runtime#

The runtime sub-namespace of onnx_core (core::runtime) hosts the generic execution engine: the runtime value types (Tensor, Sequence, Map), RuntimeContext, the node/graph/function/model traversal (RunNode(), RunNodes(), RunGraph(), RunFunction(), RunModel()), random-number helpers, and low-level cast/promotion helpers shared by many kernels.

onnx_core never depends on onnx_kernels, so the kernel dispatch table starts out empty: it is a mutable registry (RegisterKernelFn()) that onnx_kernels populates with its per-operator trampolines (see kernel_dispatch_table.h) via onnx_light::onnx_kernels::RegisterKernelFunctions(). Any consumer of the runtime (Python bindings, tests, examples, …) must call that function once before using RunNode() / RunModel() or any other entry point that dispatches to a registered kernel.

Control-flow operators (If, Loop, Scan) are the one exception to “all kernels live in onnx_kernels”: since running their subgraphs recursively calls RunGraph(), which must live in onnx_core, their kernel classes live here too, under runtime/controlflow, to avoid a dependency from onnx_core back onto onnx_kernels.