microsoft / microsoft/onnxruntime
Apply compile-time kernel registration table validation to remaining execution providers
@GopalakrishnanN is already working on this.
Since Jul 31, 2026.
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
Follow-up to #29649.
#29649 added a `consteval` helper, `onnxruntime::registration_internal::IsKernelRegistrationTableValid`, that validates the `BuildKernelCreateInfoFn function_table[]` + `BuildKernelCreateInfo` sentinel pattern at compile time, and applied it to the CPU EP's ONNX / FP16 / ONNX-ML tables. The helper now lives in the shared header `onnxruntime/core/providers/kernel_registration_validation.h` (with a `SHARED_PROVIDER` guard) so other providers can use it.
Several other providers use the same pattern and are still unvalidated, for example:
- `onnxruntime/core/providers/cuda/cuda_execution_provider.cc`
- `onnxruntime/core/providers/xnnpack/xnnpack_execution_provider.cc`
- `onnxruntime/core/providers/js/js_execution_provider.cc`
- `onnxruntime/core/providers/webnn/webnn_execution_provider.cc`
- `onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc`
- `onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc`
- `onnxruntime/core/providers/cann/cann_execution_provider.cc`
- `onnxruntime/core/providers/acl/acl_execution_provider.cc`
- `onnxruntime/core/providers/snpe/snpe_execution_provider.cc`
- `onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc`
- `onnxruntime/core/providers/nv_tensorrt_rtx/nv_execution_provider.cc`
- `onnxruntime/contrib_ops/cpu/cpu_contrib_kernels.cc` (4 tables)
- `onnxruntime/contrib_ops/cuda/cuda_contrib_kernels.cc`
- `onnxruntime/contrib_ops/js/js_contrib_kernels.cc`
- `orttraining/orttraining/training_ops/{cpu,cuda}/*_training_kernels.cc`
For each: change `static const` to `static constexpr` on the table and add
`static_assert(registration_internal::IsKernelRegistrationTableValid(function_table, BuildKernelCreateInfo));`.
Best done per-provider so each change can be validated by a build config that actually compiles that EP.
Raised by @titaiwangms in https://github.com/microsoft/onnxruntime/pull/29649.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.