CreateLoopKernel property

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

\brief Creates an OrtKernelImpl instance for a Loop 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 ('M') and input1 ('cond') on the CPU (i.e., OrtMemTypeCPUInput) as these inputs are used by CPU logic. Input2 ('v_initial') and 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("Loop").SetSinceVersion(21, 22) .SetExecutionProvider("MyEp") .SetInputMemType(0, OrtMemTypeCPUInput) // 'M' on CPU .SetInputMemType(1, OrtMemTypeCPUInput) // 'cond' on CPU .SetInputMemType(2, OrtMemTypeDefault) // 'v_initial' on EP device .SetOutputMemType(0, OrtMemTypeDefault) // output on EP device .AddTypeConstraint("I", ...) .AddTypeConstraint("B", ...) .AddTypeConstraint("V", ...).Build();

\paramin kernel_info The ::OrtKernelInfo instance for a Loop node. This function returns error ORT_FAIL if the opset version specified by kernel_info is unsupported. \paramin helper A OrtLoopKernelHelper instance that contains helper functions that ORT calls during kernel execution to operate on tensors allocated with the EP's device memory. ORT will call OrtLoopKernelHelper::Release() to release the helper and its resources. \paramout kernel_out Output parameter set to the OrtKernelImpl instance for the Loop 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<OrtLoopKernelHelper> helper,
      ffi.Pointer<ffi.Pointer<OrtKernelImpl>> kernel_out,
    )
  >
>
CreateLoopKernel;