CreateIfKernel property

Pointer<NativeFunction<OrtStatusPtr Function(Pointer<OrtKernelInfo> kernel_info, Pointer<Pointer<OrtKernelImpl>> kernel_out)>> CreateIfKernel
getter/setter pair

\brief Creates an OrtKernelImpl instance for an If operator.

Control flow operators require access to ORT session internals to orchestrate subgraph operations. This function allows an EP to create a properly configured OrtKernelImpl with access to ORT internals that the EP can add to its kernel registry.

An EP is required to create an OrtKernelDef that keeps input0 ('cond') on the CPU (i.e., OrtMemTypeCPUInput) as this input is used by CPU logic. The output should remain on the device (i.e., OrtMemTypeDefault), which is the default setting, to avoid copying to/from CPU.

Example kernel definition (CXX API): Ort::KernelDef kernel_def = Ort::KernelDefBuilder() .SetDomain("").SetOperatorType("If").SetSinceVersion(21, 22) .SetExecutionProvider("MyEp") .SetInputMemType(0, OrtMemTypeCPUInput) // 'cond' on CPU .SetOutputMemType(0, OrtMemTypeDefault) // output on EP device .AddTypeConstraint("B", ...) .AddTypeConstraint("V", ...).Build();

\paramin kernel_info The ::OrtKernelInfo instance for an If node. This function returns error ORT_FAIL if the opset version specified by kernel_info is unsupported. \paramout kernel_out Output parameter set to the OrtKernelImpl instance for the If node. Must be released via ::ReleaseKernelImpl, unless ownership is transferred to ORT (see OrtKernelCreateFunc and ::KernelRegistry_AddKernel()).

\snippet{doc} snippets.dox OrtStatus Return Value \since Version 1.24

Implementation

external ffi.Pointer<
  ffi.NativeFunction<
    OrtStatusPtr Function(
      ffi.Pointer<OrtKernelInfo> kernel_info,
      ffi.Pointer<ffi.Pointer<OrtKernelImpl>> kernel_out,
    )
  >
>
CreateIfKernel;