CreateSharedAllocator property

Pointer<NativeFunction<OrtStatusPtr Function(Pointer<OrtEnv> env, Pointer<OrtEpDevice> ep_device, UnsignedInt mem_type, Int allocator_type, Pointer<OrtKeyValuePairs> allocator_options, Pointer<Pointer<OrtAllocator>> allocator)>> CreateSharedAllocator
getter/setter pair

\brief Create/replace a shared allocator for the OrtEpDevice in the OrtEnv.

OrtEpDevice maps to the EP factory, and the factory provides the allocator implementation.

Both OrtDeviceMemoryType_DEFAULT and OrtDeviceMemoryType_HOST_ACCESSIBLE are optional for an EP to provide. It is EP implementation dependent as to what is available.

If a shared allocator already exists for the OrtEpDevice and OrtDeviceMemoryType, it is replaced. This allows changing the shared allocator configuration from the default. e.g. adding an arena.

\paramin env The OrtEnv instance to create the shared allocator in. \paramin ep_device The OrtEpDevice instance to create the shared allocator for. \paramin mem_type The memory type to use for the shared allocator. \paramin allocator_type The type of allocator to create. Only OrtDeviceAllocator is valid currently. \paramin allocator_options Optional key-value pairs to configure the allocator. If arena based, see include/onnxruntime/core/framework/allocator.h for the keys and values that can be used. \paramout allocator A pointer to the created shared allocator. Owned by the OrtEnv instance.

\snippet{doc} snippets.dox OrtStatus Return Value

\since Version 1.23

Implementation

external ffi.Pointer<
  ffi.NativeFunction<
    OrtStatusPtr Function(
      ffi.Pointer<OrtEnv> env,
      ffi.Pointer<OrtEpDevice> ep_device,
      ffi.UnsignedInt mem_type,
      ffi.Int allocator_type,
      ffi.Pointer<OrtKeyValuePairs> allocator_options,
      ffi.Pointer<ffi.Pointer<OrtAllocator>> allocator,
    )
  >
>
CreateSharedAllocator;