ONNX Runtime: OrtApi Struct Reference
The C API. More...
#include <onnxruntime_c_api.h>
Public Member Functions | |
| OrtStatus * | SynchronizeBoundInputs (OrtIoBinding *binding_ptr) |
| Synchronize bound inputs. The call may be necessary for some providers, such as cuda, in case the system that allocated bound memory operated on a different stream. However, the operation is provider specific and could be a no-op. | |
| OrtStatus * | SynchronizeBoundOutputs (OrtIoBinding *binding_ptr) |
| Synchronize bound outputs. The call may be necessary for some providers, such as cuda, in case the system that allocated bound memory operated on a different stream. However, the operation is provider specific and could be a no-op. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_MIGraphX (OrtSessionOptions *options, const OrtMIGraphXProviderOptions *migraphx_options) |
| Append MIGraphX provider to session options. | |
| OrtStatus * | AddExternalInitializers (OrtSessionOptions *options, const char *const *initializer_names, const OrtValue *const *initializers, size_t num_initializers) |
| Replace initialized Tensors with external data with the data provided in initializers. | |
| OrtStatus * | CreateOpAttr (const char *name, const void *data, int len, OrtOpAttrType type, OrtOpAttr **op_attr) |
| : Create attribute of onnxruntime operator | |
| void | ReleaseOpAttr (OrtOpAttr *input) |
| OrtStatus * | CreateOp (const OrtKernelInfo *info, const char *op_name, const char *domain, int version, const char **type_constraint_names, const ONNXTensorElementDataType *type_constraint_values, int type_constraint_count, const OrtOpAttr *const *attr_values, int attr_count, int input_count, int output_count, OrtOp **ort_op) |
| : Create onnxruntime native operator | |
| OrtStatus * | InvokeOp (const OrtKernelContext *context, const OrtOp *ort_op, const OrtValue *const *input_values, int input_count, OrtValue *const *output_values, int output_count) |
| : Invoke the operator created by OrtApi::CreateOp The inputs must follow the order as specified in onnx specification | |
| void | ReleaseOp (OrtOp *input) |
| OrtStatus * | SessionOptionsAppendExecutionProvider (OrtSessionOptions *options, const char *provider_name, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| : Append execution provider to the session options. | |
| OrtStatus * | CopyKernelInfo (const OrtKernelInfo *info, OrtKernelInfo **info_copy) |
| void | ReleaseKernelInfo (OrtKernelInfo *input) |
| OrtStatus * | SessionOptionsAppendExecutionProvider_CANN (OrtSessionOptions *options, const OrtCANNProviderOptions *cann_options) |
| Append CANN provider to session options. | |
| OrtStatus * | CreateCANNProviderOptions (OrtCANNProviderOptions **out) |
| Create an OrtCANNProviderOptions. | |
| OrtStatus * | UpdateCANNProviderOptions (OrtCANNProviderOptions *cann_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Set options in a CANN Execution Provider. | |
| OrtStatus * | GetCANNProviderOptionsAsString (const OrtCANNProviderOptions *cann_options, OrtAllocator *allocator, char **ptr) |
| Get serialized CANN provider options string. | |
| OrtStatus * | UpdateEnvWithCustomLogLevel (OrtEnv *ort_env, OrtLoggingLevel log_severity_level) |
| OrtStatus * | SetGlobalIntraOpThreadAffinity (OrtThreadingOptions *tp_options, const char *affinity_string) |
| OrtStatus * | RegisterCustomOpsLibrary_V2 (OrtSessionOptions *options, const char *library_name) |
| Register custom ops from a shared library. | |
| OrtStatus * | RegisterCustomOpsUsingFunction (OrtSessionOptions *options, const char *registration_func_name) |
| Register custom ops by calling a RegisterCustomOpsFn function. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_Dnnl (OrtSessionOptions *options, const OrtDnnlProviderOptions *dnnl_options) |
| Append dnnl provider to session options. | |
| OrtStatus * | CreateDnnlProviderOptions (OrtDnnlProviderOptions **out) |
| Create an OrtDnnlProviderOptions. | |
| OrtStatus * | UpdateDnnlProviderOptions (OrtDnnlProviderOptions *dnnl_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Set options in a oneDNN Execution Provider. | |
| OrtStatus * | GetDnnlProviderOptionsAsString (const OrtDnnlProviderOptions *dnnl_options, OrtAllocator *allocator, char **ptr) |
| OrtStatus * | KernelInfoGetConstantInput_tensor (const OrtKernelInfo *info, size_t index, int *is_constant, const OrtValue **out) |
| Get a OrtValue tensor stored as a constant initializer in the graph node. | |
| OrtStatus * | CastTypeInfoToOptionalTypeInfo (const OrtTypeInfo *type_info, const OrtOptionalTypeInfo **out) |
| Get Optional Type information from an OrtTypeInfo. | |
| OrtStatus * | GetOptionalContainedTypeInfo (const OrtOptionalTypeInfo *optional_type_info, OrtTypeInfo **out) |
| Get OrtTypeInfo for the allowed contained type from an OrtOptionalTypeInfo. | |
| OrtStatus * | GetResizedStringTensorElementBuffer (OrtValue *value, size_t index, size_t length_in_bytes, char **buffer) |
| Set a single string in a string tensor Do not zero terminate the string data. | |
| OrtStatus * | KernelContext_GetAllocator (const OrtKernelContext *context, const OrtMemoryInfo *mem_info, OrtAllocator **out) |
| Get Allocator from KernelContext for a specific memoryInfo. Please use C API ReleaseAllocator to release out object. | |
| void | ReleaseValueInfo (OrtValueInfo *input) |
| Release an OrtValueInfo instance if it was not added to an OrtGraph. | |
| void | ReleaseNode (OrtNode *input) |
| Release an OrtNode if it was not added to an OrtGraph. | |
| void | ReleaseGraph (OrtGraph *input) |
| Release an OrtGraph. | |
| void | ReleaseModel (OrtModel *input) |
| Release an OrtModel. | |
| OrtStatus * | GetValueInfoName (const OrtValueInfo *value_info, const char **name) |
| Get the value name from an OrtValueInfo instance. | |
| OrtStatus * | GetValueInfoTypeInfo (const OrtValueInfo *value_info, const OrtTypeInfo **type_info) |
| Get the type information from an OrtValueInfo instance. | |
| OrtStatus * | CreateTensorWithDataAndDeleterAsOrtValue (OrtAllocator *deleter, void *p_data, size_t p_data_len, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out) |
| Create an OrtValue for a Tensor that uses pre-existing memory. | |
| OrtStatus * | SessionOptionsSetLoadCancellationFlag (OrtSessionOptions *options, bool cancel) |
| sets load cancellation flag to abort session loading process. | |
| void | ReleaseKeyValuePairs (OrtKeyValuePairs *input) |
| Release an OrtKeyValuePairs instance. | |
| OrtStatus * | RegisterExecutionProviderLibrary (OrtEnv *env, const char *registration_name, const char *path) |
| Register an execution provider library with ORT. | |
| OrtStatus * | UnregisterExecutionProviderLibrary (OrtEnv *env, const char *registration_name) |
| Unregister an execution provider library with ORT. | |
| OrtStatus * | GetEpDevices (const OrtEnv *env, const OrtEpDevice *const **ep_devices, size_t *num_ep_devices) |
| Get the list of available OrtEpDevice instances. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_V2 (OrtSessionOptions *session_options, OrtEnv *env, const OrtEpDevice *const *ep_devices, size_t num_ep_devices, const char *const *ep_option_keys, const char *const *ep_option_vals, size_t num_ep_options) |
| Append the execution provider that is responsible for the selected OrtEpDevice instances to the session options. | |
| OrtStatus * | SessionOptionsSetEpSelectionPolicy (OrtSessionOptions *session_options, OrtExecutionProviderDevicePolicy policy) |
| Set the execution provider selection policy for the session. | |
| OrtStatus * | SessionOptionsSetEpSelectionPolicyDelegate (OrtSessionOptions *session_options, EpSelectionDelegate delegate, void *delegate_state) |
| Set the execution provider selection policy delegate for the session. | |
| OrtStatus * | GetTensorSizeInBytes (const OrtValue *ort_value, size_t *size) |
| Compute total size in bytes of the tensor data contained in an OrtValue. | |
| OrtStatus * | AllocatorGetStats (const OrtAllocator *ort_allocator, OrtKeyValuePairs **out) |
| Calls OrtAllocator::GetStats function. | |
| OrtStatus * | CreateMemoryInfo_V2 (const char *name, enum OrtMemoryInfoDeviceType device_type, uint32_t vendor_id, int32_t device_id, enum OrtDeviceMemoryType mem_type, size_t alignment, enum OrtAllocatorType allocator_type, OrtMemoryInfo **out) |
| Create an OrtMemoryInfo. | |
| OrtStatus * | CreateSharedAllocator (OrtEnv *env, const OrtEpDevice *ep_device, OrtDeviceMemoryType mem_type, OrtAllocatorType allocator_type, const OrtKeyValuePairs *allocator_options, OrtAllocator **allocator) |
| Create/replace a shared allocator for the OrtEpDevice in the OrtEnv. | |
| OrtStatus * | GetSharedAllocator (OrtEnv *env, const OrtMemoryInfo *mem_info, OrtAllocator **allocator) |
| Get a shared allocator from the OrtEnv. | |
| OrtStatus * | ReleaseSharedAllocator (OrtEnv *env, const OrtEpDevice *ep_device, OrtDeviceMemoryType mem_type) |
| Release a shared allocator from the OrtEnv for the OrtEpDevice and memory type. | |
| OrtStatus * | GetTensorData (const OrtValue *value, const void **out) |
| Get a const pointer to the raw data inside a tensor. | |
| OrtStatus * | GetSessionOptionsConfigEntries (const OrtSessionOptions *options, OrtKeyValuePairs **out) |
| Get Session configuration entries. | |
| OrtStatus * | SessionGetMemoryInfoForInputs (const OrtSession *session, const OrtMemoryInfo **inputs_memory_info, size_t num_inputs) |
| Get the OrtMemoryInfo for each input of the session. | |
| OrtStatus * | SessionGetMemoryInfoForOutputs (const OrtSession *session, const OrtMemoryInfo **outputs_memory_info, size_t num_outputs) |
| Get the OrtMemoryInfo for each output of the session. | |
| OrtStatus * | SessionGetEpDeviceForInputs (const OrtSession *session, const OrtEpDevice **inputs_ep_devices, size_t num_inputs) |
| Get the OrtEpDevice (if available) for each input of the session. | |
| OrtStatus * | CreateSyncStreamForEpDevice (const OrtEpDevice *ep_device, const OrtKeyValuePairs *stream_options, OrtSyncStream **stream) |
| Create an OrtSyncStream for the given OrtEpDevice. | |
| void | ReleaseSyncStream (OrtSyncStream *input) |
| OrtStatus * | CopyTensors (const OrtEnv *env, const OrtValue *const *src_tensors, OrtValue *const *dst_tensors, OrtSyncStream *stream, size_t num_tensors) |
| Copy OrtValue instances containing Tensors between devices. | |
| OrtStatus * | Graph_GetModelMetadata (const OrtGraph *graph, OrtModelMetadata **out) |
| Get OrtModelMetadata from an OrtGraph. | |
| OrtStatus * | GetModelCompatibilityForEpDevices (const OrtEpDevice *const *ep_devices, size_t num_ep_devices, const char *compatibility_info, OrtCompiledModelCompatibility *out_status) |
| Validate a compiled model's compatibility information for one or more EP devices. | |
| OrtStatus * | KernelInfo_GetConfigEntries (const OrtKernelInfo *info, OrtKeyValuePairs **out) |
| Get all config entries from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetOperatorDomain (const OrtKernelInfo *info, char *out, size_t *size) |
| Get the graph node's operator domain from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetOperatorType (const OrtKernelInfo *info, char *out, size_t *size) |
| Get the graph node's operator type from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetOperatorSinceVersion (const OrtKernelInfo *info, int *since_version) |
| Get the opset version in which the given node's operator type was first defined from OrtKernelInfo. | |
| OrtStatus * | SessionGetEpDeviceForOutputs (const OrtSession *session, const OrtEpDevice **outputs_ep_devices, size_t num_outputs) |
| Get the EP device assigned to each session output. | |
| OrtStatus * | GetNumHardwareDevices (const OrtEnv *env, size_t *num_devices) |
| Get the number of available hardware devices. | |
| OrtStatus * | GetHardwareDevices (const OrtEnv *env, const OrtHardwareDevice **devices, size_t num_devices) |
| Get the list of available hardware devices. | |
| OrtStatus * | GetHardwareDeviceEpIncompatibilityDetails (const OrtEnv *env, const char *ep_name, const OrtHardwareDevice *hw, OrtDeviceEpIncompatibilityDetails **details) |
| Check for known incompatibility issues between hardware device and a specific execution provider. | |
| OrtStatus * | CreateEnvWithOptions (const OrtEnvCreationOptions *options, OrtEnv **out) |
| Create an OrtEnv instance with the given options. | |
| OrtStatus * | Session_GetEpGraphAssignmentInfo (const OrtSession *session, const OrtEpAssignedSubgraph *const **ep_subgraphs, size_t *num_ep_subgraphs) |
| Get information about the subgraphs assigned to each execution provider (EP) and the nodes within. | |
| OrtStatus * | EpAssignedSubgraph_GetEpName (const OrtEpAssignedSubgraph *ep_subgraph, const char **out) |
| Get the name of the execution provider to which the subgraph was assigned. | |
| OrtStatus * | EpAssignedSubgraph_GetNodes (const OrtEpAssignedSubgraph *ep_subgraph, const OrtEpAssignedNode *const **ep_nodes, size_t *num_ep_nodes) |
| Get the nodes in a subgraph assigned to a specific execution provider. | |
| OrtStatus * | EpAssignedNode_GetName (const OrtEpAssignedNode *ep_node, const char **out) |
| Get the name of the node assigned to an execution provider. | |
| OrtStatus * | EpAssignedNode_GetDomain (const OrtEpAssignedNode *ep_node, const char **out) |
| Get the domain of the node assigned to an execution provider. | |
| OrtStatus * | EpAssignedNode_GetOperatorType (const OrtEpAssignedNode *ep_node, const char **out) |
| Get the operator type of the node assigned to an execution provider. | |
| OrtStatus * | GetTensorElementTypeAndShapeDataReference (const OrtValue *value, ONNXTensorElementDataType *elem_type, const int64_t **shape_data, size_t *shape_data_count) |
| Get the element data type and shape for an OrtValue that represents a Tensor (scalar, dense, or sparse). | |
| OrtStatus * | RunOptionsEnableProfiling (OrtRunOptions *options, const char *profile_file_prefix) |
| Enable profiling for this run. | |
| OrtStatus * | RunOptionsDisableProfiling (OrtRunOptions *options) |
| Disable profiling for this run. | |
Public Attributes | |
| void(* | ReleaseCANNProviderOptions )(OrtCANNProviderOptions *input) |
| Release an OrtCANNProviderOptions. | |
| void(* | MemoryInfoGetDeviceType )(const OrtMemoryInfo *ptr, OrtMemoryInfoDeviceType *out) |
| void(* | ReleaseDnnlProviderOptions )(OrtDnnlProviderOptions *input) |
| Release an OrtDnnlProviderOptions. | |
| const char *(* | GetBuildInfoString )(void) |
| Returns a null terminated string of the build info including git info and cxx flags. | |
| const OrtModelEditorApi *(* | GetModelEditorApi )(void) |
| Get the Model Editor API instance. | |
| const OrtCompileApi *(* | GetCompileApi )(void) |
| Get the Compile API instance. | |
| void(* | CreateKeyValuePairs )(OrtKeyValuePairs **out) |
| Create an OrtKeyValuePairs instance. | |
| void(* | AddKeyValuePair )(OrtKeyValuePairs *kvps, const char *key, const char *value) |
| Add a key-value pair to the OrtKeyValuePairs instance. | |
| const char *(* | GetKeyValue )(const OrtKeyValuePairs *kvps, const char *key) |
| Get the value associated with a key in the OrtKeyValuePairs instance. | |
| void(* | GetKeyValuePairs )(const OrtKeyValuePairs *kvps, const char *const **keys, const char *const **values, size_t *num_entries) |
| Get all the key-value pairs from the OrtKeyValuePairs instance. | |
| void(* | RemoveKeyValuePair )(OrtKeyValuePairs *kvps, const char *key) |
| Remove a key-value pair from the OrtKeyValuePairs instance. | |
| OrtHardwareDeviceType(* | HardwareDevice_Type )(const OrtHardwareDevice *device) |
| Get the hardware device type. | |
| uint32_t(* | HardwareDevice_VendorId )(const OrtHardwareDevice *device) |
| Get the hardware device's vendor identifier. | |
| const char *(* | HardwareDevice_Vendor )(const OrtHardwareDevice *device) |
| Get the hardware device's vendor name. | |
| uint32_t(* | HardwareDevice_DeviceId )(const OrtHardwareDevice *device) |
| Get the hardware device's unique identifier. | |
| const OrtKeyValuePairs *(* | HardwareDevice_Metadata )(const OrtHardwareDevice *device) |
| Get hardware device metadata. | |
| const char *(* | EpDevice_EpName )(const OrtEpDevice *ep_device) |
| Get the execution provider name. | |
| const char *(* | EpDevice_EpVendor )(const OrtEpDevice *ep_device) |
| Get the execution provider's vendor name. | |
| const OrtKeyValuePairs *(* | EpDevice_EpMetadata )(const OrtEpDevice *ep_device) |
| Get the metadata for the OrtEpDevice. | |
| const OrtKeyValuePairs *(* | EpDevice_EpOptions )(const OrtEpDevice *ep_device) |
| Get the execution provider options for the OrtEpDevice. | |
| const OrtHardwareDevice *(* | EpDevice_Device )(const OrtEpDevice *ep_device) |
| Get the OrtHardwareDevice instance for the OrtEpDevice. | |
| const OrtEpApi *(* | GetEpApi )(void) |
| Get the OrtEpApi instance for implementing an execution provider. | |
| OrtDeviceMemoryType(* | MemoryInfoGetDeviceMemType )(const OrtMemoryInfo *ptr) |
| Get the device memory type from OrtMemoryInfo. | |
| uint32_t(* | MemoryInfoGetVendorId )(const OrtMemoryInfo *ptr) |
| Get the vendor id from OrtMemoryInfo. | |
| const OrtMemoryInfo *(* | EpDevice_MemoryInfo )(const OrtEpDevice *ep_device, OrtDeviceMemoryType memory_type) |
| Get the OrtMemoryInfo for the device. | |
| void *(* | SyncStream_GetHandle )(OrtSyncStream *stream) |
| Get the native handle of the sync stream. | |
| bool(* | TensorTypeAndShape_HasShape )(const OrtTensorTypeAndShapeInfo *info) |
| Fetch whether the tensor has shape information. | |
| const OrtInteropApi *(* | GetInteropApi )(void) |
| Get the EP Interop API instance. | |
| void(* | RunOptionsSetSyncStream )(OrtRunOptions *options, OrtSyncStream *sync_stream) |
| Sets OrtSyncStream for the run options. | |
OrtStatus | |
| OrtStatus *(* | CreateStatus )(OrtErrorCode code, const char *msg) __attribute__((nonnull)) |
| Create an OrtStatus from a null terminated string. | |
| OrtErrorCode(* | GetErrorCode )(const OrtStatus *status) __attribute__((nonnull)) |
| Get OrtErrorCode from OrtStatus. | |
| const char *(* | GetErrorMessage )(const OrtStatus *status) __attribute__((nonnull)) |
| Get error string from OrtStatus. | |
| void | ReleaseStatus (OrtStatus *input) |
OrtIoBinding | |
| void(* | ClearBoundInputs )(OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
| Clears any previously set Inputs for an OrtIoBinding. | |
| void(* | ClearBoundOutputs )(OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
| Clears any previously set Outputs for an OrtIoBinding. | |
| void | ReleaseIoBinding (OrtIoBinding *input) |
| Release an OrtIoBinding obtained from OrtApi::CreateIoBinding. | |
| OrtStatus * | BindInput (OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr) |
| Bind an OrtValue to an OrtIoBinding input. | |
| OrtStatus * | BindOutput (OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr) |
| Bind an OrtValue to an OrtIoBinding output. | |
| OrtStatus * | BindOutputToDevice (OrtIoBinding *binding_ptr, const char *name, const OrtMemoryInfo *mem_info_ptr) |
| Bind an OrtIoBinding output to a device. | |
| OrtStatus * | GetBoundOutputNames (const OrtIoBinding *binding_ptr, OrtAllocator *allocator, char **buffer, size_t **lengths, size_t *count) |
| Get the names of an OrtIoBinding's outputs. | |
| OrtStatus * | GetBoundOutputValues (const OrtIoBinding *binding_ptr, OrtAllocator *allocator, OrtValue ***output, size_t *output_count) |
| Get the output OrtValue objects from an OrtIoBinding. | |
OrtTensorRTProviderOptionsV2 | |
| void(* | ReleaseTensorRTProviderOptions )(OrtTensorRTProviderOptionsV2 *input) |
| Release an OrtTensorRTProviderOptionsV2. | |
| OrtStatus * | CreateTensorRTProviderOptions (OrtTensorRTProviderOptionsV2 **out) |
| Create an OrtTensorRTProviderOptionsV2. | |
| OrtStatus * | UpdateTensorRTProviderOptions (OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Set options in a TensorRT Execution Provider. | |
| OrtStatus * | GetTensorRTProviderOptionsAsString (const OrtTensorRTProviderOptionsV2 *tensorrt_options, OrtAllocator *allocator, char **ptr) |
| Get serialized TensorRT provider options string. | |
OrtCUDAProviderOptionsV2 | |
| void(* | ReleaseCUDAProviderOptions )(OrtCUDAProviderOptionsV2 *input) |
| Release an OrtCUDAProviderOptionsV2. | |
| OrtStatus * | CreateCUDAProviderOptions (OrtCUDAProviderOptionsV2 **out) |
| Create an OrtCUDAProviderOptionsV2. | |
| OrtStatus * | UpdateCUDAProviderOptions (OrtCUDAProviderOptionsV2 *cuda_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Set options in a CUDA Execution Provider. | |
| OrtStatus * | GetCUDAProviderOptionsAsString (const OrtCUDAProviderOptionsV2 *cuda_options, OrtAllocator *allocator, char **ptr) |
OrtROCMProviderOptions | |
| void(* | ReleaseROCMProviderOptions )(OrtROCMProviderOptions *input) |
| Release an OrtROCMProviderOptions. | |
| OrtStatus * | CreateROCMProviderOptions (OrtROCMProviderOptions **out) |
| Create an OrtROCMProviderOptions. | |
| OrtStatus * | UpdateROCMProviderOptions (OrtROCMProviderOptions *rocm_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Set options in a ROCm Execution Provider. | |
| OrtStatus * | GetROCMProviderOptionsAsString (const OrtROCMProviderOptions *rocm_options, OrtAllocator *allocator, char **ptr) |
| OrtStatus * | CreateAndRegisterAllocatorV2 (OrtEnv *env, const char *provider_type, const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Create an allocator with specific type and register it with the OrtEnv This API enhance CreateAndRegisterAllocator that it can create an allocator with specific type, not just CPU allocator Enables sharing the allocator between multiple sessions that use the same env instance. Lifetime of the created allocator will be valid for the duration of the environment. Returns an error if an allocator with the same OrtMemoryInfo is already registered. | |
| OrtStatus * | RunAsync (OrtSession *session, const OrtRunOptions *run_options, const char *const *input_names, const OrtValue *const *input, size_t input_len, const char *const *output_names, size_t output_names_len, OrtValue **output, RunAsyncCallbackFn run_async_callback, void *user_data) |
| Run the model asynchronously in a thread owned by intra op thread pool. | |
| OrtStatus * | UpdateTensorRTProviderOptionsWithValue (OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *key, void *value) |
| OrtStatus * | GetTensorRTProviderOptionsByName (const OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *key, void **ptr) |
| OrtStatus * | UpdateCUDAProviderOptionsWithValue (OrtCUDAProviderOptionsV2 *cuda_options, const char *key, void *value) |
| OrtStatus * | GetCUDAProviderOptionsByName (const OrtCUDAProviderOptionsV2 *cuda_options, const char *key, void **ptr) |
| OrtStatus * | KernelContext_GetResource (const OrtKernelContext *context, int resource_version, int resource_id, void **resource) |
| OrtStatus * | SetUserLoggingFunction (OrtSessionOptions *options, OrtLoggingFunction user_logging_function, void *user_logging_param) |
| Set user logging function. | |
| OrtStatus * | ShapeInferContext_GetInputCount (const OrtShapeInferContext *context, size_t *out) |
| OrtStatus * | ShapeInferContext_GetInputTypeShape (const OrtShapeInferContext *context, size_t index, OrtTensorTypeAndShapeInfo **info) |
| OrtStatus * | ShapeInferContext_GetAttribute (const OrtShapeInferContext *context, const char *attr_name, const OrtOpAttr **attr) |
| OrtStatus * | ShapeInferContext_SetOutputTypeShape (const OrtShapeInferContext *context, size_t index, const OrtTensorTypeAndShapeInfo *info) |
| OrtStatus * | SetSymbolicDimensions (OrtTensorTypeAndShapeInfo *info, const char *dim_params[], size_t dim_params_length) |
| OrtStatus * | ReadOpAttr (const OrtOpAttr *op_attr, OrtOpAttrType type, void *data, size_t len, size_t *out) |
| OrtStatus * | SetDeterministicCompute (OrtSessionOptions *options, bool value) |
| Set whether to use deterministic compute. | |
| OrtStatus * | KernelContext_ParallelFor (const OrtKernelContext *context, void(*fn)(void *, size_t), size_t total, size_t num_batch, void *usr_data) |
| OrtStatus * | SessionOptionsAppendExecutionProvider_OpenVINO_V2 (OrtSessionOptions *options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Append OpenVINO execution provider to the session options. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_VitisAI (OrtSessionOptions *options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys) |
| Append VitisAI provider to session options. | |
| OrtStatus * | KernelContext_GetScratchBuffer (const OrtKernelContext *context, const OrtMemoryInfo *mem_info, size_t count_or_bytes, void **out) |
| Get scratch buffer from the corresponding allocator under the specific OrtMemoryInfo object. NOTE: callers are responsible to release this scratch buffer from the corresponding allocator. | |
| OrtStatus * | KernelInfoGetAllocator (const OrtKernelInfo *info, OrtMemType mem_type, OrtAllocator **out) |
| Get allocator from KernelInfo for a specific memory type. Please use C API ReleaseAllocator to release out object. | |
| OrtStatus * | AddExternalInitializersFromFilesInMemory (OrtSessionOptions *options, const char *const *external_initializer_file_names, char *const *external_initializer_file_buffer_array, const size_t *external_initializer_file_lengths, size_t num_external_initializer_files) |
| Replace initialized Tensors with external data with the provided files in memory. | |
| OrtStatus * | CreateLoraAdapter (const char *adapter_file_path, OrtAllocator *allocator, OrtLoraAdapter **out) |
| Create an OrtLoraAdapter. | |
| OrtStatus * | CreateLoraAdapterFromArray (const void *bytes, size_t num_bytes, OrtAllocator *allocator, OrtLoraAdapter **out) |
| Create an OrtLoraAdapter. | |
| void | ReleaseLoraAdapter (OrtLoraAdapter *input) |
| Release an OrtLoraAdapter obtained from OrtApi::CreateLoraAdapter. | |
| OrtStatus * | RunOptionsAddActiveLoraAdapter (OrtRunOptions *options, const OrtLoraAdapter *adapter) |
| Add the Lora Adapter to the list of active adapters. | |
OrtExternalInitializerInfo | |
| const char *(* | ExternalInitializerInfo_GetFilePath )(const OrtExternalInitializerInfo *info) |
| Get the relative path to the file that stores the initializer's data. | |
| int64_t(* | ExternalInitializerInfo_GetFileOffset )(const OrtExternalInitializerInfo *info) |
| Get the byte offset within the file where the initializer's data is stored. | |
| size_t(* | ExternalInitializerInfo_GetByteSize )(const OrtExternalInitializerInfo *info) |
| Get the size in bytes of the initializer's data within the file. | |
| void | ReleaseExternalInitializerInfo (OrtExternalInitializerInfo *input) |
| Release an OrtExternalInitializerInfo instance. | |
| OrtStatus * | CreateExternalInitializerInfo (const char *filepath, int64_t file_offset, size_t byte_size, OrtExternalInitializerInfo **out) |
| Creates an OrtExternalInitializerInfo instance. | |
OrtRunOptions | |
| const char *(* | GetRunConfigEntry )(const OrtRunOptions *options, const char *config_key) |
| Get a run configuration entry. | |
| OrtStatus * | CreateRunOptions (OrtRunOptions **out) |
| Create an OrtRunOptions. | |
| OrtStatus * | RunOptionsSetRunLogVerbosityLevel (OrtRunOptions *options, int log_verbosity_level) |
| Set per-run log verbosity level. | |
| OrtStatus * | RunOptionsSetRunLogSeverityLevel (OrtRunOptions *options, int log_severity_level) |
| Set per-run log severity level. | |
| OrtStatus * | RunOptionsSetRunTag (OrtRunOptions *options, const char *run_tag) |
| Set per-run tag. | |
| OrtStatus * | RunOptionsGetRunLogVerbosityLevel (const OrtRunOptions *options, int *log_verbosity_level) |
| Get per-run log verbosity level. | |
| OrtStatus * | RunOptionsGetRunLogSeverityLevel (const OrtRunOptions *options, int *log_severity_level) |
| Get per-run log severity level. | |
| OrtStatus * | RunOptionsGetRunTag (const OrtRunOptions *options, const char **run_tag) |
| Get per-run tag. | |
| OrtStatus * | RunOptionsSetTerminate (OrtRunOptions *options) |
| Set terminate flag. | |
| OrtStatus * | RunOptionsUnsetTerminate (OrtRunOptions *options) |
| Clears the terminate flag. | |
| void | ReleaseRunOptions (OrtRunOptions *input) |
| OrtStatus * | AddRunConfigEntry (OrtRunOptions *options, const char *config_key, const char *config_value) |
| Set a single run configuration entry as a pair of strings. | |
OrtEnv | |
| OrtStatus * | CreateEnv (OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out) |
| Create an OrtEnv. | |
| OrtStatus * | CreateEnvWithCustomLogger (OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out) |
| Create an OrtEnv. | |
| OrtStatus * | EnableTelemetryEvents (const OrtEnv *env) |
| Enable Telemetry. | |
| OrtStatus * | DisableTelemetryEvents (const OrtEnv *env) |
| Disable Telemetry. | |
| void | ReleaseEnv (OrtEnv *input) |
| OrtStatus * | CreateEnvWithGlobalThreadPools (OrtLoggingLevel log_severity_level, const char *logid, const OrtThreadingOptions *tp_options, OrtEnv **out) |
| Create an OrtEnv. | |
| OrtStatus * | CreateAndRegisterAllocator (OrtEnv *env, const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg) |
| Create an allocator and register it with the OrtEnv. | |
| OrtStatus * | SetLanguageProjection (const OrtEnv *ort_env, OrtLanguageProjection projection) |
| Set language projection. | |
| OrtStatus * | CreateEnvWithCustomLoggerAndGlobalThreadPools (OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, const struct OrtThreadingOptions *tp_options, OrtEnv **out) |
OrtSession | |
| OrtStatus * | CreateSession (const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtSession **out) |
| Create an OrtSession from a model file. | |
| OrtStatus * | CreateSessionFromArray (const OrtEnv *env, const void *model_data, size_t model_data_length, const OrtSessionOptions *options, OrtSession **out) |
| Create an OrtSession from memory. | |
| OrtStatus * | Run (OrtSession *session, const OrtRunOptions *run_options, const char *const *input_names, const OrtValue *const *inputs, size_t input_len, const char *const *output_names, size_t output_names_len, OrtValue **outputs) |
| Run the model in an OrtSession. | |
| OrtStatus * | SessionGetInputCount (const OrtSession *session, size_t *out) |
| Get input count for a session. | |
| OrtStatus * | SessionGetOutputCount (const OrtSession *session, size_t *out) |
| Get output count for a session. | |
| OrtStatus * | SessionGetOverridableInitializerCount (const OrtSession *session, size_t *out) |
| Get overridable initializer count. | |
| OrtStatus * | SessionGetInputTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
| Get input type information. | |
| OrtStatus * | SessionGetOutputTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
| Get output type information. | |
| OrtStatus * | SessionGetOverridableInitializerTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
| Get overridable initializer type information. | |
| OrtStatus * | SessionGetInputName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
| Get input name. | |
| OrtStatus * | SessionGetOutputName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
| Get output name. | |
| OrtStatus * | SessionGetOverridableInitializerName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
| Get overridable initializer name. | |
| void | ReleaseSession (OrtSession *input) |
| OrtStatus * | SessionEndProfiling (OrtSession *session, OrtAllocator *allocator, char **out) |
| End profiling and return filename of the profile data. | |
| OrtStatus * | SessionGetModelMetadata (const OrtSession *session, OrtModelMetadata **out) |
| Get OrtModelMetadata from an OrtSession. | |
| OrtStatus * | RunWithBinding (OrtSession *session, const OrtRunOptions *run_options, const OrtIoBinding *binding_ptr) |
| Run a model using Io Bindings for the inputs & outputs. | |
| OrtStatus * | CreateIoBinding (OrtSession *session, OrtIoBinding **out) |
| Create an OrtIoBinding instance. | |
| OrtStatus * | SessionGetProfilingStartTimeNs (const OrtSession *session, uint64_t *out) |
| Return the time that profiling was started. | |
| OrtStatus * | CreateSessionWithPrepackedWeightsContainer (const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtPrepackedWeightsContainer *prepacked_weights_container, OrtSession **out) |
| Create session with prepacked weights container. | |
| OrtStatus * | CreateSessionFromArrayWithPrepackedWeightsContainer (const OrtEnv *env, const void *model_data, size_t model_data_length, const OrtSessionOptions *options, OrtPrepackedWeightsContainer *prepacked_weights_container, OrtSession **out) |
| Create session from memory with prepacked weights container. | |
OrtSessionOptions | |
Custom operator APIs | |
| OrtStatus * | CreateSessionOptions (OrtSessionOptions **options) |
| Create an OrtSessionOptions object. | |
| OrtStatus * | SetOptimizedModelFilePath (OrtSessionOptions *options, const char *optimized_model_filepath) |
| Set filepath to save optimized model after graph level transformations. | |
| OrtStatus * | CloneSessionOptions (const OrtSessionOptions *in_options, OrtSessionOptions **out_options) |
| Create a copy of an existing OrtSessionOptions. | |
| OrtStatus * | SetSessionExecutionMode (OrtSessionOptions *options, ExecutionMode execution_mode) |
| Set execution mode. | |
| OrtStatus * | EnableProfiling (OrtSessionOptions *options, const char *profile_file_prefix) |
| Enable profiling for a session. | |
| OrtStatus * | DisableProfiling (OrtSessionOptions *options) |
| Disable profiling for a session. | |
| OrtStatus * | EnableMemPattern (OrtSessionOptions *options) |
| Enable the memory pattern optimization. | |
| OrtStatus * | DisableMemPattern (OrtSessionOptions *options) |
| Disable the memory pattern optimization. | |
| OrtStatus * | EnableCpuMemArena (OrtSessionOptions *options) |
| Enable the memory arena on CPU. | |
| OrtStatus * | DisableCpuMemArena (OrtSessionOptions *options) |
| Disable the memory arena on CPU. | |
| OrtStatus * | SetSessionLogId (OrtSessionOptions *options, const char *logid) |
| Set session log id. | |
| OrtStatus * | SetSessionLogVerbosityLevel (OrtSessionOptions *options, int session_log_verbosity_level) |
| Set session log verbosity level. | |
| OrtStatus * | SetSessionLogSeverityLevel (OrtSessionOptions *options, int session_log_severity_level) |
| Set session log severity level. | |
| OrtStatus * | SetSessionGraphOptimizationLevel (OrtSessionOptions *options, GraphOptimizationLevel graph_optimization_level) |
| Set the optimization level to apply when loading a graph. | |
| OrtStatus * | SetIntraOpNumThreads (OrtSessionOptions *options, int intra_op_num_threads) |
| Sets the number of threads used to parallelize the execution within nodes. | |
| OrtStatus * | SetInterOpNumThreads (OrtSessionOptions *options, int inter_op_num_threads) |
| Sets the number of threads used to parallelize the execution of the graph. | |
| OrtStatus * | AddCustomOpDomain (OrtSessionOptions *options, OrtCustomOpDomain *custom_op_domain) |
| Add custom op domain to a session options. | |
| OrtStatus * | RegisterCustomOpsLibrary (OrtSessionOptions *options, const char *library_path, void **library_handle) |
| OrtStatus * | AddFreeDimensionOverride (OrtSessionOptions *options, const char *dim_denotation, int64_t dim_value) |
| Override session symbolic dimensions. | |
| void | ReleaseSessionOptions (OrtSessionOptions *input) |
| OrtStatus * | DisablePerSessionThreads (OrtSessionOptions *options) |
| Use global thread pool on a session. | |
| OrtStatus * | AddFreeDimensionOverrideByName (OrtSessionOptions *options, const char *dim_name, int64_t dim_value) |
| OrtStatus * | AddSessionConfigEntry (OrtSessionOptions *options, const char *config_key, const char *config_value) |
| Set a session configuration entry as a pair of strings. | |
| OrtStatus * | AddInitializer (OrtSessionOptions *options, const char *name, const OrtValue *val) |
| Add a pre-allocated initializer to a session. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_CUDA (OrtSessionOptions *options, const OrtCUDAProviderOptions *cuda_options) |
| Append CUDA provider to session options. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_ROCM (OrtSessionOptions *options, const OrtROCMProviderOptions *rocm_options) |
| Append ROCM execution provider to the session options. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_OpenVINO (OrtSessionOptions *options, const OrtOpenVINOProviderOptions *provider_options) |
| Append OpenVINO execution provider to the session options. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_TensorRT (OrtSessionOptions *options, const OrtTensorRTProviderOptions *tensorrt_options) |
| Append TensorRT provider to session options. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_TensorRT_V2 (OrtSessionOptions *options, const OrtTensorRTProviderOptionsV2 *tensorrt_options) |
| Append TensorRT execution provider to the session options. | |
| OrtStatus * | EnableOrtCustomOps (OrtSessionOptions *options) |
| Enable custom operators. | |
| OrtStatus * | HasValue (const OrtValue *value, int *out) |
| Sets out to 1 iff an optional type OrtValue has an element, 0 otherwise (OrtValue is None) Use this API to find if the optional type OrtValue is None or not. If the optional type OrtValue is not None, use the OrtValue just like any other OrtValue. For example, if you get an OrtValue that corresponds to Optional(tensor) and if HasValue() returns true, use it as tensor and so on. | |
| OrtStatus * | SessionOptionsAppendExecutionProvider_CUDA_V2 (OrtSessionOptions *options, const OrtCUDAProviderOptionsV2 *cuda_options) |
| Append CUDA execution provider to the session options. | |
| OrtStatus * | HasSessionConfigEntry (const OrtSessionOptions *options, const char *config_key, int *out) |
| Checks if the given session configuration entry exists. | |
| OrtStatus * | GetSessionConfigEntry (const OrtSessionOptions *options, const char *config_key, char *config_value, size_t *size) |
| Get a session configuration value. | |
OrtCustomOpDomain | |
| OrtStatus * | CreateCustomOpDomain (const char *domain, OrtCustomOpDomain **out) |
| Create a custom op domain. | |
| OrtStatus * | CustomOpDomain_Add (OrtCustomOpDomain *custom_op_domain, const OrtCustomOp *op) |
| Add a custom op to a custom op domain. | |
| void | ReleaseCustomOpDomain (OrtCustomOpDomain *input) |
OrtValue | |
| OrtStatus * | CreateTensorAsOrtValue (OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out) |
| Create a tensor. | |
| OrtStatus * | CreateTensorWithDataAsOrtValue (const OrtMemoryInfo *info, void *p_data, size_t p_data_len, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out) |
| Create a tensor backed by a user supplied buffer. | |
| OrtStatus * | IsTensor (const OrtValue *value, int *out) |
| Return if an OrtValue is a tensor type. | |
| OrtStatus * | GetTensorMutableData (OrtValue *value, void **out) |
| Get a pointer to the raw data inside a tensor. | |
| OrtStatus * | FillStringTensor (OrtValue *value, const char *const *s, size_t s_len) |
| Set all strings at once in a string tensor. | |
| OrtStatus * | GetStringTensorDataLength (const OrtValue *value, size_t *len) |
| Get total byte length for all strings in a string tensor. | |
| OrtStatus * | GetStringTensorContent (const OrtValue *value, void *s, size_t s_len, size_t *offsets, size_t offsets_len) |
| Get all strings from a string tensor. | |
| OrtStatus * | GetTensorTypeAndShape (const OrtValue *value, OrtTensorTypeAndShapeInfo **out) |
| Get type and shape information from a tensor OrtValue. | |
| OrtStatus * | GetTypeInfo (const OrtValue *value, OrtTypeInfo **out) |
| Get type information of an OrtValue. | |
| OrtStatus * | GetValueType (const OrtValue *value, enum ONNXType *out) |
| Get ONNXType of an OrtValue. | |
| OrtStatus * | GetValue (const OrtValue *value, int index, OrtAllocator *allocator, OrtValue **out) |
| Get non tensor data from an OrtValue. | |
| OrtStatus * | GetValueCount (const OrtValue *value, size_t *out) |
| Get non tensor value count from an OrtValue. | |
| OrtStatus * | CreateValue (const OrtValue *const *in, size_t num_values, enum ONNXType value_type, OrtValue **out) |
| Create a map or sequence OrtValue. | |
| OrtStatus * | CreateOpaqueValue (const char *domain_name, const char *type_name, const void *data_container, size_t data_container_size, OrtValue **out) |
| Create an opaque (custom user defined type) OrtValue. | |
| OrtStatus * | GetOpaqueValue (const char *domain_name, const char *type_name, const OrtValue *in, void *data_container, size_t data_container_size) |
| Get internal data from an opaque (custom user defined type) OrtValue. | |
| void | ReleaseValue (OrtValue *input) |
| OrtStatus * | GetStringTensorElementLength (const OrtValue *value, size_t index, size_t *out) |
| Get the length of a single string in a string tensor. | |
| OrtStatus * | GetStringTensorElement (const OrtValue *value, size_t s_len, size_t index, void *s) |
| Get a single string from a string tensor. | |
| OrtStatus * | FillStringTensorElement (OrtValue *value, const char *s, size_t index) |
| Set a single string in a string tensor. | |
| OrtStatus * | TensorAt (OrtValue *value, const int64_t *location_values, size_t location_values_count, void **out) |
| Direct memory access to a specified tensor element. | |
| OrtStatus * | IsSparseTensor (const OrtValue *value, int *out) |
| Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise. | |
| OrtStatus * | CreateSparseTensorAsOrtValue (OrtAllocator *allocator, const int64_t *dense_shape, size_t dense_shape_len, ONNXTensorElementDataType type, OrtValue **out) |
| Create an OrtValue with a sparse tensor that is empty. | |
| OrtStatus * | FillSparseTensorCoo (OrtValue *ort_value, const OrtMemoryInfo *data_mem_info, const int64_t *values_shape, size_t values_shape_len, const void *values, const int64_t *indices_data, size_t indices_num) |
| OrtStatus * | FillSparseTensorCsr (OrtValue *ort_value, const OrtMemoryInfo *data_mem_info, const int64_t *values_shape, size_t values_shape_len, const void *values, const int64_t *inner_indices_data, size_t inner_indices_num, const int64_t *outer_indices_data, size_t outer_indices_num) |
| OrtStatus * | FillSparseTensorBlockSparse (OrtValue *ort_value, const OrtMemoryInfo *data_mem_info, const int64_t *values_shape, size_t values_shape_len, const void *values, const int64_t *indices_shape_data, size_t indices_shape_len, const int32_t *indices_data) |
| OrtStatus * | CreateSparseTensorWithValuesAsOrtValue (const OrtMemoryInfo *info, void *p_data, const int64_t *dense_shape, size_t dense_shape_len, const int64_t *values_shape, size_t values_shape_len, ONNXTensorElementDataType type, OrtValue **out) |
| OrtStatus * | UseCooIndices (OrtValue *ort_value, int64_t *indices_data, size_t indices_num) |
| OrtStatus * | UseCsrIndices (OrtValue *ort_value, int64_t *inner_data, size_t inner_num, int64_t *outer_data, size_t outer_num) |
| OrtStatus * | UseBlockSparseIndices (OrtValue *ort_value, const int64_t *indices_shape, size_t indices_shape_len, int32_t *indices_data) |
| OrtStatus * | GetSparseTensorFormat (const OrtValue *ort_value, enum OrtSparseFormat *out) |
| Returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor. | |
| OrtStatus * | GetSparseTensorValuesTypeAndShape (const OrtValue *ort_value, OrtTensorTypeAndShapeInfo **out) |
| Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor. | |
| OrtStatus * | GetSparseTensorValues (const OrtValue *ort_value, const void **out) |
| Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*(). | |
| OrtStatus * | GetSparseTensorIndicesTypeShape (const OrtValue *ort_value, enum OrtSparseIndicesFormat indices_format, OrtTensorTypeAndShapeInfo **out) |
| Returns data type, shape for the type of indices specified by indices_format. | |
| OrtStatus * | GetSparseTensorIndices (const OrtValue *ort_value, enum OrtSparseIndicesFormat indices_format, size_t *num_indices, const void **indices) |
| Returns indices data for the type of the indices specified by indices_format. | |
OrtTypeInfo | |
| OrtStatus * | CastTypeInfoToTensorInfo (const OrtTypeInfo *type_info, const OrtTensorTypeAndShapeInfo **out) |
| Get OrtTensorTypeAndShapeInfo from an OrtTypeInfo. | |
| OrtStatus * | GetOnnxTypeFromTypeInfo (const OrtTypeInfo *type_info, enum ONNXType *out) |
| Get ONNXType from OrtTypeInfo. | |
| void | ReleaseTypeInfo (OrtTypeInfo *input) |
| OrtStatus * | GetDenotationFromTypeInfo (const OrtTypeInfo *type_info, const char **const denotation, size_t *len) |
| Get denotation from type information. | |
| OrtStatus * | CastTypeInfoToMapTypeInfo (const OrtTypeInfo *type_info, const OrtMapTypeInfo **out) |
| Get detailed map information from an OrtTypeInfo. | |
| OrtStatus * | CastTypeInfoToSequenceTypeInfo (const OrtTypeInfo *type_info, const OrtSequenceTypeInfo **out) |
| Cast OrtTypeInfo to an OrtSequenceTypeInfo. | |
OrtMemoryInfo | |
| OrtStatus * | CreateMemoryInfo (const char *name, enum OrtAllocatorType type, int id, enum OrtMemType mem_type, OrtMemoryInfo **out) |
| Create an OrtMemoryInfo. | |
| OrtStatus * | CreateCpuMemoryInfo (enum OrtAllocatorType type, enum OrtMemType mem_type, OrtMemoryInfo **out) |
| Create an OrtMemoryInfo for CPU memory. | |
| OrtStatus * | CompareMemoryInfo (const OrtMemoryInfo *info1, const OrtMemoryInfo *info2, int *out) |
| Compare OrtMemoryInfo objects for equality. | |
| OrtStatus * | MemoryInfoGetName (const OrtMemoryInfo *ptr, const char **out) |
| Get name from OrtMemoryInfo. | |
| OrtStatus * | MemoryInfoGetId (const OrtMemoryInfo *ptr, int *out) |
| Get the device id from OrtMemoryInfo. | |
| OrtStatus * | MemoryInfoGetMemType (const OrtMemoryInfo *ptr, OrtMemType *out) |
| Get the OrtMemType from OrtMemoryInfo. | |
| OrtStatus * | MemoryInfoGetType (const OrtMemoryInfo *ptr, OrtAllocatorType *out) |
| Get the OrtAllocatorType from OrtMemoryInfo. | |
| void | ReleaseMemoryInfo (OrtMemoryInfo *input) |
OrtAllocator | |
| OrtStatus * | AllocatorAlloc (OrtAllocator *ort_allocator, size_t size, void **out) |
| Calls OrtAllocator::Alloc function. | |
| OrtStatus * | AllocatorFree (OrtAllocator *ort_allocator, void *p) |
| Calls OrtAllocator::Free function. | |
| OrtStatus * | AllocatorGetInfo (const OrtAllocator *ort_allocator, const struct OrtMemoryInfo **out) |
| Calls OrtAllocator::Info function. | |
| OrtStatus * | GetAllocatorWithDefaultOptions (OrtAllocator **out) |
| Get the default allocator. | |
| OrtStatus * | CreateAllocator (const OrtSession *session, const OrtMemoryInfo *mem_info, OrtAllocator **out) |
| Create an allocator for an OrtSession following an OrtMemoryInfo. | |
| void | ReleaseAllocator (OrtAllocator *input) |
| Release an OrtAllocator obtained from OrtApi::CreateAllocator. | |
| OrtStatus * | RegisterAllocator (OrtEnv *env, OrtAllocator *allocator) |
| Register a custom allocator. | |
| OrtStatus * | UnregisterAllocator (OrtEnv *env, const OrtMemoryInfo *mem_info) |
| Unregister a custom allocator. | |
OrtKernelInfo | |
Custom operator APIs. | |
| OrtStatus * | KernelInfoGetAttribute_float (const OrtKernelInfo *info, const char *name, float *out) |
| Get a float stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfoGetAttribute_int64 (const OrtKernelInfo *info, const char *name, int64_t *out) |
| Fetch a 64-bit int stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfoGetAttribute_string (const OrtKernelInfo *info, const char *name, char *out, size_t *size) |
| Fetch a string stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfoGetAttributeArray_float (const OrtKernelInfo *info, const char *name, float *out, size_t *size) |
| Fetch an array of int64_t values stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfoGetAttributeArray_int64 (const OrtKernelInfo *info, const char *name, int64_t *out, size_t *size) |
| Fetch an array of int64_t values stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfo_GetInputCount (const OrtKernelInfo *info, size_t *out) |
| Get the number of inputs from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetOutputCount (const OrtKernelInfo *info, size_t *out) |
| Get the number of outputs from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetInputName (const OrtKernelInfo *info, size_t index, char *out, size_t *size) |
| Get the name of a OrtKernelInfo's input. | |
| OrtStatus * | KernelInfo_GetOutputName (const OrtKernelInfo *info, size_t index, char *out, size_t *size) |
| Get the name of a OrtKernelInfo's output. | |
| OrtStatus * | KernelInfo_GetInputTypeInfo (const OrtKernelInfo *info, size_t index, OrtTypeInfo **type_info) |
| Get the type information for a OrtKernelInfo's input. | |
| OrtStatus * | KernelInfo_GetOutputTypeInfo (const OrtKernelInfo *info, size_t index, OrtTypeInfo **type_info) |
| Get the type information for a OrtKernelInfo's output. | |
| OrtStatus * | KernelInfoGetAttribute_tensor (const OrtKernelInfo *info, const char *name, OrtAllocator *allocator, OrtValue **out) |
| Get a OrtValue tensor stored as an attribute in the graph node. | |
| OrtStatus * | KernelInfo_GetNodeName (const OrtKernelInfo *info, char *out, size_t *size) |
| Get the graph node name from OrtKernelInfo. | |
| OrtStatus * | KernelInfo_GetLogger (const OrtKernelInfo *info, const OrtLogger **logger) |
| Get the session logger from OrtKernelInfo. | |
OrtKernelContext | |
Custom operator APIs. | |
| OrtStatus * | KernelContext_GetInputCount (const OrtKernelContext *context, size_t *out) |
| Used for custom operators, get the input count of a kernel. | |
| OrtStatus * | KernelContext_GetOutputCount (const OrtKernelContext *context, size_t *out) |
| Used for custom operators, get the output count of a kernel. | |
| OrtStatus * | KernelContext_GetInput (const OrtKernelContext *context, size_t index, const OrtValue **out) |
| Used for custom operators, get an input of a kernel. | |
| OrtStatus * | KernelContext_GetOutput (OrtKernelContext *context, size_t index, const int64_t *dim_values, size_t dim_count, OrtValue **out) |
| Used for custom operators, get an output of a kernel. | |
| OrtStatus * | KernelContext_GetGPUComputeStream (const OrtKernelContext *context, void **out) |
| Used for custom operators, gets the GPU compute stream to use to launch the custom a GPU kernel. | |
| OrtStatus * | KernelContext_GetLogger (const OrtKernelContext *context, const OrtLogger **logger) |
| Get the runtime logger from OrtKernelContext. | |
OrtMapTypeInfo | |
| OrtStatus * | GetMapKeyType (const OrtMapTypeInfo *map_type_info, enum ONNXTensorElementDataType *out) |
| Get key type from an OrtMapTypeInfo. | |
| OrtStatus * | GetMapValueType (const OrtMapTypeInfo *map_type_info, OrtTypeInfo **type_info) |
| Get the value type from an OrtMapTypeInfo. | |
| void | ReleaseMapTypeInfo (OrtMapTypeInfo *input) |
OrtSequenceTypeInfo | |
| OrtStatus * | GetSequenceElementType (const OrtSequenceTypeInfo *sequence_type_info, OrtTypeInfo **type_info) |
| Get element type from an OrtSequenceTypeInfo. | |
| void | ReleaseSequenceTypeInfo (OrtSequenceTypeInfo *input) |
OrtModelMetadata | |
| OrtStatus * | ModelMetadataGetProducerName (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get producer name from an OrtModelMetadata. | |
| OrtStatus * | ModelMetadataGetGraphName (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get graph name from an OrtModelMetadata. | |
| OrtStatus * | ModelMetadataGetDomain (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get domain from an OrtModelMetadata. | |
| OrtStatus * | ModelMetadataGetDescription (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get description from an OrtModelMetadata. | |
| OrtStatus * | ModelMetadataLookupCustomMetadataMap (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, const char *key, char **value) |
| Return data for a key in the custom metadata map in an OrtModelMetadata. | |
| OrtStatus * | ModelMetadataGetVersion (const OrtModelMetadata *model_metadata, int64_t *value) |
| Get version number from an OrtModelMetadata. | |
| void | ReleaseModelMetadata (OrtModelMetadata *input) |
| OrtStatus * | ModelMetadataGetCustomMetadataMapKeys (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char ***keys, int64_t *num_keys) |
| OrtStatus * | ModelMetadataGetGraphDescription (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
OrtThreadingOptions | |
| OrtStatus * | CreateThreadingOptions (OrtThreadingOptions **out) |
| Create an OrtThreadingOptions. | |
| void | ReleaseThreadingOptions (OrtThreadingOptions *input) |
| OrtStatus * | SetGlobalIntraOpNumThreads (OrtThreadingOptions *tp_options, int intra_op_num_threads) |
| Set global intra-op thread count. | |
| OrtStatus * | SetGlobalInterOpNumThreads (OrtThreadingOptions *tp_options, int inter_op_num_threads) |
| Set global inter-op thread count. | |
| OrtStatus * | SetGlobalSpinControl (OrtThreadingOptions *tp_options, int allow_spinning) |
| Set global spin control options. | |
| OrtStatus * | SetGlobalDenormalAsZero (OrtThreadingOptions *tp_options) |
| Set threading flush-to-zero and denormal-as-zero. | |
| OrtStatus * | SetGlobalCustomCreateThreadFn (OrtThreadingOptions *tp_options, OrtCustomCreateThreadFn ort_custom_create_thread_fn) |
| Set custom thread creation function for global thread pools. | |
| OrtStatus * | SetGlobalCustomThreadCreationOptions (OrtThreadingOptions *tp_options, void *ort_custom_thread_creation_options) |
| Set custom thread creation options for global thread pools. | |
| OrtStatus * | SetGlobalCustomJoinThreadFn (OrtThreadingOptions *tp_options, OrtCustomJoinThreadFn ort_custom_join_thread_fn) |
| Set custom thread join function for global thread pools. | |
Misc | |
| OrtStatus * | GetAvailableProviders (char ***out_ptr, int *provider_length) |
| Get the names of all available providers. | |
| OrtStatus * | ReleaseAvailableProviders (char **ptr, int providers_length) |
| Release data from OrtApi::GetAvailableProviders. This API will never fail so you can rely on it in a noexcept code. | |
| OrtStatus * | SetCurrentGpuDeviceId (int device_id) |
| Set current GPU device ID. | |
| OrtStatus * | GetCurrentGpuDeviceId (int *device_id) |
| Get current GPU device ID. | |
OrtArenaCfg | |
| OrtStatus * | CreateArenaCfg (size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk, OrtArenaCfg **out) |
| void | ReleaseArenaCfg (OrtArenaCfg *input) |
| OrtStatus * | CreateArenaCfgV2 (const char *const *arena_config_keys, const size_t *arena_config_values, size_t num_keys, OrtArenaCfg **out) |
| Create an OrtArenaCfg. | |
OrtPrepackedWeightsContainer | |
| OrtStatus * | CreatePrepackedWeightsContainer (OrtPrepackedWeightsContainer **out) |
| Create an OrtPrepackedWeightsContainer. | |
| void | ReleasePrepackedWeightsContainer (OrtPrepackedWeightsContainer *input) |
| Release OrtPrepackedWeightsContainer instance. | |
GetExecutionProviderApi | |
| OrtStatus * | GetExecutionProviderApi (const char *provider_name, uint32_t version, const void **provider_api) |
| Get a pointer to the requested version of the Execution Provider specific API extensions to the OrtApi. | |
SessionOptions | |
| OrtStatus * | SessionOptionsSetCustomCreateThreadFn (OrtSessionOptions *options, OrtCustomCreateThreadFn ort_custom_create_thread_fn) |
| Set custom thread creation function. | |
| OrtStatus * | SessionOptionsSetCustomThreadCreationOptions (OrtSessionOptions *options, void *ort_custom_thread_creation_options) |
| Set creation options for custom thread. | |
| OrtStatus * | SessionOptionsSetCustomJoinThreadFn (OrtSessionOptions *options, OrtCustomJoinThreadFn ort_custom_join_thread_fn) |
| Set custom thread join function. | |
OrtLogger | |
Custom operator APIs. | |
| OrtStatus * | Logger_LogMessage (const OrtLogger *logger, OrtLoggingLevel log_severity_level, const char *message, const char *file_path, int line_number, const char *func_name) |
| Logs a message at the given severity level using the provided OrtLogger. | |
| OrtStatus * | Logger_GetLoggingSeverityLevel (const OrtLogger *logger, OrtLoggingLevel *out) |
| Get the logging severity level of the OrtLogger. | |
OrtValueInfo | |
| OrtStatus * | ValueInfo_GetValueProducer (const OrtValueInfo *value_info, const OrtNode **producer_node, size_t *producer_output_index) |
| Get the OrtNode that produces the value represented by the given OrtValueInfo. Optionally returns the associated output index. | |
| OrtStatus * | ValueInfo_GetValueNumConsumers (const OrtValueInfo *value_info, size_t *num_consumers) |
| Get the number of consumers of a value as a node input. | |
| OrtStatus * | ValueInfo_GetValueConsumers (const OrtValueInfo *value_info, const OrtNode **nodes, int64_t *input_indices, size_t num_consumers) |
| Returns information (OrtNode and input index) for all consumer nodes that use the value as an input. | |
| OrtStatus * | ValueInfo_GetInitializerValue (const OrtValueInfo *value_info, const OrtValue **initializer_value) |
| Get the underlying initializer value, as an OrtValue, from the given OrtValueInfo. | |
| OrtStatus * | ValueInfo_GetExternalInitializerInfo (const OrtValueInfo *value_info, OrtExternalInitializerInfo **info) |
| Get information about an external initializer (e.g., filepath, file offset, byte size). | |
| OrtStatus * | ValueInfo_IsRequiredGraphInput (const OrtValueInfo *value_info, bool *is_required_graph_input) |
| Returns a boolean indicating if the given value is a required graph input. | |
| OrtStatus * | ValueInfo_IsOptionalGraphInput (const OrtValueInfo *value_info, bool *is_optional_graph_input) |
| Returns a boolean indicating if the given value is an optional graph input. | |
| OrtStatus * | ValueInfo_IsGraphOutput (const OrtValueInfo *value_info, bool *is_graph_output) |
| Returns a boolean indicating if the given value is a graph output. | |
| OrtStatus * | ValueInfo_IsConstantInitializer (const OrtValueInfo *value_info, bool *is_constant_initializer) |
| Returns a boolean indicating if the given value is a constant initializer. | |
| OrtStatus * | ValueInfo_IsFromOuterScope (const OrtValueInfo *value_info, bool *is_from_outer_scope) |
| Returns a boolean indicating if the given value is defined in an outer scope. | |
OrtGraph | |
| OrtStatus * | Graph_GetName (const OrtGraph *graph, const char **graph_name) |
| Returns a graph's name. | |
| OrtStatus * | Graph_GetModelPath (const OrtGraph *graph, const char **model_path) |
| Get the filepath to the model from which an OrtGraph is constructed. | |
| OrtStatus * | Graph_GetOnnxIRVersion (const OrtGraph *graph, int64_t *onnx_ir_version) |
| Returns the ONNX IR version. | |
| OrtStatus * | Graph_GetNumOperatorSets (const OrtGraph *graph, size_t *num_operator_sets) |
| Returns the number of operator sets that the graph's model uses. | |
| OrtStatus * | Graph_GetOperatorSets (const OrtGraph *graph, const char **domains, int64_t *opset_versions, size_t num_operator_sets) |
| Returns the operator sets that the graph's model uses. | |
| OrtStatus * | Graph_GetNumInputs (const OrtGraph *graph, size_t *num_inputs) |
| Returns the number of graph inputs. | |
| OrtStatus * | Graph_GetInputs (const OrtGraph *graph, const OrtValueInfo **inputs, size_t num_inputs) |
| Returns the graph's inputs as OrtValueInfo instances. | |
| OrtStatus * | Graph_GetNumOutputs (const OrtGraph *graph, size_t *num_outputs) |
| Returns the number of graph outputs. | |
| OrtStatus * | Graph_GetOutputs (const OrtGraph *graph, const OrtValueInfo **outputs, size_t num_outputs) |
| Returns the graph's outputs as OrtValueInfo instances. | |
| OrtStatus * | Graph_GetNumInitializers (const OrtGraph *graph, size_t *num_initializers) |
| Returns the number of graph initializers. | |
| OrtStatus * | Graph_GetInitializers (const OrtGraph *graph, const OrtValueInfo **initializers, size_t num_initializers) |
| Returns the graph's initializers as OrtValueInfo instances. | |
| OrtStatus * | Graph_GetNumNodes (const OrtGraph *graph, size_t *num_nodes) |
| Returns the number of graph nodes. | |
| OrtStatus * | Graph_GetNodes (const OrtGraph *graph, const OrtNode **nodes, size_t num_nodes) |
| Returns the graph's nodes as OrtNode instances. | |
| OrtStatus * | Graph_GetParentNode (const OrtGraph *graph, const OrtNode **node) |
| Get the parent node for the given graph, if any exists. | |
| OrtStatus * | Graph_GetGraphView (const OrtGraph *src_graph, const OrtNode **nodes, size_t num_nodes, OrtGraph **dst_graph) |
| Returns an OrtGraph that contains a subset of nodes in the source OrtGraph. | |
OrtNode | |
| OrtStatus * | Node_GetId (const OrtNode *node, size_t *node_id) |
| Returns a node's identifier. | |
| OrtStatus * | Node_GetName (const OrtNode *node, const char **node_name) |
| Returns a node's name. Can be an empty string. | |
| OrtStatus * | Node_GetOperatorType (const OrtNode *node, const char **operator_type) |
| Returns a node's operator type (e.g., "Conv"). | |
| OrtStatus * | Node_GetDomain (const OrtNode *node, const char **domain_name) |
| Returns a node's domain name. | |
| OrtStatus * | Node_GetSinceVersion (const OrtNode *node, int *since_version) |
| Get the opset version in which the given node's operator type was first defined. | |
| OrtStatus * | Node_GetNumInputs (const OrtNode *node, size_t *num_inputs) |
| Returns the number of node inputs. | |
| OrtStatus * | Node_GetInputs (const OrtNode *node, const OrtValueInfo **inputs, size_t num_inputs) |
| Returns the node's inputs as OrtValueInfo instances. | |
| OrtStatus * | Node_GetNumOutputs (const OrtNode *node, size_t *num_outputs) |
| Returns the number of node outputs. | |
| OrtStatus * | Node_GetOutputs (const OrtNode *node, const OrtValueInfo **outputs, size_t num_outputs) |
| Returns the node's outputs as OrtValueInfo instances. | |
| OrtStatus * | Node_GetNumImplicitInputs (const OrtNode *node, size_t *num_implicit_inputs) |
| Returns the number of node implicit inputs. | |
| OrtStatus * | Node_GetImplicitInputs (const OrtNode *node, const OrtValueInfo **implicit_inputs, size_t num_implicit_inputs) |
| Get the implicit inputs, as OrtValueInfo instances, that are used within the given node's subgraphs. | |
| OrtStatus * | Node_GetNumAttributes (const OrtNode *node, size_t *num_attributes) |
| Returns the number of node attributes. | |
| OrtStatus * | Node_GetAttributes (const OrtNode *node, const OrtOpAttr **attributes, size_t num_attributes) |
| Returns a node's attributes as OrtOpAttr instances. | |
| OrtStatus * | Node_GetAttributeByName (const OrtNode *node, const char *attribute_name, const OrtOpAttr **attribute) |
| Gets the OrtNode's attribute as OrtOpAttr by name. | |
| OrtStatus * | OpAttr_GetTensorAttributeAsOrtValue (const OrtOpAttr *attribute, OrtValue **attr_tensor) |
| Get the OrtNode's 'TENSOR' attribute as an OrtValue. | |
| OrtStatus * | OpAttr_GetType (const OrtOpAttr *attribute, OrtOpAttrType *type) |
| Get the attribute type as OrtOpAttrType from an OrtOpAttr. | |
| OrtStatus * | OpAttr_GetName (const OrtOpAttr *attribute, const char **name) |
| Get the attribute name from an OrtOpAttr. | |
| OrtStatus * | Node_GetNumSubgraphs (const OrtNode *node, size_t *num_subgraphs) |
| Returns the number of subgraphs contained by the given node. | |
| OrtStatus * | Node_GetSubgraphs (const OrtNode *node, const OrtGraph **subgraphs, size_t num_subgraphs, const char **attribute_names) |
| Get the subgraphs, as OrtGraph instances, contained by the given node. | |
| OrtStatus * | Node_GetGraph (const OrtNode *node, const OrtGraph **graph) |
| Get the node's parent OrtGraph instance. | |
| OrtStatus * | Node_GetEpName (const OrtNode *node, const char **out) |
| Returns the execution provider name that this node is assigned to run on. Returns NULL if the node has not been assigned to any execution provider yet. For plugin execution providers, the name is the one returned by OrtEp::GetName. | |
OrtDeviceEpIncompatibilityDetails | |
Accessor functions for device incompatibility details | |
| OrtStatus * | DeviceEpIncompatibilityDetails_GetReasonsBitmask (const OrtDeviceEpIncompatibilityDetails *details, uint32_t *reasons_bitmask) |
| Get the incompatibility reasons bitmask from OrtDeviceEpIncompatibilityDetails. | |
| OrtStatus * | DeviceEpIncompatibilityDetails_GetNotes (const OrtDeviceEpIncompatibilityDetails *details, const char **notes) |
| Get the notes from OrtDeviceEpIncompatibilityDetails. | |
| OrtStatus * | DeviceEpIncompatibilityDetails_GetErrorCode (const OrtDeviceEpIncompatibilityDetails *details, int32_t *error_code) |
| Get the execution provider error code from OrtDeviceEpIncompatibilityDetails. | |
| void | ReleaseDeviceEpIncompatibilityDetails (OrtDeviceEpIncompatibilityDetails *input) |
| Release an OrtDeviceEpIncompatibilityDetails instance. | |
Model Compatibility APIs | |
| OrtStatus * | GetCompatibilityInfoFromModel (const char *model_path, const char *ep_type, OrtAllocator *allocator, char **compatibility_info) |
| Extract EP compatibility info from a precompiled model file. | |
| OrtStatus * | GetCompatibilityInfoFromModelBytes (const void *model_data, size_t model_data_length, const char *ep_type, OrtAllocator *allocator, char **compatibility_info) |
| Extract EP compatibility info from precompiled model bytes in memory. | |
The C API.
All C API functions are defined inside this structure as pointers to functions. Call OrtApiBase::GetApi to get a pointer to it
◆ AddCustomOpDomain()
Add custom op domain to a session options.
- Note
- The OrtCustomOpDomain* must not be deleted until all sessions using it are released
- Parameters
-
[in] options [in] custom_op_domain
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ AddExternalInitializers()
| OrtStatus * OrtApi::AddExternalInitializers | ( | OrtSessionOptions * | options, |
| const char *const * | initializer_names, | ||
| const OrtValue *const * | initializers, | ||
| size_t | num_initializers | ||
| ) |
Replace initialized Tensors with external data with the data provided in initializers.
The function will find the initialized TensorProtos with external data in the graph with the provided names and replace them with the provided tensors. The API verifies that the TensorProto being replaced has an external data reference and has the same name, dimensions and data type as its replacement. The replacement will occur before any of the optimizations take place. The data will be copied into the graph since TensorProto can't refer to the user provided buffers.
Once the model has been loaded, the OrtValue(s) added to SessionOptions instance will be removed from the internal SessionOptions copy to save memory, the user provided buffers can then be deallocated and the SessionOptions instance that refers to them can be destroyed.
- Parameters
-
[in] options [in] initializer_names Array of null terminated UTF-8 encoded strings of the initializers names. [in] initializers Array of OrtValue type [in] num_initializers Number of elements in the initializer_names and initializers
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.12.
◆ AddExternalInitializersFromFilesInMemory()
| OrtStatus * OrtApi::AddExternalInitializersFromFilesInMemory | ( | OrtSessionOptions * | options, |
| const char *const * | external_initializer_file_names, | ||
| char *const * | external_initializer_file_buffer_array, | ||
| const size_t * | external_initializer_file_lengths, | ||
| size_t | num_external_initializer_files | ||
| ) |
Replace initialized Tensors with external data with the provided files in memory.
The function will find the initialized TensorProtos with external data in the graph with the provided external file names and the file content in memory. The API gets the external file name, offset, data length from TensorProto, and locate the tensor data from the file in memory buffer. It creates a Tensor to replace the existing Tensor in graph. The replacement will occur before any of the optimizations take place. The data will be copied into the graph since TensorProto can't refer to the user provided buffers.
- Parameters
-
[in] options [in] external_initializer_file_names Array of null terminated UTF-8 encoded strings of the file names which holds the external initializers. [in] external_initializer_file_buffer_array Array of pointers to the buffer of the file content. The buffer can be freed after session creation. [in] external_initializer_file_lengths Array of size_t to indicate the length of file content [in] num_external_initializer_files Number of external files
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.18.
◆ AddFreeDimensionOverride()
Override session symbolic dimensions.
Override symbolic dimensions (by specific denotation strings) with actual values if known at session initialization time to enable optimizations that can take advantage of fixed values (such as memory planning, etc)
- Parameters
-
[in] options [in] dim_denotation [in] dim_value
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ AddFreeDimensionOverrideByName()
Override symbolic dimensions (by specific name strings) with actual values if known at session initialization time to enable optimizations that can take advantage of fixed values (such as memory planning, etc)
◆ AddInitializer()
Add a pre-allocated initializer to a session.
If a model contains an initializer with a name that is same as the name passed to this call, ORT will use this initializer instance instead of deserializing one from the model file. This is useful when you want to share the same initializer across sessions.
- Parameters
-
[in] options [in] name Null terminated string of the initializer name [in] val OrtValue containing the initializer. Its lifetime and the underlying initializer buffer must be managed by the user (created using the OrtApi::CreateTensorWithDataAsOrtValue) and it must outlive the session object to which it is added.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ AddRunConfigEntry()
| OrtStatus * OrtApi::AddRunConfigEntry | ( | OrtRunOptions * | options, |
| const char * | config_key, | ||
| const char * | config_value | ||
| ) |
Set a single run configuration entry as a pair of strings.
If a configuration with same key exists, this will overwrite the configuration with the given config_value
The config_key and the format of config_value are defined in onnxruntime_run_options_config_keys.h
- Parameters
-
[in] options [in] config_key A null terminated string representation of the config key [in] config_value A null terminated string representation of the config value
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ AddSessionConfigEntry()
Set a session configuration entry as a pair of strings.
If a configuration with same key exists, this will overwrite the configuration with the given config_value.
The config_key and the format of config_value are defined in onnxruntime_session_options_config_keys.h
- Parameters
-
[in] options [in] config_key A null terminated string representation of the config key [in] config_value A null terminated string representation of the config value
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ AllocatorAlloc()
◆ AllocatorFree()
◆ AllocatorGetInfo()
◆ AllocatorGetStats()
Calls OrtAllocator::GetStats function.
Return a pointer to the OrtKeyValuePairs structure that contains the statistics of the allocator and the user should call OrtApi::ReleaseKeyValuePairs.
NOTE: If the allocator does not implement this function, the OrtKeyValuePairs instance will be empty.
- Parameters
-
[in] ort_allocator The allocator to get stats from [out] out A pointer to the OrtKeyValuePairs instance that contains the stats
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ BindInput()
◆ BindOutput()
Bind an OrtValue to an OrtIoBinding output.
When using OrtApi::RunWithBinding this value is used for the named output
- Parameters
-
[in] binding_ptr [in] name Null terminated string of the model output name [in] val_ptr OrtValue of Tensor type.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ BindOutputToDevice()
Bind an OrtIoBinding output to a device.
Binds the OrtValue to a device which is specified by OrtMemoryInfo. You can either create an instance of OrtMemoryInfo with a device id or obtain one from the allocator that you have created/are using This is useful when one or more outputs have dynamic shapes and, it is hard to pre-allocate and bind a chunk of memory within OrtValue ahead of time.
- See also
- OrtApi::RunWithBinding
- Parameters
-
[in] binding_ptr [in] name Null terminated string of the device name [in] mem_info_ptr
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CastTypeInfoToMapTypeInfo()
Get detailed map information from an OrtTypeInfo.
This augments OrtTypeInfo to return an OrtMapTypeInfo when the type is a map. The OrtMapTypeInfo has additional information about the map's key type and value type.
This is used by WinML to support model reflection APIs.
- Parameters
-
[out] type_info [out] out A pointer to the OrtMapTypeInfo. Do not free this value. If type_info does not contain a map, this value will be set to nullptr.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CastTypeInfoToOptionalTypeInfo()
Get Optional Type information from an OrtTypeInfo.
This augments OrtTypeInfo to return an OrtOptionalTypeInfo when the type is optional. The OrtOptionalTypeInfo also has a nested OrtTypeInfo that describes the type of the optional value. OrtOptionalTypeInfo type can only appear within model metadata to describe inputs/outputs. The actual OrtValues that are supplied in place of optional type inputs should contain specific type that is described by OrtOptionalTypeInfo.
So the picture: OrtTypeInfo -> OrtOptionalTypeInfo -> OrtTypeInfo (describes the type that can be supplied in place of the optional type when creating the actual OrtValue).
- Parameters
-
[in] type_info [out] out A pointer to the OrtOptionalTypeInfo. Do not free this value, it is owned by OrtTypeInfo instance. When the type_info does not represent optional type, nullptr is returned in out.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ CastTypeInfoToSequenceTypeInfo()
Cast OrtTypeInfo to an OrtSequenceTypeInfo.
This api augments OrtTypeInfo to return an OrtSequenceTypeInfo when the type is a sequence. The OrtSequenceTypeInfo has additional information about the sequence's element type.
This is used by WinML to support model reflection APIs.
- Parameters
-
[in] type_info [out] out A pointer to the OrtSequenceTypeInfo. Do not free this value. If type_info doesn not contain a sequence, this value will be set to nullptr.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CastTypeInfoToTensorInfo()
Get OrtTensorTypeAndShapeInfo from an OrtTypeInfo.
- Parameters
-
[in] type_info [out] out Do not free this value, it will be valid until type_info is freed. If type_info does not represent tensor, this value will be set to nullptr.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CloneSessionOptions()
Create a copy of an existing OrtSessionOptions.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CompareMemoryInfo()
Compare OrtMemoryInfo objects for equality.
Compares all settings of each OrtMemoryInfo for equality
- Parameters
-
[in] info1 [in] info2 [out] out Set to 0 if equal, -1 if not equal
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CopyKernelInfo()
◆ CopyTensors()
Copy OrtValue instances containing Tensors between devices.
The overall copy must be between a single source device and a single destination device. i.e.
- all src_tensors must have matching OrtMemoryInfo,
- all dst_tensors must have matching OrtMemoryInfo.
OrtValue instances can be created by:
- Use GetSharedAllocator to get the shared allocator for the OrtMemoryInfo if you need to allocate memory on the device.
- Use CreateTensorAsOrtValue, CreateTensorWithDataAsOrtValue or CreateTensorWithDataAndDeleterAsOrtValue to create an OrtValue containing a tensor depending on whether you have existing data or not, and whether you want ORT to free the existing data once it is done with the OrtValue.
- Parameters
-
[in] env The OrtEnv instance to use. The data transfer implementation is provided by an execution provider that is registered in this OrtEnv. [in] src_tensors Array of OrtValue instances containing the source tensors to copy. [in] dst_tensors Array of OrtValue instances to copy the source tensors to. [in] stream Optional OrtSyncStream that can be used to perform the copy asynchronously. May be nullptr. [in] num_tensors The number of tensors to copy. The size of src_tensorsanddst_tensorsmust match.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ CreateAllocator()
Create an allocator for an OrtSession following an OrtMemoryInfo.
The allocator wraps the internal allocator from the OrtSession and becomes invalid when the session does.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateAndRegisterAllocator()
Create an allocator and register it with the OrtEnv.
Enables sharing the allocator between multiple sessions that use the same env instance. Lifetime of the created allocator will be valid for the duration of the environment. Returns an error if an allocator with the same OrtMemoryInfo is already registered.
See https://onnxruntime.ai/docs/get-started/with-c.html for details.
- Parameters
-
[in] env OrtEnv instance [in] mem_info [in] arena_cfg Pass nullptr for defaults
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateAndRegisterAllocatorV2()
| OrtStatus * OrtApi::CreateAndRegisterAllocatorV2 | ( | OrtEnv * | env, |
| const char * | provider_type, | ||
| const OrtMemoryInfo * | mem_info, | ||
| const OrtArenaCfg * | arena_cfg, | ||
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Create an allocator with specific type and register it with the OrtEnv This API enhance CreateAndRegisterAllocator that it can create an allocator with specific type, not just CPU allocator Enables sharing the allocator between multiple sessions that use the same env instance. Lifetime of the created allocator will be valid for the duration of the environment. Returns an error if an allocator with the same OrtMemoryInfo is already registered.
- Parameters
-
[in] env OrtEnv instance [in] provider_type ExecutionProvider type [in] mem_info OrtMemoryInfo instance [in] arena_cfg Arena configuration [in] provider_options_keys key of the provider options map [in] provider_options_values value of the provider options map [in] num_keys Length of the provider options map
◆ CreateArenaCfg()
| OrtStatus * OrtApi::CreateArenaCfg | ( | size_t | max_mem, |
| int | arena_extend_strategy, | ||
| int | initial_chunk_size_bytes, | ||
| int | max_dead_bytes_per_chunk, | ||
| OrtArenaCfg ** | out | ||
| ) |
This will create the configuration of an arena that can eventually be used to define an arena based allocator's behavior
- Parameters
-
[in] max_mem Use 0 to allow ORT to choose the default [in] arena_extend_strategy Use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested [in] initial_chunk_size_bytes Use -1 to allow ORT to choose the default [in] max_dead_bytes_per_chunk Use -1 to allow ORT to choose the default [in] out A pointer to an OrtArenaCfg instance
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateArenaCfgV2()
| OrtStatus * OrtApi::CreateArenaCfgV2 | ( | const char *const * | arena_config_keys, |
| const size_t * | arena_config_values, | ||
| size_t | num_keys, | ||
| OrtArenaCfg ** | out | ||
| ) |
Create an OrtArenaCfg.
Create the configuration of an arena that can eventually be used to define an arena based allocator's behavior.
Supported keys are (See https://onnxruntime.ai/docs/get-started/with-c.html for details on what the following parameters mean and how to choose these values.): "max_mem": Maximum memory that can be allocated by the arena based allocator. Use 0 for ORT to pick the best value. Default is 0. "arena_extend_strategy": 0 = kNextPowerOfTwo, 1 = kSameAsRequested. Use -1 to allow ORT to choose the default. "initial_chunk_size_bytes": (Possible) Size of the first allocation in the arena. Only relevant if arena strategy is kNextPowerOfTwo. Use -1 to allow ORT to choose the default. Ultimately, the first allocation size is determined by the allocation memory request. "max_dead_bytes_per_chunk": Threshold of unused memory in an allocated chunk of arena memory after crossing which the current chunk is chunked into 2. "initial_growth_chunk_size_bytes": (Possible) Size of the second allocation in the arena. Only relevant if arena strategy is kNextPowerOfTwo. Use -1 to allow ORT to choose the default. "max_power_of_two_extend_bytes": The maximum extend size if arena strategy is kNextPowerOfTwo. It is not an allocation limit, it is only a limit for extension when requested byte is less than the limit. When requested bytes is more than the limit, allocator will still return as requested. Use -1 to allow ORT to choose the default 1GB for max_power_of_two_extend_bytes. Ultimately, the allocation size is determined by the allocation memory request. Further allocation sizes are governed by the arena extend strategy.
- Parameters
-
[in] arena_config_keys Keys to configure the arena [in] arena_config_values Values to configure the arena [in] num_keys Number of keys in arena_config_keysandarena_config_values[out] out Newly created OrtArenaCfg. Must be freed with OrtApi::ReleaseArenaCfg
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateCANNProviderOptions()
Create an OrtCANNProviderOptions.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.13.
◆ CreateCpuMemoryInfo()
◆ CreateCUDAProviderOptions()
Create an OrtCUDAProviderOptionsV2.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.11.
◆ CreateCustomOpDomain()
Create a custom op domain.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateDnnlProviderOptions()
Create an OrtDnnlProviderOptions.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ CreateEnv()
Create an OrtEnv.
- Note
- Invoking this function will return the same instance of the environment as that returned by a previous call to another env creation function; all arguments to this function will be ignored.
- Parameters
-
[in] log_severity_level The log severity level. [in] logid The log identifier. [out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateEnvWithCustomLogger()
Create an OrtEnv.
- Note
- Invoking this function will return the same instance of the environment as that returned by a previous call to another env creation function; all arguments to this function will be ignored. If you want to provide your own logging function, consider setting it using the SetUserLoggingFunction API instead.
- Parameters
-
[in] logging_function A pointer to a logging function. [in] logger_param A pointer to arbitrary data passed as the OrtLoggingFunction paramparameter tologging_function. This parameter is optional.[in] log_severity_level The log severity level. [in] logid The log identifier. [out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateEnvWithCustomLoggerAndGlobalThreadPools()
Create a custom environment with global threadpools and logger that will be shared across sessions. Use this in conjunction with OrtApi::DisablePerSessionThreads or else the session will use its own thread pools.
- Parameters
-
[in] logging_function A pointer to a logging function. [in] logger_param A pointer to arbitrary data passed as the OrtLoggingFunction paramparameter tologging_function.[in] log_severity_level The log severity level. [in] logid The log identifier. [in] tp_options [out] out Newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateEnvWithGlobalThreadPools()
Create an OrtEnv.
Create an environment with global threadpools that will be shared across sessions. Use this in conjunction with OrtApi::DisablePerSessionThreads or else the session will use its own thread pools.
- Parameters
-
[in] log_severity_level The log severity level. [in] logid The log identifier. [in] tp_options [out] out Returned newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateEnvWithOptions()
Create an OrtEnv instance with the given options.
- Note
- Invoking this function will return the same instance of the environment as that returned by a previous call to another env creation function; all arguments to this function will be ignored.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ CreateExternalInitializerInfo()
Creates an OrtExternalInitializerInfo instance.
- Parameters
-
[in] filepath The relative path to the file that stores the initializer's data. ORT copies this path string. [in] file_offset The byte offset where the initializer's data is stored within the file. [in] byte_size The size in bytes of the initializer's data within the file. [out] out Output parameter set to the new OrtExternalInitializerInfo instance. Must be released by calling ReleaseExternalInitializerInfo().
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ CreateIoBinding()
Create an OrtIoBinding instance.
An IoBinding object allows one to bind pre-allocated OrtValues to input names. Thus if you want to use a raw on device buffer as input or output you can avoid extra copy during runtime.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateLoraAdapter()
Create an OrtLoraAdapter.
The function attempts to locate file specified by adapter_file_path, read it and create an OrtLoraAdapter instance. The adapter_file_path should be a valid path to a file that contains a valid Lora Adapter format. The function attempts to validate the format at load time. The file will always be memory mapped, unless the platform does not support memory mapping, in which case the file will be read into memory.
- Parameters
-
[in] adapter_file_path adapter file path. [in] allocator optional pointer to a device allocator. If specified data is copied to the device at some point before Run() is invoked. If nullptr, data stays on CPU. The data would still be copied to device if required by the model at inference time. [out] out A pointer to a newly created OrtLoraAdapter instance. Must be released with OrtApi::ReleaseLoraAdapter.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.20.
◆ CreateLoraAdapterFromArray()
Create an OrtLoraAdapter.
The function copies the bytes from the array and creates an OrtLoraAdapter instance.
- Parameters
-
[in] bytes pointer to a valid Lora Adapter format buffer. [in] num_bytes length of bytes buffer. [in] allocator optional pointer to a device allocator. If specified data is copied to the device at some point before Run() is invoked. If nullptr, data stays on CPU. The data would still be copied to device if required by the model at inference time. [out] out A pointer to a newly created OrtLoraAdapter instance. Must be released with OrtApi::ReleaseLoraAdapter.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.20.
◆ CreateMemoryInfo()
Create an OrtMemoryInfo.
- Parameters
-
[in] name [in] type [in] id [in] mem_type [out] out Newly created OrtMemoryInfo. Must be freed with OrtAPi::ReleaseMemoryInfo
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateMemoryInfo_V2()
Create an OrtMemoryInfo.
- Parameters
-
[in] name Arbitrary name. [in] device_type Device type. [in] vendor_id PCI Vendor ID. Use 0 for a generic allocator (e.g. WebGPU). [in] device_id Device ID if there are multiple devices of the same type. e.g. 2 GPU devices. [in] mem_type Memory type. Use OrtDeviceMemoryType_DEFAULT for device memory, and OrtDeviceMemoryType_HOST_ACCESSIBLE (if applicable) for memory used to transfer between the device and the CPU. Use the device_type and device_id of the GPU/NPU that the memory is also accessible to. [in] alignment Alignment of the memory if required. Pass 0 for default alignment. [in] allocator_type Allocator type. If OrtAllocatorType::OrtArenaAllocator, the ORT arena will be used. Caveat: Support for OrtArenaAllocator is currently limited to usage of internal ORT allocators via CreateAllocator/CreateAndRegisterAllocator/CreateAndRegisterAllocatorV2. [out] out Newly created OrtMemoryInfo. Must be freed with OrtApi::ReleaseMemoryInfo
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ CreateOp()
| OrtStatus * OrtApi::CreateOp | ( | const OrtKernelInfo * | info, |
| const char * | op_name, | ||
| const char * | domain, | ||
| int | version, | ||
| const char ** | type_constraint_names, | ||
| const ONNXTensorElementDataType * | type_constraint_values, | ||
| int | type_constraint_count, | ||
| const OrtOpAttr *const * | attr_values, | ||
| int | attr_count, | ||
| int | input_count, | ||
| int | output_count, | ||
| OrtOp ** | ort_op | ||
| ) |
: Create onnxruntime native operator
- Parameters
-
[in] info Kernel info [in] op_name Operator name [in] domain Operator domain [in] version Operator opset version [in] type_constraint_names Name of the type constraints, such as "T" or "T1" [in] type_constraint_values Type of each constraints [in] type_constraint_count Number of constraints [in] attr_values Attributes used to initialize the operator [in] attr_count Number of the attributes [in] input_count Number of inputs [in] output_count Number of outputs [out] ort_op Operator that has been created
- Since
- Version 1.12.
◆ CreateOpaqueValue()
| OrtStatus * OrtApi::CreateOpaqueValue | ( | const char * | domain_name, |
| const char * | type_name, | ||
| const void * | data_container, | ||
| size_t | data_container_size, | ||
| OrtValue ** | out | ||
| ) |
Create an opaque (custom user defined type) OrtValue.
Constructs an OrtValue that contains a value of non-standard type created for experiments or while awaiting standardization. OrtValue in this case would contain an internal representation of the Opaque type. Opaque types are distinguished from each other by two strings 1) domain and 2) type name. The combination of the two must be unique, so the type representation is properly identified internally. The combination must be properly registered from within ORT at both compile/run time or by another API.
To construct the OrtValue pass domain and type names, also a pointer to a data container the type of which must be known to both ORT and the client program. That data container may or may not match the internal representation of the Opaque type. The sizeof(data_container) is passed for verification purposes.
- Parameters
-
[in] domain_name Null terminated string of the domain name [in] type_name Null terminated string of the type name [in] data_container User pointer Data to populate OrtValue [in] data_container_size Size in bytes of what data_containerpoints to[out] out Newly created OrtValue. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateOpAttr()
: Create attribute of onnxruntime operator
- Parameters
-
[in] name Name of the attribute [in] data Data content of the attribute [in] len Number of bytes stored in data for ORT_OP_ATTR_STRING. Number of elements if data represents an array (e.g., ORT_OP_ATTR_INTS). Otherwise, set to 1. [in] type Data type [out] op_attr Attribute that has been created, which must be released by OrtApi::ReleaseOpAttr
- Since
- Version 1.12.
◆ CreatePrepackedWeightsContainer()
Create an OrtPrepackedWeightsContainer.
This container will hold pre-packed buffers of shared initializers for sharing between sessions (i.e.) if there are shared initializers that can be shared between sessions, the pre-packed buffers of these (if any) may possibly be shared to provide memory footprint savings. Pass this container to sessions that you would like to share pre-packed buffers of shared initializers at session creation time.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateROCMProviderOptions()
◆ CreateRunOptions()
Create an OrtRunOptions.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSession()
Create an OrtSession from a model file.
- Parameters
-
[in] env [in] model_path [in] options [out] out Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSessionFromArray()
Create an OrtSession from memory.
- Parameters
-
[in] env [in] model_data [in] model_data_length [in] options [out] out Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSessionFromArrayWithPrepackedWeightsContainer()
Create session from memory with prepacked weights container.
Same functionality offered by OrtApi::CreateSessionFromArray except that a container that contains pre-packed weights' buffers is written into/read from by the created session. This is useful when used in conjunction with OrtApi::AddInitializer which injects shared initializer info into sessions. Wherever possible, the pre-packed versions of these shared initializers are cached in this container so that multiple sessions can just re-use these instead of duplicating these in memory.
- Parameters
-
[in] env [in] model_data Array of bytes holding the model [in] model_data_length Number of bytes in model_data_model[in] options [in] prepacked_weights_container [out] out Newly created OrtSession. Must be freed with OrtApi::ReleaseSession
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSessionOptions()
Create an OrtSessionOptions object.
To use additional providers, you must build ORT with the extra providers enabled. Then call one of these functions to enable them in the session:
OrtSessionOptionsAppendExecutionProvider_CPU
OrtSessionOptionsAppendExecutionProvider_CUDA
OrtSessionOptionsAppendExecutionProvider_(remaining providers...)
The order they are called indicates the preference order as well. In other words call this method on your most preferred execution provider first followed by the less preferred ones. If none are called Ort will use its internal CPU execution provider.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSessionWithPrepackedWeightsContainer()
Create session with prepacked weights container.
Same functionality offered by OrtApi::CreateSession except that a container that contains pre-packed weights' buffers is written into/read from by the created session. This is useful when used in conjunction with OrtApi::AddInitializer which injects shared initializer info into sessions. Wherever possible, the pre-packed versions of these shared initializers are cached in this container so that multiple sessions can just re-use these instead of duplicating these in memory.
- Parameters
-
[in] env OrtEnv instance instance [in] model_path Null terminated string of the path (wchar on Windows, char otherwise) [in] options [in] prepacked_weights_container [out] out Newly created OrtSession. Must be freed with OrtApi::ReleaseSession
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSharedAllocator()
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.
- Parameters
-
[in] env The OrtEnv instance to create the shared allocator in. [in] ep_device The OrtEpDevice instance to create the shared allocator for. [in] mem_type The memory type to use for the shared allocator. [in] allocator_type The type of allocator to create. Only OrtDeviceAllocator is valid currently. [in] 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. [out] allocator A pointer to the created shared allocator. Owned by the OrtEnv instance.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ CreateSparseTensorAsOrtValue()
Create an OrtValue with a sparse tensor that is empty.
Use FillSparseTensor<Format>() functions to populate sparse tensor with non-zero values and format specific indices data. Use ReleaseValue to destroy the sparse tensor, this will also release the buffer inside the output value if any was allocated.
- Parameters
-
[in,out] allocator allocator to use when performing an allocation. Allocation will be performed by FillSparseTensor<Format>() APIs. The lifespan of the allocator instance must eclipse the lifespan this sparse tensor instance as the same allocator will be used to free memory. [in] dense_shape shape of the original dense tensor [in] dense_shape_len number of shape dimensions being passed [in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx [out] out Should be freed by calling ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSparseTensorWithValuesAsOrtValue()
Create an OrtValue with a sparse tensor. This is the first step. Next, use Use<Format>Indices() functions to supply sparse tensor with format specific indices data and set its sparse format to a specific enum value. This will not perform memory allocations. It will use supplied user buffer which should outlive the created sparse tensor. Use OrtApi::ReleaseValue to destroy the sparse tensor. It would not release the supplied values buffer. This function can not be used to map strings from the user allocated memory. Strings must always be copied and have UTF-8 encoding. Therefore, use OrtApi::CreateSparseTensorAsOrtValue above and then fill it with data using appropriate Make*() function.
- Parameters
-
[in] info memory info where sparse values reside. [in,out] p_data pointer to a user allocated buffer with values. To create a full sparse tensor with no non-zero values, pass nullptr [in] dense_shape shape of the original dense tensor [in] dense_shape_len number of shape dimensions being passed [in] values_shape shape of the values data. To create a fully sparse tensor with no non-zero values, pass {0} shape. [in] values_shape_len number of values shape dimensions [in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx [out] out Should be freed by calling ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateSyncStreamForEpDevice()
Create an OrtSyncStream for the given OrtEpDevice.
The OrtSyncStream can be used to enable asynchronous operations. e.g. async usage of CopyTensors to provide input to an OrtSession Run call.
An error code of ORT_NOT_IMPLEMENTED will be returned if the EP does not support OrtSyncStream.
- Parameters
-
[in] ep_device The OrtEpDevice instance to create the sync stream for. [in] stream_options Options for OrtSyncStream creation. May be nullptr. [out] stream Output parameter set to the created OrtSyncStream instance.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ CreateTensorAsOrtValue()
Create a tensor.
Create a tensor using a supplied OrtAllocator
- Parameters
-
[in] allocator [in] shape Pointer to the tensor shape dimensions. [in] shape_len The number of tensor shape dimensions. [in] type [out] out Returns newly created OrtValue. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateTensorRTProviderOptions()
Create an OrtTensorRTProviderOptionsV2.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateTensorTypeAndShapeInfo()
◆ CreateTensorWithDataAndDeleterAsOrtValue()
Create an OrtValue for a Tensor that uses pre-existing memory.
ORT will take ownership of the memory and free it using the provided deleter when no longer in use.
- Parameters
-
[in] deleter OrtAllocator instance that will be used to free the memory. Only the OrtAllocator:Info and OrtAllocator::Release functions are required. The OrtMemoryInfo returned by OrtAllocator::Info must match the location of p_data. [in] p_data Pointer to the memory that will be used by the Tensor. ORT will take ownership of the memory. [in] p_data_len Length of the memory in bytes. [in] shape Dimensions of the Tensor. All values should be > 0. [in] shape_len Number of dimensions in the shape array. [in] type Data type of the Tensor. [out] out Newly created OrtValue. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ CreateTensorWithDataAsOrtValue()
Create a tensor backed by a user supplied buffer.
Create a tensor with user's buffer. You can fill the buffer either before calling this function or after. p_data is owned by caller. ReleaseValue won't release p_data.
If you wish to transfer ownership of p_data to ORT use CreateTensorWithDataAndDeleterAsOrtValue.
- Parameters
-
[in] info Memory description of where the p_data buffer resides (CPU vs GPU etc). [in] p_data Pointer to the data buffer. [in] p_data_len The number of bytes in the data buffer. [in] shape Pointer to the tensor shape dimensions. [in] shape_len The number of tensor shape dimensions. [in] type The data type. [out] out Returns newly created OrtValue. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CreateThreadingOptions()
◆ CreateValue()
Create a map or sequence OrtValue.
To construct a map (ONNX_TYPE_MAP), use num_values = 2 and in should be an array of 2 OrtValues representing keys and values.
To construct a sequence (ONNX_TYPE_SEQUENCE), use num_values = N where N is the number of the elements in the sequence. 'in' should be an array of N OrtValues.
- Parameters
-
[in] in See above for details [in] num_values [in] value_type Must be either ONNX_TYPE_MAP or ONNX_TYPE_SEQUENCE [out] out Newly created OrtValue. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ CustomOpDomain_Add()
Add a custom op to a custom op domain.
- Note
- The OrtCustomOp* pointer must remain valid until the OrtCustomOpDomain using it is released
- Parameters
-
[in] custom_op_domain [in] op
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ DeviceEpIncompatibilityDetails_GetErrorCode()
Get the execution provider error code from OrtDeviceEpIncompatibilityDetails.
This allows Independent Hardware Vendors (IHVs) to define their own error codes to provide additional details about device incompatibility.
- Parameters
-
[in] details The OrtDeviceEpIncompatibilityDetails instance to query. [out] error_code Pointer to store the EP-specific error code. A value of 0 indicates no error code was set.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ DeviceEpIncompatibilityDetails_GetNotes()
Get the notes from OrtDeviceEpIncompatibilityDetails.
- Parameters
-
[in] details The OrtDeviceEpIncompatibilityDetails instance to query. [out] notes Pointer to the notes string. May be nullptr if no notes are available. The returned string is owned by the details object and should not be freed.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ DeviceEpIncompatibilityDetails_GetReasonsBitmask()
Get the incompatibility reasons bitmask from OrtDeviceEpIncompatibilityDetails.
- Parameters
-
[in] details The OrtDeviceEpIncompatibilityDetails instance to query. [out] reasons_bitmask Pointer to store the bitmask of incompatibility reasons.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ DisableCpuMemArena()
Disable the memory arena on CPU.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ DisableMemPattern()
Disable the memory pattern optimization.
- See also
- OrtApi::EnableMemPattern
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ DisablePerSessionThreads()
Use global thread pool on a session.
Disable using per session thread pool and use the shared global threadpool. This should be used in conjunction with OrtApi::CreateEnvWithGlobalThreadPools.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ DisableProfiling()
Disable profiling for a session.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ DisableTelemetryEvents()
◆ EnableCpuMemArena()
Enable the memory arena on CPU.
Arena may pre-allocate memory for future usage.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ EnableMemPattern()
Enable the memory pattern optimization.
The idea is if the input shapes are the same, we could trace the internal memory allocation and generate a memory pattern for future request. So next time we could just do one allocation with a big chunk for all the internal memory allocation.
- Note
- Memory pattern optimization is only available when Sequential Execution mode is enabled (see OrtApi::SetSessionExecutionMode)
- See also
- OrtApi::DisableMemPattern
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ EnableOrtCustomOps()
◆ EnableProfiling()
Enable profiling for a session.
- Parameters
-
[in] options [in] profile_file_prefix
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ EnableTelemetryEvents()
Enable Telemetry.
- Note
- Telemetry events are on by default since they are lightweight
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ EpAssignedNode_GetDomain()
Get the domain of the node assigned to an execution provider.
- Parameters
-
[in] ep_node The OrtEpAssignedNode instance. [out] out Output parameter set to the node's domain as a UTF-8 null-terminated string. Owned by the OrtEpAssignedNode instance (do not free).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ EpAssignedNode_GetName()
Get the name of the node assigned to an execution provider.
- Parameters
-
[in] ep_node The OrtEpAssignedNode instance. [out] out Output parameter set to the node's name as a UTF-8 null-terminated string. Owned by the OrtEpAssignedNode instance (do not free).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ EpAssignedNode_GetOperatorType()
Get the operator type of the node assigned to an execution provider.
- Parameters
-
[in] ep_node The OrtEpAssignedNode instance. [out] out Output parameter set to the node's operator type as a UTF-8 null-terminated string. Owned by the OrtEpAssignedNode instance (do not free).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ EpAssignedSubgraph_GetEpName()
Get the name of the execution provider to which the subgraph was assigned.
- Parameters
-
[in] ep_subgraph The OrtEpAssignedSubgraph instance. [out] out Output parameter set to the execution provider's name as a UTF-8 null-terminated string. Owned by the OrtEpAssignedSubgraph instance (do not free).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ EpAssignedSubgraph_GetNodes()
Get the nodes in a subgraph assigned to a specific execution provider.
- Parameters
-
[in] ep_subgraph The OrtEpAssignedSubgraph instance. [out] ep_nodes Output parameter set to the array of OrtEpAssignedNode instances. [out] num_ep_nodes Output parameter set to the number of OrtEpAssignedNode instance returned.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ FillSparseTensorBlockSparse()
| OrtStatus * OrtApi::FillSparseTensorBlockSparse | ( | OrtValue * | ort_value, |
| const OrtMemoryInfo * | data_mem_info, | ||
| const int64_t * | values_shape, | ||
| size_t | values_shape_len, | ||
| const void * | values, | ||
| const int64_t * | indices_shape_data, | ||
| size_t | indices_shape_len, | ||
| const int32_t * | indices_data | ||
| ) |
This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory and copy the supplied NNZ values and BlockSparse indices into that memory allocation. Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue.
- Parameters
-
[in,out] ort_value OrtValue to populate with data [in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. [in] values_shape [in] values_shape_len [in] values structure with values information [in] indices_shape_data pointer to a location of indices shape [in] indices_shape_len length of the block sparse indices shape [in] indices_data pointer to a location of indices data. Shape will determine the length of the indices data.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ FillSparseTensorCoo()
| OrtStatus * OrtApi::FillSparseTensorCoo | ( | OrtValue * | ort_value, |
| const OrtMemoryInfo * | data_mem_info, | ||
| const int64_t * | values_shape, | ||
| size_t | values_shape_len, | ||
| const void * | values, | ||
| const int64_t * | indices_data, | ||
| size_t | indices_num | ||
| ) |
This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory and copy the supplied NNZ values and COO indices into that memory allocation. Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue.
- Parameters
-
[in,out] ort_value OrtValue to populate with data [in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. [in] values_shape pointer to values shape array [in] values_shape_len length of the values_shape [in] values pointer to an array of values. For strings, pass const char**. [in] indices_data pointer to a location of COO indices [in] indices_num number of COO indices
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ FillSparseTensorCsr()
| OrtStatus * OrtApi::FillSparseTensorCsr | ( | OrtValue * | ort_value, |
| const OrtMemoryInfo * | data_mem_info, | ||
| const int64_t * | values_shape, | ||
| size_t | values_shape_len, | ||
| const void * | values, | ||
| const int64_t * | inner_indices_data, | ||
| size_t | inner_indices_num, | ||
| const int64_t * | outer_indices_data, | ||
| size_t | outer_indices_num | ||
| ) |
This fills populates an empty tensor that was created using OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory and copy the supplied NNZ values and CSR indices into that memory allocation. Memory allocation is performed using the allocator that was specified with OrtApi::CreateSparseTensorAsOrtValue.
- Parameters
-
[in,out] ort_value OrtValue to populate with data [in] data_mem_info serves to identify the location of the data to be copied. If the allocator specified at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. [in] values_shape pointer to values shape array [in] values_shape_len length of the values_shape [in] values - pointer to an array of values. For strings, pass const char**. [in] inner_indices_data pointer to a location of CSR inner indices [in] inner_indices_num number of CSR inner indices [in] outer_indices_data pointer to a location of CSR outer indices [in] outer_indices_num number of CSR outer indices
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ FillStringTensor()
Set all strings at once in a string tensor.
- Parameters
-
[in,out] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING [in] s An array of strings. Each string in this array must be null terminated. [in] s_len Count of strings in s (Must match the size of value'stensor shape)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ FillStringTensorElement()
Set a single string in a string tensor.
- Parameters
-
[in] value A string tensor [in] s A null terminated UTF-8 encoded string [in] index Index of the string in the tensor to set
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetAllocatorWithDefaultOptions()
Get the default allocator.
The default allocator is a CPU based, non-arena. Always returns the same pointer to the same default allocator.
- Parameters
-
[out] out Returned value should NOT be freed
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetAvailableProviders()
| OrtStatus * OrtApi::GetAvailableProviders | ( | char *** | out_ptr, |
| int * | provider_length | ||
| ) |
Get the names of all available providers.
- Note
- The providers in the list are not guaranteed to be usable. They may fail to load due to missing system dependencies. For example, if the CUDA/cuDNN libraries are not installed, the CUDA provider will report an error when it is added to the session options.
- Parameters
-
[out] out_ptr Set to a pointer to an array of null terminated strings of the available providers. The entries and the array itself must be freed using OrtApi::ReleaseAvailableProviders [out] provider_length Set to the number of entries in the out_ptrarray
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetBoundOutputNames()
Get the names of an OrtIoBinding's outputs.
Returns the names of the outputs in the order they were bound. This is useful after running the model with bound outputs because the returned names are in order in which output OrtValue are returned. This is useful if the order of outputs and their names is not known.
- Parameters
-
[in] binding_ptr [in] allocator Allocator used to allocate continuous buffers for output strings and lengths. [out] buffer Returns an array of non-null terminated UTF-8 strings. The number of strings stored is returned in the count parameter. This buffer is allocated using allocatorand must be freed using it.[out] lengths Returns an array of countlengths of the strings returned inbufferThis buffer is allocated usingallocatorand must be freed using it.[out] count Number of strings returned. If binding_ptrhas no bound outputs, zero is returned, no memory allocation is performed and buffer and lengths are set to nullptr.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetBoundOutputValues()
Get the output OrtValue objects from an OrtIoBinding.
Returns an array of pointers to individually allocated OrtValues that contain results of a model execution with OrtApi::RunWithBinding The array contains the same number of OrtValues and they are in the same order as they were bound with OrtApi::BindOutput or OrtApi::BindOutputToDevice.
The returned OrtValues must be released using OrtApi::ReleaseValue after they are no longer needed. The array is allocated using the specified instance of the allocator and must be freed using the same allocator after all the OrtValues contained therein are individually released.
- Parameters
-
[in] binding_ptr [in] allocator Allocator used to allocate output array [out] output Set to the allocated array of allocated OrtValue outputs. Set to nullptr if there are 0 outputs. [out] output_count Set to number of OrtValues returned
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetCANNProviderOptionsAsString()
Get serialized CANN provider options string.
- Parameters
-
[in] cann_options OrtCANNProviderOptions instance [in] allocator a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions(), the specified allocator will be used to allocate continuous buffers for output strings and lengths. [out] ptr is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.13.
◆ GetCompatibilityInfoFromModel()
| OrtStatus * OrtApi::GetCompatibilityInfoFromModel | ( | const char * | model_path, |
| const char * | ep_type, | ||
| OrtAllocator * | allocator, | ||
| char ** | compatibility_info | ||
| ) |
Extract EP compatibility info from a precompiled model file.
Parses the model file to extract the compatibility info string for a specific execution provider from the model's metadata properties. This is only applicable to models that have been precompiled for an EP (e.g., via OrtCompileApi). Standard ONNX models do not contain this information.
The compatibility info string must be valid UTF-8 without embedded NUL characters.
- Note
- This API performs standalone model parsing, separate from session creation. This means the protobuf parsing cost is incurred here and again during session creation. It is intended for scenarios where applications need to check compatibility before deciding whether to proceed with session creation, such as providing early user feedback.
- This operation parses the full ONNX ModelProto from disk. For very large models, consider using GetCompatibilityInfoFromModelBytes with a pre-loaded buffer if the model is already in memory.
The compatibility info can then be passed to GetModelCompatibilityForEpDevices to check if a precompiled model is compatible with the current system.
- Parameters
-
[in] model_path Path to the ONNX model file. [in] ep_type The execution provider type string. Must be non-empty. Use OrtApi::EpDevice_EpName to get this value from an OrtEpDevice. [in] allocator Allocator to use for the output string. Use OrtApi::GetAllocatorWithDefaultOptions. [out] compatibility_info Output pointer to the compatibility info string. Returns nullptr if no compatibility info exists for the specified EP. Caller must free with OrtApi::AllocatorFree when non-null.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetCompatibilityInfoFromModelBytes()
| OrtStatus * OrtApi::GetCompatibilityInfoFromModelBytes | ( | const void * | model_data, |
| size_t | model_data_length, | ||
| const char * | ep_type, | ||
| OrtAllocator * | allocator, | ||
| char ** | compatibility_info | ||
| ) |
Extract EP compatibility info from precompiled model bytes in memory.
Same as GetCompatibilityInfoFromModel but reads from a memory buffer instead of a file. Useful when precompiled models are loaded from encrypted storage, network, or other non-file sources.
- Note
- This API performs standalone model parsing, separate from session creation. This means the protobuf parsing cost is incurred here and again during session creation. It is intended for scenarios where applications need to check compatibility before deciding whether to proceed with session creation, such as providing early user feedback.
- Parameters
-
[in] model_data Pointer to the model data in memory. [in] model_data_length Size of the model data in bytes. [in] ep_type The execution provider type string. Must be non-empty. [in] allocator Allocator to use for the output string. Use OrtApi::GetAllocatorWithDefaultOptions. [out] compatibility_info Output pointer to the compatibility info string. Returns nullptr if no compatibility info exists for the specified EP. Caller must free with OrtApi::AllocatorFree when non-null.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetCUDAProviderOptionsAsString()
Get serialized CUDA provider options string.
For example, "device_id=0;arena_extend_strategy=0;......"
- Parameters
-
cuda_options - OrtCUDAProviderOptionsV2 instance allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions() the specified allocator will be used to allocate continuous buffers for output strings and lengths. ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.11.
◆ GetCUDAProviderOptionsByName()
Get CUDA EP provider option where its data type is pointer. If the data type of the provider option can be represented by string please use GetCUDAProviderOptionsAsString.
- Parameters
-
cuda_options - OrtCUDAProviderOptionsV2 instance key - Name of the provider option ptr - A pointer to the instance that is kept by the provider option
- Since
- Version 1.16.
◆ GetCurrentGpuDeviceId()
| OrtStatus * OrtApi::GetCurrentGpuDeviceId | ( | int * | device_id | ) |
Get current GPU device ID.
Get the current device id of the GPU execution provider (CUDA/tensorrt/rocm).
- See also
- OrtApi::SetCurrentGpuDeviceId
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetDenotationFromTypeInfo()
| OrtStatus * OrtApi::GetDenotationFromTypeInfo | ( | const OrtTypeInfo * | type_info, |
| const char **const | denotation, | ||
| size_t * | len | ||
| ) |
Get denotation from type information.
Augments OrtTypeInfo to return denotations on the type.
This is used by WinML to determine if an input/output is intended to be an Image or a Tensor.
- Parameters
-
[in] type_info [out] denotation Pointer to the null terminated denotation string is written to this pointer. This pointer is valid until the object is destroyed or the name is changed, do not free. [out] len Length in bytes of the string returned in denotation
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetDimensions()
◆ GetDimensionsCount()
◆ GetDnnlProviderOptionsAsString()
Get serialized oneDNN provider options string.
For example, "use_arena=1;......"
- Parameters
-
dnnl_options - OrtDnnlProviderOptions instance allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions() the specified allocator will be used to allocate continuous buffers for output strings and lengths. ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ GetEpDevices()
Get the list of available OrtEpDevice instances.
Each OrtEpDevice instance contains details of the execution provider and the device it will use.
- Parameters
-
[in] env The OrtEnv instance to query. [out] ep_devices The OrtEpDevice instances that the execution provider will use. [out] num_ep_devices The number of OrtEpDevice instances returned.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ GetExecutionProviderApi()
| OrtStatus * OrtApi::GetExecutionProviderApi | ( | const char * | provider_name, |
| uint32_t | version, | ||
| const void ** | provider_api | ||
| ) |
Get a pointer to the requested version of the Execution Provider specific API extensions to the OrtApi.
- Parameters
-
[in] provider_name The name of the execution provider name. Currently only the following values are supported: "DML". [in] version Must be ORT_API_VERSION. [out] provider_api A void pointer containing a reference to the execution provider versioned api structure. For example, the provider_api pointer can be cast to the OrtDmlApi* when the provider_name is "DML".
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetHardwareDeviceEpIncompatibilityDetails()
Check for known incompatibility issues between hardware device and a specific execution provider.
This function checks for known incompatibility issues between the specified hardware device and a specific execution provider. If returned incompatibility details have non-zero reasons, it indicates the device is not compatible. However, if returned detail have reason == 0, it doesn't guarantee 100% compatibility for all models, as models may have specific requirements.
Note: This method should only be called when the OrtEnv has been initialized with execution providers (after RegisterExecutionProviderLibrary is called).
- Parameters
-
[in] env The OrtEnv instance with registered execution providers. [in] ep_name The name of the execution provider to check. Required and cannot be null or empty. [in] hw The hardware device to check for incompatibility. [out] details Compatibility details including reasons for incompatibility if any. Must be freed with OrtApi::ReleaseDeviceEpIncompatibilityDetails.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetHardwareDevices()
Get the list of available hardware devices.
Enumerates hardware devices available on the system. Populates a user-provided array with pointers to OrtHardwareDevice instances. The caller is responsible for allocating the array with sufficient space (use GetNumHardwareDevices() to get the count).
The returned pointers reference internal ORT data structures that are discovered once at process startup and remain valid for the lifetime of the OrtEnv. The caller does not need to release these pointers, but should not use them after calling ReleaseEnv().
- Parameters
-
[in] env The OrtEnv instance where device discovery results are stored. [out] devices User-allocated array to receive pointers to OrtHardwareDevice instances. The array must have space for at least num_devices elements. [in] num_devices The size of the user-allocated devices array.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetMapKeyType()
Get key type from an OrtMapTypeInfo.
Key types are restricted to being scalar types.
This is used by WinML to support model reflection APIs.
- Parameters
-
[in] map_type_info [out] out
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetMapValueType()
Get the value type from an OrtMapTypeInfo.
- Parameters
-
[in] map_type_info [out] type_info A copy of the OrtTypeInfo for the map value type. The user must free this value with ReleaseTypeInfo.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetModelCompatibilityForEpDevices()
Validate a compiled model's compatibility information for one or more EP devices.
- Parameters
-
[in] ep_devices The EP devices to validate against (e.g., from GetEpDevices). All devices must belong to the same execution provider. [in] num_ep_devices The number of EP devices provided. [in] compatibility_info The compatibility info string produced when the model was compiled. [out] out_status The resulting compatibility status for the EP devices.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ GetNumHardwareDevices()
Get the number of available hardware devices.
Returns the count of hardware devices discovered on the system. Use this to allocate an array before calling GetHardwareDevices().
- Parameters
-
[in] env The OrtEnv instance where device discovery results are stored. [out] num_devices The number of OrtHardwareDevice instances available.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetOnnxTypeFromTypeInfo()
◆ GetOpaqueValue()
| OrtStatus * OrtApi::GetOpaqueValue | ( | const char * | domain_name, |
| const char * | type_name, | ||
| const OrtValue * | in, | ||
| void * | data_container, | ||
| size_t | data_container_size | ||
| ) |
Get internal data from an opaque (custom user defined type) OrtValue.
Copies internal data from an opaque value into a user provided buffer
- See also
- OrtApi::CreateOpaqueValue
- Parameters
-
[in] domain_name Null terminated string of the domain name [in] type_name Null terminated string of the type name [in] in The opaque OrtValue [out] data_container Buffer to copy data into [out] data_container_size Size in bytes of the buffer pointed to by data_container. Must match the size of the internal buffer.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetOptionalContainedTypeInfo()
Get OrtTypeInfo for the allowed contained type from an OrtOptionalTypeInfo.
This augments OrtOptionalTypeInfo to return an OrtTypeInfo for the contained type. The OrtOptionalTypeInfo has a nested OrtTypeInfo that describes the type of the optional value. OrtOptionalTypeInfo type can only appear within model metadata to describe inputs/outputs. The actual OrtValues that are supplied in place of optional type inputs should contain specific type that is described by the returned OrtTypeInfo.
- Parameters
-
[in] optional_type_info [out] out A copy of OrtTypeInfo for what the optional value could be. The user must free this value with ReleaseTypeInfo.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ GetResizedStringTensorElementBuffer()
| OrtStatus * OrtApi::GetResizedStringTensorElementBuffer | ( | OrtValue * | value, |
| size_t | index, | ||
| size_t | length_in_bytes, | ||
| char ** | buffer | ||
| ) |
Set a single string in a string tensor Do not zero terminate the string data.
- Parameters
-
[in] value A string tensor [in] index - flat index of the element [in] length_in_bytes length of the buffer in utf-8 bytes (without the null terminator) [in,out] buffer - address of return value
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetROCMProviderOptionsAsString()
Get serialized ROCm provider options string.
For example, "device_id=0;arena_extend_strategy=0;......"
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.16.
◆ GetSequenceElementType()
Get element type from an OrtSequenceTypeInfo.
This is used by WinML to support model reflection APIs.
- Parameters
-
[in] sequence_type_info [out] type_info A copy of the OrtTypeInfo for the sequence element type. The user must free this value with ReleaseTypeInfo.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSessionConfigEntry()
| OrtStatus * OrtApi::GetSessionConfigEntry | ( | const OrtSessionOptions * | options, |
| const char * | config_key, | ||
| char * | config_value, | ||
| size_t * | size | ||
| ) |
Get a session configuration value.
Returns a failure status if the configuration key does not exist. The config_key and the format of config_value are defined in onnxruntime_session_options_config_keys.h
If config_value is nullptr, the value of size is set to the true size of the string value (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the actual string value's size, the value of size is set to the true size of the string value, the provided memory is filled with the value's contents, and a success status is returned.
If the size parameter is less than the actual string value's size and config_value is not nullptr, the value of size is set to the true size of the string value and a failure status is returned.
Can be used in a custom operator library to get session configuration entries that target one or more custom operators in the library. Example: The config entry custom_op.myop.some_key targets a custom op named "myop".
- Parameters
-
[in] options The session options. [in] config_key A null-terminated UTF-8 string representation of the config key. [in] config_value Pointer to memory where the null-terminated UTF-8 string value will be stored. [in,out] size Pointer to the size of the config_valuebuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ GetSessionOptionsConfigEntries()
Get Session configuration entries.
- Parameters
-
[in] options The session options. [out] out A pointer to a newly created OrtKeyValuePairs instance.
An OrtKeyValuePairs instance containing all session configuration entries. Note: the user should call OrtApi::ReleaseKeyValuePairs.
- Since
- Version 1.23.
◆ GetSharedAllocator()
Get a shared allocator from the OrtEnv.
By default there is a shared allocator created for all OrtEpDevice instances, so if you get the OrtMemoryInfo from the OrtEpDevice using EpDevice_MemoryInfo a shared allocator is guaranteed to exist.
This will also match and return custom allocators added with RegisterAllocator.
It is not an error to not find a matching allocator.
- Parameters
-
[in] env The OrtEnv instance to get the shared allocator from. [in] mem_info The OrtMemoryInfo instance to get the shared allocator for. [out] allocator A pointer to the shared allocator, or nullptr if no shared allocator exists for the given memory info.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ GetSparseTensorFormat()
Returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor.
- Parameters
-
[in] ort_value OrtValue that contains an instance of sparse tensor [out] out pointer to out parameter
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSparseTensorIndices()
Returns indices data for the type of the indices specified by indices_format.
- Parameters
-
[in] ort_value OrtValue containing sparse tensor. [in] indices_format One of the indices formats. It is an error to request a format that the sparse tensor does not contain. [out] num_indices Pointer to where the number of indices entries is returned [out] indices Returned pointer to the indices data. Do not free the returned pointer as it refers to internal data owned by the OrtValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSparseTensorIndicesTypeShape()
Returns data type, shape for the type of indices specified by indices_format.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSparseTensorValues()
Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*().
- Parameters
-
[in] ort_value an instance of OrtValue containing sparse tensor [out] out returns a pointer to values data. Do not attempt to free this ptr.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSparseTensorValuesTypeAndShape()
Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetStringTensorContent()
| OrtStatus * OrtApi::GetStringTensorContent | ( | const OrtValue * | value, |
| void * | s, | ||
| size_t | s_len, | ||
| size_t * | offsets, | ||
| size_t | offsets_len | ||
| ) |
Get all strings from a string tensor.
An example of the results:
Given value is a string tensor with the strings { "This" "is" "a" "test" }
s must have a size of 11 bytes
offsets must have 4 elements
After the call, these values will be filled in:
s will contain "Thisisatest"
offsets will contain { 0, 4, 6, 7 }
The length of the last string is just s_len - offsets[last]
- Parameters
-
[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING [in] s Buffer to sequentially write all tensor strings to. Each string is NOT null-terminated. [in] s_len Number of bytes of buffer pointed to by s(Get it from OrtApi::GetStringTensorDataLength)[out] offsets Array of start offsets into the strings written to s[in] offsets_len Number of elements in offsets
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetStringTensorDataLength()
Get total byte length for all strings in a string tensor.
Typically used with OrtApi::GetStringTensorContent
- Parameters
-
[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING [out] len Total byte length of all strings (does not include trailing nulls)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetStringTensorElement()
| OrtStatus * OrtApi::GetStringTensorElement | ( | const OrtValue * | value, |
| size_t | s_len, | ||
| size_t | index, | ||
| void * | s | ||
| ) |
Get a single string from a string tensor.
- Parameters
-
[in] value A string tensor [in] s_len Number of bytes in the sbuffer. Must match the value returned by OrtApi::GetStringTensorElementLength.[in] index Index of the string in the tensor [out] s The string element contents in UTF-8 encoding. The string is NOT null-terminated.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetStringTensorElementLength()
| OrtStatus * OrtApi::GetStringTensorElementLength | ( | const OrtValue * | value, |
| size_t | index, | ||
| size_t * | out | ||
| ) |
Get the length of a single string in a string tensor.
- Parameters
-
[in] value A string tensor [in] index Index of the string in the tensor [out] out Set to number of bytes of the string element
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetSymbolicDimensions()
Get symbolic dimension names in OrtTensorTypeAndShapeInfo.
- Parameters
-
[in] info [in] dim_params Array with dim_params_lengthelements. On return filled with pointers to null terminated strings of the dimension names[in] dim_params_length Number of elements in dim_params. Use OrtApi::GetDimensionsCount to get this value
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTensorData()
Get a const pointer to the raw data inside a tensor.
Used to read the internal tensor data directly.
- Note
- The returned pointer is valid until the OrtValue is destroyed.
- Parameters
-
[in] value A tensor type (string tensors are not supported) [out] out Filled in with a pointer to the internal storage
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ GetTensorElementType()
◆ GetTensorElementTypeAndShapeDataReference()
Get the element data type and shape for an OrtValue that represents a Tensor (scalar, dense, or sparse).
- Note
- This function is an alternative to GetTensorTypeAndShape() that does not allocate a new array for the shape data. The OrtValue instance's internal shape data is returned directly.
- Returns an error if the underlying OrtValue is not a Tensor.
- Parameters
-
[in] value The OrtValue instance. [out] elem_type Output parameter set to the tensor element data type. [out] shape_data Output parameter set to the OrtValue instance's internal shape data array. For a scalar, shape_datais NULL andshape_data_countis 0. Must not be released as it is owned by the OrtValue instance. This pointer becomes invalid when the OrtValue is released or if the underlying shape data is updated or reallocated.[out] shape_data_count Output parameter set to the number of elements in shape_data.shape_data_countis 0 for a scalar.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ GetTensorMemoryInfo()
Returns a pointer to the OrtMemoryInfo of a Tensor.
- Parameters
-
[in] value OrtValue containing tensor. [out] mem_info OrtMemoryInfo of the tensor. Do NOT free the returned pointer. It is valid for the lifetime of the OrtValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTensorMutableData()
Get a pointer to the raw data inside a tensor.
Used to read/write/modify the internal tensor data directly.
- Note
- The returned pointer is valid until the
valueis destroyed.
- Parameters
-
[in] value A tensor type (string tensors are not supported) [out] out Filled in with a pointer to the internal storage
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTensorRTProviderOptionsAsString()
Get serialized TensorRT provider options string.
For example, "trt_max_workspace_size=2147483648;trt_max_partition_iterations=10;trt_int8_enable=1;......"
- Parameters
-
tensorrt_options - OrtTensorRTProviderOptionsV2 instance allocator - a ptr to an instance of OrtAllocator obtained with OrtApi::CreateAllocator or OrtApi::GetAllocatorWithDefaultOptions the specified allocator will be used to allocate continuous buffers for output strings and lengths. ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTensorRTProviderOptionsByName()
Get TensorRT EP provider option where its data type is pointer. If the data type of the provider option can be represented by string please use GetTensorRTProviderOptionsAsString.
- Parameters
-
tensorrt_options - OrtTensorRTProviderOptionsV2 instance key - Name of the provider option ptr - A pointer to the instance that is kept by the provider option
- Since
- Version 1.16.
◆ GetTensorShapeElementCount()
Get total number of elements in a tensor shape from an OrtTensorTypeAndShapeInfo.
Return the number of elements specified by the tensor shape (all dimensions multiplied by each other). For 0 dimensions, 1 is returned. If any dimension is less than 0, the result is always -1.
Examples:
[] = 1
[1,3,4] = 12
[2,0,4] = 0
[-1,3,4] = -1
- Parameters
-
[in] info [out] out Number of elements
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTensorSizeInBytes()
Compute total size in bytes of the tensor data contained in an OrtValue.
Returns the total number of bytes used to store the tensor data. For numeric tensors, this is sizeof(element_type) * total_element_count. OrtValues that are not tensors or that are tensors that contain strings will cause an error to be returned.
- Parameters
-
[in] ort_value OrtValue instance containing a tensor [out] size The total size of the tensor data in bytes
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ GetTensorTypeAndShape()
Get type and shape information from a tensor OrtValue.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetTypeInfo()
Get type information of an OrtValue.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetValue()
Get non tensor data from an OrtValue.
If value is of type ONNX_TYPE_MAP, you need to retrieve the keys and values separately. Use index=0 to retrieve keys and index=1 to retrieve values. If value is of type ONNX_TYPE_SEQUENCE, use index to retrieve the index'th element of the sequence.
- Parameters
-
[in] value [in] index See above for usage based on valuetype[in] allocator Allocator used to allocate OrtValue [out] out Created OrtValue that holds the element requested. Must be freed with OrtApi::ReleaseValue
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetValueCount()
Get non tensor value count from an OrtValue.
If value is of type ONNX_TYPE_MAP 2 will always be returned. For ONNX_TYPE_SEQUENCE the number of elements in the sequence will be returned
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ GetValueInfoName()
Get the value name from an OrtValueInfo instance.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] name The name of the OrtValueInfo - Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ GetValueInfoTypeInfo()
Get the type information from an OrtValueInfo instance.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] type_info The type info of the OrtValueInfo - Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ GetValueType()
Get ONNXType of an OrtValue.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ Graph_GetGraphView()
Returns an OrtGraph that contains a subset of nodes in the source OrtGraph.
- Note
- The lifetime of "dst_graph" is tied to that of "src_graph", as they both internally reference the same underlying graph. "dst_graph" preserves the input order of "src_graph", and its output order corresponds to the outputs produced by the nodes in "nodes" with the given order.
- Parameters
-
[in] src_graph The source OrtGraph instance. [in] nodes A subset of the nodes/OrtNodes in 'graph'. [in] num_nodes Number of nodes. [out] dst_graph An OrtGraph created from a given set of nodes. Must be released by calling ReleaseGraph.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetInitializers()
Returns the graph's initializers as OrtValueInfo instances.
Includes constant and non-constant initializers.
For ONNX IR version < 4, all initializers are constant.
For ONNX IR version >= 4, an initializer with a name that matches a graph input is considered a non-constant initializer.
Call ValueInfo_GetInitializerValue to get the initializer's data.
- Parameters
-
[in] graph The OrtGraph instance. [out] initializers Pre-allocated array of num_outputselements that is filled with the initializers.[in] num_initializers The size of the initializersarray. Typical usage sets this to the result of Graph_GetNumInitializers(). An error status is returned ifnum_initializersis less than the number of graph initializers.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetInputs()
Returns the graph's inputs as OrtValueInfo instances.
- Note
- The result includes initializers that are included in the list of graph inputs.
- Parameters
-
[in] graph The OrtGraph instance. [out] inputs Pre-allocated array of num_inputselements that is filled with the graph's inputs.[in] num_inputs The size of the inputsarray. Typical usage sets this to the result of Graph_GetNumInputs(). An error status is returned ifnum_inputsis less than the number of graph inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetModelMetadata()
◆ Graph_GetModelPath()
Get the filepath to the model from which an OrtGraph is constructed.
- Note
- The model's filepath is empty if the filepath is unknown, such as when the model is loaded from bytes via CreateSessionFromArray.
- Parameters
-
[in] graph The OrtGraph instance. [out] model_path Output parameter set to the model's null-terminated filepath. Set to an empty path string if unknown.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetName()
Returns a graph's name.
- Parameters
-
[in] graph The OrtGraph instance. [out] graph_name Output parameter set to the graph's name.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNodes()
Returns the graph's nodes as OrtNode instances.
The nodes are sorted using a stable topological ordering. Callers are responsible for maintaining their own node ordering if a different order is required.
- Parameters
-
[in] graph The OrtGraph instance. [out] nodes Pre-allocated array of num_nodeselements that is filled with the graph's nodes.[in] num_nodes The size of the nodesarray. Typical usage sets this to the result of Graph_GetNumNodes(). An error status is returned ifnum_nodesis less than the number of graph nodes.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNumInitializers()
Returns the number of graph initializers.
Counts constant and non-constant initializers.
- Parameters
-
[in] graph The OrtGraph instance. [out] num_initializers Output parameter set to the number of graph initializers.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNumInputs()
Returns the number of graph inputs.
- Note
- The count includes initializers that are included in the list of graph inputs.
- Parameters
-
[in] graph The OrtGraph instance. [out] num_inputs Output parameter set to the number of graph inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNumNodes()
Returns the number of graph nodes.
- Parameters
-
[in] graph The OrtGraph instance. [out] num_nodes Output parameter set to the number of graph nodes.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNumOperatorSets()
Returns the number of operator sets that the graph's model uses.
- Note
- An operator set is uniquely identified by the (domain, opset_version) pair. All models must have at least one entry that specifies which entry of the ONNX operator set is used. The ONNX domain is represented by an empty string.
- Parameters
-
[in] graph The OrtGraph instance. [out] num_operator_sets Output parameter set to the number of operator sets that the graph's model uses.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetNumOutputs()
Returns the number of graph outputs.
- Parameters
-
[in] graph The OrtGraph instance. [out] num_outputs Output parameter set to the number of graph outputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetOnnxIRVersion()
Returns the ONNX IR version.
- Parameters
-
[in] graph The OrtGraph instance. [out] onnx_ir_version Output parameter set to the ONNX IR version.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetOperatorSets()
| OrtStatus * OrtApi::Graph_GetOperatorSets | ( | const OrtGraph * | graph, |
| const char ** | domains, | ||
| int64_t * | opset_versions, | ||
| size_t | num_operator_sets | ||
| ) |
Returns the operator sets that the graph's model uses.
- Note
- An operator set is uniquely identified by the (domain, opset_version) pair. All models must have at least one entry that specifies which entry of the ONNX operator set is used. The ONNX domain is represented by an empty string.
- Parameters
-
[in] graph The OrtGraph instance. [out] domains Pre-allocated array of num_operator_setselements that is filled with null-terminated domain names.[out] opset_versions Pre-allocated array of num_operator_setselements that is filled with the opset version of the corresponding domain in thedomainsarray.[in] num_operator_sets The size of the domainsandopset_versionsarrays. Typical usage sets this to the result of Graph_GetNumOperatorSets(). An error status is returned ifnum_operator_setsis less than the actual number of operator sets.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetOutputs()
Returns the graph's outputs as OrtValueInfo instances.
- Parameters
-
[in] graph The OrtGraph instance. [out] outputs Pre-allocated array of num_outputselements that is filled with the graph's outputs.[in] num_outputs The size of the outputsarray. Typical usage sets this to the result of Graph_GetNumOutputs(). An error status is returned ifnum_outputsis less than the number of graph outputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Graph_GetParentNode()
Get the parent node for the given graph, if any exists.
Certain operator types (e.g., If and Loop) contain nested subgraphs. This function enables access to the parent node (e.g., the If and Loop node) from a nested subgraph.
- Parameters
-
[in] graph The OrtGraph instance. [out] node Output parameter that is set to the graph's parent node. Set to NULL if a parent node does not exist (e.g., for a top-level graph).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ HasSessionConfigEntry()
Checks if the given session configuration entry exists.
The config_key formats are defined in onnxruntime_session_options_config_keys.h
Can be used in a custom operator library to check for session configuration entries that target one or more custom operators in the library. Example: The config entry custom_op.myop.some_key targets a custom op named "myop".
- Parameters
-
[in] options The OrtSessionOptions instance. [in] config_key A null-terminated UTF-8 string representation of the configuration key. [out] out Pointer set to 1 if the entry exists and 0 otherwise.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ HasValue()
Sets out to 1 iff an optional type OrtValue has an element, 0 otherwise (OrtValue is None) Use this API to find if the optional type OrtValue is None or not. If the optional type OrtValue is not None, use the OrtValue just like any other OrtValue. For example, if you get an OrtValue that corresponds to Optional(tensor) and if HasValue() returns true, use it as tensor and so on.
- Parameters
-
[in] value Input OrtValue. [out] out indicating if the input OrtValue contains data (1) or if it is a None (0)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ InvokeOp()
: Invoke the operator created by OrtApi::CreateOp The inputs must follow the order as specified in onnx specification
- Parameters
-
[in] context Kernel context [in] ort_op Operator that has been created [in] input_values Array of inputs [in] input_count Number of inputs [in] output_values Array of outputs [in] output_count Number of outputs
- Since
- Version 1.12.
◆ IsSparseTensor()
Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise.
- Parameters
-
[in] value existing OrtValue [out] out unless an error occurs, contains 1 iff the value contains an instance of sparse tensor or 0 otherwise.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ IsTensor()
Return if an OrtValue is a tensor type.
- Parameters
-
[in] value A tensor type (string tensors are not supported) [out] out Set to 1 iff OrtValue is a tensor, 0 otherwise
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelContext_GetAllocator()
Get Allocator from KernelContext for a specific memoryInfo. Please use C API ReleaseAllocator to release out object.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ KernelContext_GetGPUComputeStream()
Used for custom operators, gets the GPU compute stream to use to launch the custom a GPU kernel.
- See also
- OrtCustomOp
- Parameters
-
[in] context OrtKernelContext instance [out] out Returns pointer to a GPU compute stream that can be used to launch the custom GPU kernel. If retrieving the GPU compute stream is not relevant (GPU not enabled in the build, kernel partitioned to some other EP), then a nullptr is returned as the output param. Do not free or mutate the returned pointer as it refers to internal data owned by the underlying session. Only use it for custom kernel launching.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelContext_GetInput()
Used for custom operators, get an input of a kernel.
The function attempts fetches the input of the kernel. If the input is optional and not present, the function returns success and out is set to nullptr.
- Parameters
-
[in] context OrtKernelContext instance [in] index See KernelContext_GetInputCount for boundaries check. [out] out OrtValue if the input is present otherwise is set nullptr
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelContext_GetInputCount()
Used for custom operators, get the input count of a kernel.
- See also
- OrtCustomOp
◆ KernelContext_GetLogger()
Get the runtime logger from OrtKernelContext.
Used in the KernelCompute callback of an OrtCustomOp to get a logger that can be used to log messages during inference.
- Parameters
-
[in] context An instance of OrtKernelContext. [out] logger Pointer set to the kernel context's OrtLogger. Owned by ONNX Runtime, so do not free.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15
◆ KernelContext_GetOutput()
Used for custom operators, get an output of a kernel.
The function attempts fetches the output of the kernel. If the output is optional and not present, the function returns success and out is set to nullptr.
- Parameters
-
[in] context OrtKernelContext instance [in] index See KernelContext_GetOutputCount for boundaries check. [in] dim_values output dimensions [in] dim_count number of dimensions [out] out a ptr to OrtValue to output otherwise set to nullptr
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelContext_GetOutputCount()
Used for custom operators, get the output count of a kernel.
- See also
- OrtCustomOp
◆ KernelContext_GetResource()
| OrtStatus * OrtApi::KernelContext_GetResource | ( | const OrtKernelContext * | context, |
| int | resource_version, | ||
| int | resource_id, | ||
| void ** | resource | ||
| ) |
Get a EP resource. E.g. a cuda stream or a cublas handle
- Parameters
-
context - Kernel context resource_version - Version of the resource resource_id - Type of resource resource - A pointer to returned resource
- Since
- Version 1.16.
◆ KernelContext_GetScratchBuffer()
Get scratch buffer from the corresponding allocator under the specific OrtMemoryInfo object. NOTE: callers are responsible to release this scratch buffer from the corresponding allocator.
- Parameters
-
[in] context OrtKernelContext instance [in] mem_info OrtMemoryInfo instance [in] count_or_bytes How many bytes is this scratch buffer [out] out A pointer to the scratch buffer
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.18.
◆ KernelContext_ParallelFor()
| OrtStatus * OrtApi::KernelContext_ParallelFor | ( | const OrtKernelContext * | context, |
| void(*)(void *, size_t) | fn, | ||
| size_t | total, | ||
| size_t | num_batch, | ||
| void * | usr_data | ||
| ) |
Run fn in parallel
- Parameters
-
[in] context [in] fn Function accepting usr_data and an integer as iterator [in] total The number of times fn is to be invoked [in] num_batch Number of batches by which the "total" is to be divided in maximum. When zero, there is no limit [in] usr_data User data to be passed back to fn
- Since
- Version 1.17.
◆ KernelInfo_GetConfigEntries()
Get all config entries from OrtKernelInfo.
Gets all configuration entries from the OrtKernelInfo object as key-value pairs. Config entries are set on the OrtSessionOptions and are accessible in custom operator kernels.
Used in the CreateKernel callback of an OrtCustomOp to access all session configuration entries during kernel construction.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ KernelInfo_GetInputCount()
Get the number of inputs from OrtKernelInfo.
Used in the CreateKernel callback of an OrtCustomOp to query the number of inputs during kernel/session creation.
- Parameters
-
[in] info Instance of OrtKernelInfo. [out] out Pointer to variable assigned with the result on success.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfo_GetInputName()
| OrtStatus * OrtApi::KernelInfo_GetInputName | ( | const OrtKernelInfo * | info, |
| size_t | index, | ||
| char * | out, | ||
| size_t * | size | ||
| ) |
Get the name of a OrtKernelInfo's input.
Used in the CreateKernel callback of an OrtCustomOp to query an input's name during kernel/session creation.
If out is nullptr, the value of size is set to the size of the name string (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the name string's size and out is not nullptr, the value of size is set to the true size of the string (including null-terminator), the provided memory is filled with the string's contents, and a success status is returned.
If the size parameter is less than the actual string's size and out is not nullptr, the value of size is set to the true size of the string and a failure status is returned.
- Parameters
-
[in] info An instance of OrtKernelInfo. [in] index The index of the input name to get. Returns a failure status if out-of-bounds. [out] out Memory location into which to write the UTF-8 null-terminated string representing the input's name. [in,out] size Pointer to the size of the outbuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfo_GetInputTypeInfo()
Get the type information for a OrtKernelInfo's input.
Used in the CreateKernel callback of an OrtCustomOp to query the shape and type information of an input during kernel/session creation.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfo_GetLogger()
Get the session logger from OrtKernelInfo.
Used in the CreateKernel callback of an OrtCustomOp to get a logger that can be used to log messages.
- Parameters
-
[in] info An instance of OrtKernelInfo. [out] logger Pointer set to the session's OrtLogger. Owned by ONNX Runtime, so do not free.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15
◆ KernelInfo_GetNodeName()
Get the graph node name from OrtKernelInfo.
If out is nullptr, the value of size is set to the size of the name string (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the name string's size and out is not nullptr, the value of size is set to the true size of the string (including null-terminator), the provided memory is filled with the string's contents, and a success status is returned.
If the size parameter is less than the actual string's size and out is not nullptr, the value of size is set to the true size of the string and a failure status is returned.
Can be used in a custom operator's CreateKernel callback to get the name of the operator's node name in the graph.
- Parameters
-
[in] info An instance of OrtKernelInfo. [out] out Memory location into which to write the UTF-8 null-terminated string representing the name. [in,out] size Pointer to the size of the outbuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15
◆ KernelInfo_GetOperatorDomain()
Get the graph node's operator domain from OrtKernelInfo.
If out is nullptr, the value of size is set to the size of the operator domain string (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the string's size and out is not nullptr, the value of size is set to the true size of the string (including null-terminator), the provided memory is filled with the string's contents, and a success status is returned.
If the size parameter is less than the actual string's size and out is not nullptr, the value of size is set to the true size of the string and a failure status with error code ORT_INVALID_ARGUMENT is returned.
- Parameters
-
[in] info An instance of OrtKernelInfo. [out] out Memory location into which to write the UTF-8 null-terminated string representing the operator domain. [in,out] size Pointer to the size of the outbuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ KernelInfo_GetOperatorSinceVersion()
Get the opset version in which the given node's operator type was first defined from OrtKernelInfo.
- Parameters
-
[in] info An instance of OrtKernelInfo. [out] since_version The opset version in which the node's operator type was first defined.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ KernelInfo_GetOperatorType()
Get the graph node's operator type from OrtKernelInfo.
If out is nullptr, the value of size is set to the size of the operator type string (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the string's size and out is not nullptr, the value of size is set to the true size of the string (including null-terminator), the provided memory is filled with the string's contents, and a success status is returned.
If the size parameter is less than the actual string's size and out is not nullptr, the value of size is set to the true size of the string and a failure status with error code ORT_INVALID_ARGUMENT is returned.
- Parameters
-
[in] info An instance of OrtKernelInfo. [out] out Memory location into which to write the UTF-8 null-terminated string representing the operator type. [in,out] size Pointer to the size of the outbuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ KernelInfo_GetOutputCount()
Get the number of outputs from OrtKernelInfo.
Used in the CreateKernel callback of an OrtCustomOp to query the number of outputs during kernel/session creation.
- Parameters
-
[in] info Instance of OrtKernelInfo. [out] out Pointer to variable assigned with the result on success.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfo_GetOutputName()
| OrtStatus * OrtApi::KernelInfo_GetOutputName | ( | const OrtKernelInfo * | info, |
| size_t | index, | ||
| char * | out, | ||
| size_t * | size | ||
| ) |
Get the name of a OrtKernelInfo's output.
Used in the CreateKernel callback of an OrtCustomOp to query an output's name during kernel/session creation.
If out is nullptr, the value of size is set to the size of the name string (including null-terminator), and a success status is returned.
If the size parameter is greater than or equal to the name string's size and out is not nullptr, the value of size is set to the true size of the string (including null-terminator), the provided memory is filled with the string's contents, and a success status is returned.
If the size parameter is less than the actual string's size and out is not nullptr, the value of size is set to the true size of the string and a failure status is returned.
- Parameters
-
[in] info An instance of OrtKernelInfo. [in] index The index of the output name to get. Returns a failure status if out-of-bounds. [out] out Memory location into which to write the UTF-8 null-terminated string representing the output's name. [in,out] size Pointer to the size of the outbuffer. See above comments for details.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfo_GetOutputTypeInfo()
Get the type information for a OrtKernelInfo's output.
Used in the CreateKernel callback of an OrtCustomOp to query the shape and type information of an output during kernel/session creation.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ KernelInfoGetAllocator()
Get allocator from KernelInfo for a specific memory type. Please use C API ReleaseAllocator to release out object.
- Parameters
-
[in] info OrtKernelInfo instance [in] mem_type OrtMemType object [out] out A pointer to OrtAllocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.18.
◆ KernelInfoGetAttribute_float()
| OrtStatus * OrtApi::KernelInfoGetAttribute_float | ( | const OrtKernelInfo * | info, |
| const char * | name, | ||
| float * | out | ||
| ) |
Get a float stored as an attribute in the graph node.
- Parameters
-
[in] info OrtKernelInfo instance [in] name Null terminated string of the name of the attribute [out] out Pointer to memory where the attribute will be stored
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetAttribute_int64()
| OrtStatus * OrtApi::KernelInfoGetAttribute_int64 | ( | const OrtKernelInfo * | info, |
| const char * | name, | ||
| int64_t * | out | ||
| ) |
Fetch a 64-bit int stored as an attribute in the graph node.
- Parameters
-
[in] info OrtKernelInfo instance [in] name Null terminated string of the name of the attribute [out] out Pointer to memory where the attribute will be stored
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetAttribute_string()
| OrtStatus * OrtApi::KernelInfoGetAttribute_string | ( | const OrtKernelInfo * | info, |
| const char * | name, | ||
| char * | out, | ||
| size_t * | size | ||
| ) |
Fetch a string stored as an attribute in the graph node.
If out is nullptr, the value of size is set to the true size of the string attribute, and a success status is returned.
If the size parameter is greater than or equal to the actual string attribute's size, the value of size is set to the true size of the string attribute, the provided memory is filled with the attribute's contents, and a success status is returned.
If the size parameter is less than the actual string attribute's size and out is not nullptr, the value of size is set to the true size of the string attribute and a failure status is returned.)
- Parameters
-
[in] info OrtKernelInfo instance [in] name Null terminated string of the name of the attribute [out] out Pointer to memory where the attribute will be stored [in,out] size See above comments for details
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetAttribute_tensor()
Get a OrtValue tensor stored as an attribute in the graph node.
Used in the CreateKernel callback of an OrtCustomOp to get a tensor attribute.
- Parameters
-
[in] info OrtKernelInfo instance. [in] name UTF-8 null-terminated string representing the attribute's name. [in] allocator Allocator used to allocate the internal tensor state. [out] out Returns newly created OrtValue. Must be freed with OrtApi::ReleaseValue, which will also free internal tensor state allocated with the provided allocator.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetAttributeArray_float()
| OrtStatus * OrtApi::KernelInfoGetAttributeArray_float | ( | const OrtKernelInfo * | info, |
| const char * | name, | ||
| float * | out, | ||
| size_t * | size | ||
| ) |
Fetch an array of int64_t values stored as an attribute in the graph node.
If out is nullptr, the value of size is set to the true size of the attribute array's size, and a success status is returned.
If the size parameter is greater than or equal to the actual attribute array's size, the value of size is set to the true size of the attribute array's size, the provided memory is filled with the attribute's contents, and a success status is returned.
If the size parameter is less than the actual attribute array's size and out is not nullptr, the value of size is set to the true size of the attribute array's size and a failure status is returned.)
- Parameters
-
[in] info instance [in] name name of the attribute to be parsed [out] out pointer to memory where the attribute's contents are to be stored [in,out] size actual size of attribute array
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetAttributeArray_int64()
| OrtStatus * OrtApi::KernelInfoGetAttributeArray_int64 | ( | const OrtKernelInfo * | info, |
| const char * | name, | ||
| int64_t * | out, | ||
| size_t * | size | ||
| ) |
Fetch an array of int64_t values stored as an attribute in the graph node.
If out is nullptr, the value of size is set to the true size of the attribute array's size, and a success status is returned.
If the size parameter is greater than or equal to the actual attribute array's size, the value of size is set to the true size of the attribute array's size, the provided memory is filled with the attribute's contents, and a success status is returned.
If the size parameter is less than the actual attribute array's size and out is not nullptr, the value of size is set to the true size of the attribute array's size and a failure status is returned.)
- Parameters
-
[in] info instance [in] name name of the attribute to be parsed [out] out pointer to memory where the attribute's contents are to be stored [in,out] size actual size of attribute array
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ KernelInfoGetConstantInput_tensor()
Get a OrtValue tensor stored as a constant initializer in the graph node.
Used in the CreateKernel callback of an OrtCustomOp to get a tensor value.
- Parameters
-
[in] info OrtKernelInfo instance. [in] index The node index. [out] is_constant Is it a constant node input or not. [out] out The OrtValue tensor value.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ Logger_GetLoggingSeverityLevel()
Get the logging severity level of the OrtLogger.
Can be used in a custom operator to get the logging severity level of the OrtLogger associated with the OrtKernelInfo.
- Parameters
-
[in] logger The OrtLogger instance. [out] out Pointer to variable assigned with the logging severity level on success.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15
◆ Logger_LogMessage()
| OrtStatus * OrtApi::Logger_LogMessage | ( | const OrtLogger * | logger, |
| OrtLoggingLevel | log_severity_level, | ||
| const char * | message, | ||
| const char * | file_path, | ||
| int | line_number, | ||
| const char * | func_name | ||
| ) |
Logs a message at the given severity level using the provided OrtLogger.
Only messages with a severity level equal or greater than the OrtLogger's logging severity level are logged. Use OrtApi::Logger_GetLoggingSeverityLevel to get the OrtLogger's logging severity level.
Can be used in custom operators to log messages with the logger retrieved via OrtApi::KernelInfo_GetLogger.
- Parameters
-
[in] logger The OrtLogger instance. [in] log_severity_level The message's severity level. [in] message The message to log. [in] file_path The filepath of the file in which the message is logged. Usually the value of ORT_FILE. [in] line_number The file line number in which the message is logged. Usually the value of LINE. [in] func_name The name of the function in which the message is logged. Usually the value of FUNCTION.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15
◆ MemoryInfoGetId()
◆ MemoryInfoGetMemType()
◆ MemoryInfoGetName()
Get name from OrtMemoryInfo.
- Parameters
-
[in] ptr [out] out Writes null terminated string to this pointer. Do NOT free the returned pointer. It is valid for the lifetime of the OrtMemoryInfo
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ MemoryInfoGetType()
◆ ModelMetadataGetCustomMetadataMapKeys()
- Parameters
-
[in] model_metadata [in] allocator [out] keys Array of null terminated strings (array count = num_keys) allocated using allocator. The strings and the pointer array must be freed usingallocatorkeyswill be set to nullptr if the custom metadata map is empty.[out] num_keys Set to the number of elements in the keysarray
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetDescription()
Get description from an OrtModelMetadata.
- Parameters
-
[in] model_metadata [in] allocator [out] value Set to a null terminated string allocated using allocator. Must be freed usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetDomain()
Get domain from an OrtModelMetadata.
- Parameters
-
[in] model_metadata [in] allocator [out] value Set to a null terminated string allocated using allocator. Must be freed usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetGraphDescription()
Use this to obtain the description of the graph present in the model (doc_string field of the GraphProto message within the ModelProto message). If it doesn't exist, an empty string will be returned.
- Parameters
-
[in] model_metadata An instance of OrtModelMetadata [in] allocator Allocator used to allocate the string that will be returned back [out] value Set to a null terminated string allocated using allocator. The caller is responsible for freeing it usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetGraphName()
Get graph name from an OrtModelMetadata.
- Parameters
-
[in] model_metadata [in] allocator [out] value Set to a null terminated string allocated using allocator. Must be freed usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetProducerName()
Get producer name from an OrtModelMetadata.
- Parameters
-
[in] model_metadata [in] allocator [out] value Set to a null terminated string allocated using allocator. Must be freed usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataGetVersion()
Get version number from an OrtModelMetadata.
- Parameters
-
[in] model_metadata [out] value Set to the version number
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ModelMetadataLookupCustomMetadataMap()
Return data for a key in the custom metadata map in an OrtModelMetadata.
- Parameters
-
[in] model_metadata [in] allocator [in] key Null terminated string [out] value Set to a null terminated string allocated using allocator. Must be freed usingallocatorvaluewill be set to nullptr if the given key is not found in the custom metadata map.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ Node_GetAttributeByName()
| OrtStatus * OrtApi::Node_GetAttributeByName | ( | const OrtNode * | node, |
| const char * | attribute_name, | ||
| const OrtOpAttr ** | attribute | ||
| ) |
Gets the OrtNode's attribute as OrtOpAttr by name.
- Parameters
-
[in] node The OrtNode instance. [in] attribute_name The name of the attribute [out] attribute Output parameter set to the OrtOpAttr instance if an attribute by the given name exists. For an unset optional attribute, attributeis set to NULL and a non-error status is returned. For an invalid attribute name,attributeis set to NULL and an error status with code ORT_NOT_FOUND is returned.
- Note
- ONNX Runtime automatically sets optional (unset) attributes to their default values if the default value is a constant expression that does not depend on other tensor/model characteristics. Conv's 'kernel_shape' attribute is an example of an optional attribute that does not have a constant default value. This function does not provide any unset optional attributes without a constant default value.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetAttributes()
Returns a node's attributes as OrtOpAttr instances.
- Parameters
-
[in] node The OrtNode instance. [out] attributes Pre-allocated array of num_attributeselements that is filled with the node's attributes.[in] num_attributes The size of the num_attributesarray. Typical usage sets this to the result of Node_GetNumAttributes(). An error status is returned ifnum_attributesis less than the number of node attributes.
- Note
- ONNX Runtime automatically sets optional (unset) attributes to their default values if the default value is a constant expression that does not depend on other tensor/model characteristics. Conv's 'kernel_shape' attribute is an example of an optional attribute that does not have a constant default value. This function does not provide any unset optional attributes without a constant default value.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetDomain()
Returns a node's domain name.
- Parameters
-
[in] node The OrtNode instance. [out] domain_name Output parameter set to the node's domain name.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetEpName()
Returns the execution provider name that this node is assigned to run on. Returns NULL if the node has not been assigned to any execution provider yet. For plugin execution providers, the name is the one returned by OrtEp::GetName.
- Parameters
-
[in] node The OrtNode instance. [out] out Output execution provider type and can be NULL if node has not been assigned.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetGraph()
Get the node's parent OrtGraph instance.
Can return NULL if the OrtNode was created without an owning graph. In another case, this API may also return NULL if node is obtained by calling Graph_GetParentNode() on an OrtGraph that is a subgraph of a control-flow op, and the parent graph has not been created yet, for example during ORT's GetCapability() when processing the innermost subgraph.
- Parameters
-
[in] node The OrtNode instance. [out] graph Output parameter set to the node's OrtGraph. Can be set to NULL if the node is not currently contained by a graph.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetId()
Returns a node's identifier.
The node's identifier is only unique in the node's parent graph. Different nested subgraphs (e.g., subgraphs contained by If and Loop nodes) may reuse identifiers.
- Parameters
-
[in] node The OrtNode instance. [out] node_id Output parameter set to the node's identifier.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetImplicitInputs()
Get the implicit inputs, as OrtValueInfo instances, that are used within the given node's subgraphs.
- Note
- Only certain operator types (e.g., If and Loop) contain nested subgraphs. The internal nodes within the nested subgraphs may use values from the outer scope. Those "outer scope" values are considered implicit inputs to the node that contains the subgraphs (e.g., the If or Loop node).
- Parameters
-
[in] node The OrtNode instance. [out] implicit_inputs Pre-allocated array of num_implicit_inputselements that is filled the node's implicit inputs.[in] num_implicit_inputs The size of the implicit_inputsarray. Typical usage sets this to the result of Node_GetNumImplicitInputs(). An error status is returned ifnum_implicit_inputsis less than the number of node implicit inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetInputs()
Returns the node's inputs as OrtValueInfo instances.
- Parameters
-
[in] node The OrtNode instance. [out] inputs Pre-allocated array of num_inputselements that is filled with the node's inputs.[in] num_inputs The size of the inputsarray. Typical usage sets this to the result of Node_GetNumInputs(). An error status is returned ifnum_inputsis less than the number of node inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetName()
Returns a node's name. Can be an empty string.
- Parameters
-
[in] node The OrtNode instance. [out] node_name Output parameter set to the node's name.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetNumAttributes()
Returns the number of node attributes.
- Parameters
-
[in] node The OrtNode instance. [out] num_attributes Output parameter set to the number of node attributes.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetNumImplicitInputs()
| OrtStatus * OrtApi::Node_GetNumImplicitInputs | ( | const OrtNode * | node, |
| size_t * | num_implicit_inputs | ||
| ) |
Returns the number of node implicit inputs.
Certain operator types (e.g., If and Loop) contain nested subgraphs. The internal nodes within the nested subgraphs may use values from the outer scope. Those "outer scope" values are considered implicit inputs to the node that contains the subgraphs (e.g., the If or Loop node).
- Parameters
-
[in] node The OrtNode instance. [out] num_implicit_inputs Output parameter set to the number of node implicit inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetNumInputs()
Returns the number of node inputs.
- Parameters
-
[in] node The OrtNode instance. [out] num_inputs Output parameter set to the number of node inputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetNumOutputs()
Returns the number of node outputs.
- Parameters
-
[in] node The OrtNode instance. [out] num_outputs Output parameter set to the number of node outputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetNumSubgraphs()
Returns the number of subgraphs contained by the given node.
- Note
- Only certain operator types (e.g., If and Loop) contain nested subgraphs.
- Parameters
-
[in] node The OrtNode instance. [out] num_subgraphs Output parameter set to the number of node subgraphs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetOperatorType()
Returns a node's operator type (e.g., "Conv").
- Parameters
-
[in] node The OrtNode instance. [out] operator_type Output parameter set to the name of the node's operator type.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetOutputs()
Returns the node's outputs as OrtValueInfo instances.
- Parameters
-
[in] node The OrtNode instance. [out] outputs Pre-allocated array of num_outputselements that is filled with the node's outputs.[in] num_outputs The size of the outputsarray. Typical usage sets this to the result of Node_GetNumOutputs(). An error status is returned ifnum_outputsis less than the number of node outputs.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetSinceVersion()
Get the opset version in which the given node's operator type was first defined.
- Parameters
-
[in] node The OrtNode instance. [out] since_version The opset version in which the node's operator type was first defined.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ Node_GetSubgraphs()
| OrtStatus * OrtApi::Node_GetSubgraphs | ( | const OrtNode * | node, |
| const OrtGraph ** | subgraphs, | ||
| size_t | num_subgraphs, | ||
| const char ** | attribute_names | ||
| ) |
Get the subgraphs, as OrtGraph instances, contained by the given node.
- Note
- Only certain operator types (e.g., If and Loop) contain nested subgraphs. ONNX nodes store subgraphs in their attributes, however, this function must be used to obtain subgraphs from an OrtNode.
- Parameters
-
[in] node The OrtNode instance. [out] subgraphs Pre-allocated array of num_subgraphselements that is filled with the node's subgraphs.[in] num_subgraphs The size of the num_subgraphsarray. Typical usage sets this to the result of Node_GetNumSubgraphs(). An error status is returned ifnum_subgraphsis less than the number of node subgraphs.[out] attribute_names Optional pre-allocated array of num_subgraphselements that is filled with the attribute names that correspond to the subgraphs. Ignored if set to NULL.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ OpAttr_GetName()
Get the attribute name from an OrtOpAttr.
- Parameters
-
[in] attribute The OrtOpAttr instance. [out] name Output parameter set to the attribute's name. The name is a null-terminated string.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ OpAttr_GetTensorAttributeAsOrtValue()
Get the OrtNode's 'TENSOR' attribute as an OrtValue.
- Parameters
-
[in] attribute The OrtOpAttr instance. [out] attr_tensor If successful, contains the 'TENSOR' attribute as a newly created OrtValue. Must be freed with OrtApi::ReleaseValue.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ OpAttr_GetType()
Get the attribute type as OrtOpAttrType from an OrtOpAttr.
- Parameters
-
[in] attribute The OrtOpAttr instance. [out] type Output the attribute type as OrtOpAttrType.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ReadOpAttr()
Read contents of an attribute to data
- Parameters
-
[in] op_attr [in] type Attribute type [out] data Memory address to save raw content of the attribute [in] len Number of bytes allowed to store in data [out] out Number of bytes required to save the data when the call failed, or the real number of bytes saved to data on success
- Note
- Does not support reading graph attributes. Refer to Node_GetSubgraphs.
- Since
- Version 1.17.
◆ RegisterAllocator()
Register a custom allocator.
Enables sharing between multiple sessions that use the same env instance. Returns an error if an allocator with the same OrtMemoryInfo is already registered.
The behavior of this is exactly the same as OrtApi::CreateAndRegisterAllocator except instead of ORT creating an allocator based on provided info, in this case ORT uses the user-provided custom allocator. See https://onnxruntime.ai/docs/get-started/with-c.html for details.
- Parameters
-
[in] env [in] allocator User provided allocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RegisterCustomOpsLibrary()
Registers custom ops from a shared library.
Loads a shared library (dll on windows, so on linux, etc) named 'library_path' and looks for this entry point: OrtStatus* RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); It then passes in the provided session options to this function along with the api base. The handle to the loaded library is returned in library_handle. It can be freed by the caller after all sessions using the passed in session options are destroyed, or if an error occurs and it is non null.
- Parameters
-
[in] options [in] library_path [out] library_handle OS specific handle to the loaded library (Use FreeLibrary on Windows, dlclose on Linux, etc.. to unload)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RegisterCustomOpsLibrary_V2()
Register custom ops from a shared library.
Loads a shared library (.dll on windows, .so on linux, etc) named 'library_name' and looks for this entry point: OrtStatus* RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); It then passes in the provided session options to this function along with the api base.
The handle to the loaded library is automatically released by ORT when the last OrtSession that references the library handle is released. If no OrtSession is created, then the library handle is released when the provided OrtSessionOptions is released.
- Parameters
-
[in] options The session options. [in] library_name The name of the shared library to load and register. Refer to OS-specific dynamic library loading utilities (e.g., LoadLibraryEx on Windows or dlopen on Linux/MacOS) for information on the format of library names and search paths.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ RegisterCustomOpsUsingFunction()
Register custom ops by calling a RegisterCustomOpsFn function.
Searches for registration_func_name and if found calls it.
The library containing the function must either be linked against or previously loaded by the executable.
If you want ONNX Runtime to load the library and manage its lifetime, use RegisterCustomOpsLibrary_V2.
RegisterCustomOpsUsingFunction can be used in scenarios where it may not be possible for ONNX Runtime to load the library from a path. e.g. mobile platforms where the library must be linked into the app.
The registration function must have the signature of RegisterCustomOpsFn: OrtStatus* (fn)(OrtSessionOptions options, const OrtApiBase* api);
See https://onnxruntime.ai/docs/reference/operators/add-custom-op.html for details on how the registration function should be implemented.
- Parameters
-
[in] options OrtSessionOptions that is passed through as the first argument in the call to the registration function. [in] registration_func_name Name of registration function to use.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.14
◆ RegisterExecutionProviderLibrary()
| OrtStatus * OrtApi::RegisterExecutionProviderLibrary | ( | OrtEnv * | env, |
| const char * | registration_name, | ||
| const char * | path | ||
| ) |
Register an execution provider library with ORT.
The library must export 'CreateEpFactories' and 'ReleaseEpFactory' functions. See OrtEpApi for more details.
- Parameters
-
[in] env The OrtEnv instance to register the library in. [in] registration_name The name to register the execution provider library under. [in] path The path to the execution provider library.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ ReleaseAllocator()
◆ ReleaseArenaCfg()
◆ ReleaseAvailableProviders()
| OrtStatus * OrtApi::ReleaseAvailableProviders | ( | char ** | ptr, |
| int | providers_length | ||
| ) |
Release data from OrtApi::GetAvailableProviders. This API will never fail so you can rely on it in a noexcept code.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ReleaseCustomOpDomain()
◆ ReleaseDeviceEpIncompatibilityDetails()
Release an OrtDeviceEpIncompatibilityDetails instance.
- Since
- Version 1.24.
◆ ReleaseEnv()
| void OrtApi::ReleaseEnv | ( | OrtEnv * | input | ) |
◆ ReleaseExternalInitializerInfo()
Release an OrtExternalInitializerInfo instance.
- Parameters
-
[in] input OrtExternalInitializerInfo instance to be released.
- Since
- Version 1.23.
◆ ReleaseGraph()
| void OrtApi::ReleaseGraph | ( | OrtGraph * | input | ) |
Release an OrtGraph.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ ReleaseIoBinding()
◆ ReleaseKernelInfo()
◆ ReleaseKeyValuePairs()
Release an OrtKeyValuePairs instance.
- Parameters
-
[in] input OrtKeyValuePairs instance to be released.
- Since
- Version 1.22.
◆ ReleaseLoraAdapter()
◆ ReleaseMapTypeInfo()
◆ ReleaseMemoryInfo()
◆ ReleaseModel()
| void OrtApi::ReleaseModel | ( | OrtModel * | input | ) |
Release an OrtModel.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ ReleaseModelMetadata()
◆ ReleaseNode()
| void OrtApi::ReleaseNode | ( | OrtNode * | input | ) |
Release an OrtNode if it was not added to an OrtGraph.
- Since
- Version 1.22.
◆ ReleaseOp()
| void OrtApi::ReleaseOp | ( | OrtOp * | input | ) |
◆ ReleaseOpAttr()
| void OrtApi::ReleaseOpAttr | ( | OrtOpAttr * | input | ) |
◆ ReleasePrepackedWeightsContainer()
Release OrtPrepackedWeightsContainer instance.
- Note
- instance must not be released until the sessions using it are released
◆ ReleaseRunOptions()
◆ ReleaseSequenceTypeInfo()
◆ ReleaseSession()
◆ ReleaseSessionOptions()
◆ ReleaseSharedAllocator()
Release a shared allocator from the OrtEnv for the OrtEpDevice and memory type.
This will release the shared allocator for the given OrtEpDevice and memory type. If no shared allocator exists, this is a no-op.
- Parameters
-
[in] env The OrtEnv instance to release the shared allocator from. [in] ep_device The OrtEpDevice instance to release the shared allocator for. [in] mem_type The memory type of the shared allocator to release.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ ReleaseStatus()
| void OrtApi::ReleaseStatus | ( | OrtStatus * | input | ) |
◆ ReleaseSyncStream()
◆ ReleaseTensorTypeAndShapeInfo()
◆ ReleaseThreadingOptions()
◆ ReleaseTypeInfo()
◆ ReleaseValue()
| void OrtApi::ReleaseValue | ( | OrtValue * | input | ) |
◆ ReleaseValueInfo()
Release an OrtValueInfo instance if it was not added to an OrtGraph.
- Since
- Version 1.22.
◆ Run()
| OrtStatus * OrtApi::Run | ( | OrtSession * | session, |
| const OrtRunOptions * | run_options, | ||
| const char *const * | input_names, | ||
| const OrtValue *const * | inputs, | ||
| size_t | input_len, | ||
| const char *const * | output_names, | ||
| size_t | output_names_len, | ||
| OrtValue ** | outputs | ||
| ) |
Run the model in an OrtSession.
Will not return until the model run has completed. Multiple threads might be used to run the model based on the options in the OrtSession and settings used when creating the OrtEnv
- Parameters
-
[in] session [in] run_options If nullptr, will use a default OrtRunOptions [in] input_names Array of null terminated UTF8 encoded strings of the input names [in] inputs Array of OrtValues of the input values [in] input_len Number of elements in the input_names and inputs arrays [in] output_names Array of null terminated UTF8 encoded strings of the output names [in] output_names_len Number of elements in the output_names and outputs array [out] outputs Array of OrtValues that the outputs are stored in. This can also be an array of nullptr values, in this case OrtValue objects will be allocated and pointers to them will be set into the outputsarray.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RunAsync()
Run the model asynchronously in a thread owned by intra op thread pool.
- Parameters
-
[in] session [in] run_options If nullptr, will use a default OrtRunOptions [in] input_names Array of null terminated UTF8 encoded strings of the input names [in] input Array of OrtValues of the input values [in] input_len Number of elements in the input_names and inputs arrays [in] output_names Array of null terminated UTF8 encoded strings of the output names [in] output_names_len Number of elements in the output_names and outputs array [out] output OrtValue* array of size output_names_len. On calling RunAsync, output[i] could either be a null or a pointer to a preallocated OrtValue. Later, the output array will be passed to run_async_callback with all null(s) filled with valid OrtValue pointer(s) allocated by onnxruntime. NOTE: it is customer's duty to finally release the output array and each of its member, regardless of whether the member (OrtValue*) is allocated by onnxruntime or preallocated by the customer. [in] run_async_callback Callback function on model run completion [in] user_data User data that pass back to run_async_callback
◆ RunOptionsAddActiveLoraAdapter()
Add the Lora Adapter to the list of active adapters.
The function adds the Lora Adapter to the list of active adapters. The Lora Adapter must be created with OrtApi::CreateLoraAdapter or FromArray. The Lora Adapter will be used by the session to run the model. The instance of the OrtRunOptions can then be used to customize the Run() calls. More than one OrtLoraAdapter can be active at the same time. Lora Parameters that belong to different Lora adapters that will be active at the same time must not overlap. This setting does not affect RunWithBinding.
- Parameters
-
[in] options OrtRunOptions instance [in] adapter OrtLoraAdapter instance
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.20.
◆ RunOptionsDisableProfiling()
Disable profiling for this run.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.25.
◆ RunOptionsEnableProfiling()
Enable profiling for this run.
- Parameters
-
[in] options [in] profile_file_prefix The prefix for the profile file. The actual filename will be: [profile_file_prefix]_[timestamp].json
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.25.
◆ RunOptionsGetRunLogSeverityLevel()
| OrtStatus * OrtApi::RunOptionsGetRunLogSeverityLevel | ( | const OrtRunOptions * | options, |
| int * | log_severity_level | ||
| ) |
◆ RunOptionsGetRunLogVerbosityLevel()
| OrtStatus * OrtApi::RunOptionsGetRunLogVerbosityLevel | ( | const OrtRunOptions * | options, |
| int * | log_verbosity_level | ||
| ) |
Get per-run log verbosity level.
- Parameters
-
[in] options [out] log_verbosity_level The log verbosity level controls the display of ORT_LOGGING_LEVEL_VERBOSE severity log messages at a finer granularity. It only has an effect in debug builds. The higher the value, the more verbose the log output will be.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RunOptionsGetRunTag()
Get per-run tag.
This is used in a per-run log identifier.
- See also
- OrtApi::RunOptionsSetRunTag
- Parameters
-
[in] options [out] run_tag The run tag. Do not free this value, it is owned by options. It will be invalidated if the run tag changes (i.e., with OrtApi::RunOptionsSetRunTag) oroptionsis freed.
◆ RunOptionsSetRunLogSeverityLevel()
◆ RunOptionsSetRunLogVerbosityLevel()
Set per-run log verbosity level.
- Parameters
-
[in] options [in] log_verbosity_level The log verbosity level controls the display of ORT_LOGGING_LEVEL_VERBOSE severity log messages at a finer granularity. It only has an effect in debug builds. The higher the value, the more verbose the log output will be.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RunOptionsSetRunTag()
Set per-run tag.
This is used in a per-run log identifier.
- See also
- OrtApi::RunOptionsGetRunTag
- Parameters
-
[in] options [in] run_tag The run tag.
◆ RunOptionsSetTerminate()
Set terminate flag.
If a currently executing session needs to be force terminated, this can be called from another thread to force it to fail with an error.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RunOptionsUnsetTerminate()
Clears the terminate flag.
Used so the OrtRunOptions instance can be used in a new OrtApi::Run call without it instantly terminating
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ RunWithBinding()
Run a model using Io Bindings for the inputs & outputs.
- See also
- OrtApi::Run
- Parameters
-
[in] session [in] run_options [in] binding_ptr
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ Session_GetEpGraphAssignmentInfo()
Get information about the subgraphs assigned to each execution provider (EP) and the nodes within.
Each returned OrtEpAssignedSubgraph instance contains details of the subgraph/nodes assigned to an execution provider, including the execution provider's name, and the name, domain, and operator type for every node.
For compiling execution providers, a single OrtEpAssignedSubgraph instance contains information about the nodes that are fused and compiled within a single subgraph assigned to the execution provider.
For execution providers that use kernel registration (e.g., CPU EP), each node with a registered kernel is contained in its own OrtEpAssignedSubgraph instance.
- Note
- The caller must enable the collection of this information by enabling the session configuration entry "session.record_ep_graph_assignment_info" during session creation. Refer to onnxruntime_session_options_config_keys.h. Otherwise, if not enabled, this function returns a status with error code ORT_FAIL.
- The information reported by this function is obtained immediately after running basic optimizations on the original graph if the session optimization level is set to ORT_ENABLE_BASIC or higher. If the session optimization level is set to ORT_DISABLE_ALL, only minimal/required optimizations are run before the information is collected.
- Parameters
-
[in] session The OrtSession instance. [out] ep_subgraphs Output parameter set to the array of OrtEpAssignedSubgraph instances. [out] num_ep_subgraphs Output parameter set to the number of elements in the ep_subgraphsarray.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24.
◆ SessionEndProfiling()
End profiling and return filename of the profile data.
Profiling is turned on through OrtApi::EnableProfiling
- Parameters
-
[in] session [in] allocator [out] out Null terminated string of the filename, allocated using allocator. Must be freed usingallocator
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetEpDeviceForInputs()
Get the OrtEpDevice (if available) for each input of the session.
An OrtEpDevice will be available if auto EP selection is enabled by calling SessionOptionsSetEpSelectionPolicy or SessionOptionsSetEpSelectionPolicyDelegate, or if the OrtEpDevice was manually added to the session using SessionOptionsAppendExecutionProvider_V2.
If an OrtEpDevice is not available for the input a nullptr is returned.
The returned OrtEpDevice can be used to create an OrtSyncStream via CreateSyncStreamForEpDevice to asynchronously provide input to the inference session Run.
The session must be fully initialized before calling this function as the assigned EPs are not known until this has occurred.
- Parameters
-
[in] session The OrtSession instance. [out] inputs_ep_devices Pre-allocated array of size num_inputsthat will be filled with OrtEpDevice* values for each input. The order is the same as returned by SessionGetInputName.[in] num_inputs The number of inputs in the session. Must match SessionGetInputCount.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ SessionGetEpDeviceForOutputs()
Get the EP device assigned to each session output.
Returns the OrtEpDevice assigned to each output of the session after graph partitioning. This allows validation that outputs are placed on the expected device for external resource sharing.
The EP device for each output is determined by which execution provider will produce that output during inferencing. This information is useful for:
- Validating that outputs will be placed on the expected device for external resource sharing
- Deciding whether to use external memory handles for outputs
- Parameters
-
[in] session The OrtSession instance to query. [out] outputs_ep_devices An array to be filled with the EP device for each output. The array must be allocated by the caller with space for OrtEpDevice* values for each output. The order is the same as returned by SessionGetOutputName. [in] num_outputs The number of outputs in the session. Must match SessionGetOutputCount.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.24
◆ SessionGetInputCount()
◆ SessionGetInputName()
Get input name.
- Parameters
-
[in] session [in] index Must be between 0 (inclusive) and what OrtApi::SessionGetInputCount returns (exclusive) [in] allocator [out] value Set to a null terminated UTF-8 encoded string allocated using allocator. Must be freed usingallocator.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetInputTypeInfo()
Get input type information.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetMemoryInfoForInputs()
Get the OrtMemoryInfo for each input of the session.
The memory info can be used to determine where the input tensors are required.
The session must be fully initialized before calling this function as the input locations are not known until this has occurred.
- Parameters
-
[in] session The OrtSession instance. [out] inputs_memory_info Pre-allocated array of size num_inputsthat will be filled with the OrtMemoryInfo* value for each input. The order is the same as returned by SessionGetInputName.[in] num_inputs The number of inputs in the session. Must match SessionGetInputCount.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ SessionGetMemoryInfoForOutputs()
Get the OrtMemoryInfo for each output of the session.
The memory info can be used to determine the device the output tensors are produced on. The user can pre-allocate an OrtValue using this information or use IOBinding to keep the data on the device. ORT will copy the output to CPU otherwise.
The session must be fully initialized before calling this function as the output locations are not known until this has occurred.
- Parameters
-
[in] session The OrtSession instance. [out] outputs_memory_info Pre-allocated array of size num_outputsthat will be filled with OrtMemoryInfo* values for each output. The order is the same as returned by SessionGetOutputName.[in] num_outputs The number of outputs in the session. Must match SessionGetOutputCount.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ SessionGetModelMetadata()
◆ SessionGetOutputCount()
◆ SessionGetOutputName()
Get output name.
- Parameters
-
[in] session [in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOutputCount returns (exclusive) [in] allocator [out] value Set to a null terminated UTF-8 encoded string allocated using allocator. Must be freed usingallocator.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetOutputTypeInfo()
Get output type information.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetOverridableInitializerCount()
| OrtStatus * OrtApi::SessionGetOverridableInitializerCount | ( | const OrtSession * | session, |
| size_t * | out | ||
| ) |
◆ SessionGetOverridableInitializerName()
Get overridable initializer name.
- Parameters
-
[in] session [in] index Must be between 0 (inclusive) and what OrtApi::SessionGetOverridableInitializerCount returns (exclusive) [in] allocator [out] value Set to a null terminated UTF-8 encoded string allocated using allocator. Must be freed usingallocator.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetOverridableInitializerTypeInfo()
Get overridable initializer type information.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionGetProfilingStartTimeNs()
| OrtStatus * OrtApi::SessionGetProfilingStartTimeNs | ( | const OrtSession * | session, |
| uint64_t * | out | ||
| ) |
Return the time that profiling was started.
- Note
- The timer precision varies per platform. On Windows and MacOS, the precision will be ~100ns
- Parameters
-
[in] session [out] out nanoseconds of profiling's start time
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsAppendExecutionProvider()
| OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider | ( | OrtSessionOptions * | options, |
| const char * | provider_name, | ||
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
: Append execution provider to the session options.
- Parameters
-
[in] options [in] provider_name - provider to add. [in] provider_options_keys - keys to configure the provider options [in] provider_options_values - values to configure the provider options [in] num_keys - number of keys passed in
Currently supported provider names: QNNExecutionProvider (or QNN) OpenVINOExecutionProvider (or OpenVINO) XnnpackExecutionProvider (or XNNPACK) WebNNExecutionProvider (or WEBNN) WebGpuExecutionProvider (or WebGPU) AzureExecutionProvider (or AZURE) JsExecutionProvider (or JS) VitisAIExecutionProvider (or VitisAI) CoreMLExecutionProvider (or CoreML)
Note: If an execution provider has a dedicated SessionOptionsAppendExecutionProvider_<provider name> function that should be used to add it.
QNN supported keys: "backend_type": Type of QNN backend. Specifies a backend path that is the associated QNN backend library file name. E.g., given backend type "htp", on Windows, the backend path would be "QnnHtp.dll", and on other platforms, it would be "libQnnHtp.so". Mutually exclusive with "backend_path". Available options:
- "cpu"
- "gpu"
- "htp": Default.
- "saver"
- "ir" "backend_path": File path to QNN backend library. Mutually exclusive with "backend_type". "profiling_level": QNN profiling level. Available options:
- "off": Default.
- "basic"
- "detailed" "profiling_file_path": QNN profiling file path if ETW not enabled. "rpc_control_latency": QNN RPC control latency. "vtcm_mb": QNN VTCM size in MB. default to 0(not set). "htp_performance_mode": QNN performance mode. Available options:
- "burst"
- "balanced"
- "default": Default.
- "high_performance"
- "high_power_saver"
- "low_balanced"
- "extreme_power_saver"
- "low_power_saver"
- "power_saver"
- "sustained_high_performance" "dump_qnn_ir_dlc": Use the QnnIr backend library to write .dlc files for each subgraph dispatched to QNN. When enabled, inference results will be incorrect. Use only for debugging.
- "0": Default: disabled
- "1": enabled "dump_qnn_ir_dlc_dir": Set the directory into which QnnIr will be configured to write QNN graphs as .dlc files. Default is current working directory. "qnn_ir_backend_path": File path to the QnnIr backend library. If "dump_qnn_ir_dlc" is enabled, use this path instead of looking for the Ir backend in the standard location. "qnn_saver_path": File path to the QNN Saver backend library. If specified, QNN Saver will be enabled and will dump QNN API calls to disk for replay/debugging. QNN Saver produces incorrect model inference results and may alter model/EP partitioning. Use only for debugging. "qnn_context_priority": QNN context priority. Available options:
- "low"
- "normal": Default.
- "normal_high"
- "high" "htp_graph_finalization_optimization_mode": Set the optimization mode for graph finalization on the HTP backend. Available options:
- "0": Default.
- "1": Faster preparation time, less optimal graph.
- "2": Longer preparation time, more optimal graph.
- "3": Longest preparation time, most likely even more optimal graph. See QNN SDK documentation for specific details. "soc_model": The SoC model number. Refer to the QNN SDK documentation for valid values. Defaults to "0" (unknown). "htp_arch": The minimum HTP architecture the driver will use to select compatible QNN operators. Available options:
- "0": Default (none).
- "68"
- "69"
- "73"
- "75"
- "81" "device_id": The ID of the device to use when setting 'htp_arch'. Defaults to "0" (for single device). "enable_htp_fp16_precision": Used for float32 model for HTP backend. Enable the float32 model to be inferenced with fp16 precision. Otherwise, it will be fp32 precision.
- "0": With fp32 precision.
- "1": Default. With fp16 precision. "offload_graph_io_quantization": Offload graph input quantization and graph output dequantization to another execution provider (typically CPU EP).
- "0": Disabled. QNN EP will handle quantization and dequantization of graph I/O.
- "1": Enabled. This is the default value. "enable_htp_spill_fill_buffer": Enable HTP spill fill buffer setting. The flag is used while generating context binary.
- "0": Default. Disabled.
- "1": Enabled. "enable_htp_shared_memory_allocator": Enable the QNN HTP shared memory allocator. Requires libcdsprpc.so/dll to be available.
- "0": Default. Disabled.
- "1": Enabled. "dump_json_qnn_graph": Set to "1" to dump QNN graphs generated by QNN EP as JSON files. Each graph partition assigned to QNN EP is dumped to a separate file. "json_qnn_graph_dir": Directory in which to dump QNN JSON graphs. If not specified, QNN graphs are dumped in the program's current working directory. Ignored if "dump_json_qnn_graph" is not set. "op_packages": QNN UDO op_package for QNN EP, allowed format: "<op_type>:<op_package_path>:<interface>[:<target>],<op_type2>:<op_package_path2>:<interface2>[:<target>]", where op_type is the name of the operation, op_package_path is the path to the op package shared library, interface is the symbol name to register the op life cycle functions, and target is the backend type. For more details, refer to: https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/op_packages.html [Advanced] "skip_qnn_version_check": Set to "1" to allow a different version of QNN to be used than what was compiled into ONNX Runtime. Differences in operator support, accuracy, performance, and QNN's ABI may lead to crashes, inaccurate results, and poor performance. Use with caution and test thoroughly.
XNNPACK supported keys: "intra_op_num_threads": number of thread-pool size to use for XNNPACK execution provider. default value is 0, which means to use the session thread-pool size.
- Since
- Version 1.12.
◆ SessionOptionsAppendExecutionProvider_CANN()
Append CANN provider to session options.
If CANN is not available (due to a non CANN enabled build, or if CANN is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] cann_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.13.
◆ SessionOptionsAppendExecutionProvider_CUDA()
Append CUDA provider to session options.
If CUDA is not available (due to a non CUDA enabled build, or if CUDA is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] cuda_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsAppendExecutionProvider_CUDA_V2()
◆ SessionOptionsAppendExecutionProvider_Dnnl()
Append dnnl provider to session options.
If oneDNN is not available, this function will return failure.
- Parameters
-
[in] options [in] dnnl_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ SessionOptionsAppendExecutionProvider_MIGraphX()
Append MIGraphX provider to session options.
If MIGraphX is not available (due to a non MIGraphX enabled build, or if MIGraphX is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] migraphx_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.11.
◆ SessionOptionsAppendExecutionProvider_OpenVINO()
Append OpenVINO execution provider to the session options.
If OpenVINO is not available (due to a non OpenVINO enabled build, or if OpenVINO is not installed on the system), this function will fail.
- Parameters
-
[in] options [in] provider_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsAppendExecutionProvider_OpenVINO_V2()
| OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO_V2 | ( | OrtSessionOptions * | options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Append OpenVINO execution provider to the session options.
If OpenVINO is not available (due to a non OpenVINO enabled build, or if OpenVINO is not installed on the system), this function will fail.
- Parameters
-
[in] options [in] provider_options_keys [in] provider_options_values [in] num_keys
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.17.
◆ SessionOptionsAppendExecutionProvider_ROCM()
Append ROCM execution provider to the session options.
If ROCM is not available (due to a non ROCM enabled build, or if ROCM is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] rocm_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsAppendExecutionProvider_TensorRT()
Append TensorRT provider to session options.
If TensorRT is not available (due to a non TensorRT enabled build, or if TensorRT is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] tensorrt_options
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsAppendExecutionProvider_TensorRT_V2()
◆ SessionOptionsAppendExecutionProvider_V2()
| OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_V2 | ( | OrtSessionOptions * | session_options, |
| OrtEnv * | env, | ||
| const OrtEpDevice *const * | ep_devices, | ||
| size_t | num_ep_devices, | ||
| const char *const * | ep_option_keys, | ||
| const char *const * | ep_option_vals, | ||
| size_t | num_ep_options | ||
| ) |
Append the execution provider that is responsible for the selected OrtEpDevice instances to the session options.
- Parameters
-
[in] session_options Session options to add execution provider to. [in] env Environment that execution providers were registered with. [in] ep_devices One or more OrtEpDevice instances to create an execution provider for. Obtain from GetEpDevices. All OrtEpDevice instances must be from the same execution provider. It is only necessary to provide multiple OrtEpDevices if you want to use the same execution provider for multiple devices. e.g. the EP is capable of running on GPU and NPU. [in] num_ep_devices Number of OrtEpDevice instances. [in] ep_option_keys Optional keys to configure the execution provider. [in] ep_option_vals Optional values to configure the execution provider. [in] num_ep_options Number of execution provide options to add.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ SessionOptionsAppendExecutionProvider_VitisAI()
| OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_VitisAI | ( | OrtSessionOptions * | options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Append VitisAI provider to session options.
If VitisAI is not available (due to a non VitisAI enabled build, or if VitisAI is not installed on the system), this function will return failure.
- Parameters
-
[in] options [in] provider_options_keys [in] provider_options_values [in] num_keys
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.18.
◆ SessionOptionsSetCustomCreateThreadFn()
Set custom thread creation function.
- Parameters
-
[in] options Session options [in] ort_custom_create_thread_fn Custom thread creation function
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsSetCustomJoinThreadFn()
Set custom thread join function.
- Parameters
-
[in] options Session options [in] ort_custom_join_thread_fn Custom join thread function, must not be nullptr when ort_custom_create_thread_fn is set
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsSetCustomThreadCreationOptions()
| OrtStatus * OrtApi::SessionOptionsSetCustomThreadCreationOptions | ( | OrtSessionOptions * | options, |
| void * | ort_custom_thread_creation_options | ||
| ) |
Set creation options for custom thread.
- Parameters
-
[in] options Session options [in] ort_custom_thread_creation_options Custom thread creation options (can be nullptr)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SessionOptionsSetEpSelectionPolicy()
Set the execution provider selection policy for the session.
Allows users to specify a device selection policy for automatic execution provider (EP) selection. If custom selection is required please use SessionOptionsSetEpSelectionPolicyDelegate instead.
- Parameters
-
[in] session_options The OrtSessionOptions instance. [in] policy The device selection policy to use (see OrtExecutionProviderDevicePolicy).
- Since
- Version 1.22
◆ SessionOptionsSetEpSelectionPolicyDelegate()
Set the execution provider selection policy delegate for the session.
Allows users to provide a custom device selection policy for automatic execution provider (EP) selection.
- Parameters
-
[in] session_options The OrtSessionOptions instance. [in] delegate Delegate callback for custom selection. [in] delegate_state Optional state that will be passed to the delegate callback. nullptr if not required.
- Since
- Version 1.22
◆ SessionOptionsSetLoadCancellationFlag()
sets load cancellation flag to abort session loading process.
- Parameters
-
[in] options instance that was passed to the session at creation time. [in] cancel setting this to true after model loading process was initiated will attempt to cancel the loading process. If cancellation is successful, CreateSession() CreateSessionFromArray() or any other session creation API that take session options as an argument will return an OrtStatus indicating that session loading was canceled at user request, error code ORT_MODEL_LOAD_CANCELED. The APIs above would not return any valid Session instance. This is the best case effort and the result is not guaranteed. The session may have already been created and initialized before the cancellation request was issued.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ SetCurrentGpuDeviceId()
| OrtStatus * OrtApi::SetCurrentGpuDeviceId | ( | int | device_id | ) |
Set current GPU device ID.
Set the current device id of the GPU execution provider (CUDA/tensorrt/rocm). The device id should be less than the total number of devices available. This is only useful when multiple-GPUs are installed and it is required to restrict execution to a single GPU.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetDeterministicCompute()
Set whether to use deterministic compute.
Default is false. If set to true, this will enable deterministic compute for GPU kernels where possible. Note that this most likely will have a performance cost.
- Parameters
- Since
- Version 1.17.
◆ SetDimensions()
Set shape information in OrtTensorTypeAndShapeInfo.
- Parameters
-
[in] info [in] dim_values Array with dim_countelements. Can contain negative values.[in] dim_count Number of elements in dim_values
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetEpDynamicOptions()
| OrtStatus * OrtApi::SetEpDynamicOptions | ( | OrtSession * | sess, |
| const char *const * | keys, | ||
| const char *const * | values, | ||
| size_t | kv_len | ||
| ) |
Set DynamicOptions for EPs (Execution Providers)
Valid options can be found in include\onnxruntime\core\session\onnxruntime_session_options_config_keys.h Look for kOrtEpDynamicOptions
- Parameters
-
[in] sess OrtSession [in] keys Array of null terminated UTF8 encoded strings of EP dynamic option keys [in] values Array of null terminated UTF8 encoded string of EP dynamic option values [in] kv_len Number of elements in the keys and values arrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.20.
◆ SetGlobalCustomCreateThreadFn()
Set custom thread creation function for global thread pools.
- Parameters
-
[in,out] tp_options [in] ort_custom_create_thread_fn Custom thread creation function
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalCustomJoinThreadFn()
Set custom thread join function for global thread pools.
- Parameters
-
[in,out] tp_options [in] ort_custom_join_thread_fn Custom thread join function, must not be nullptr when global ort_custom_create_thread_fn is set
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalCustomThreadCreationOptions()
Set custom thread creation options for global thread pools.
- Parameters
-
[in,out] tp_options [in] ort_custom_thread_creation_options Custom thread creation options (can be nullptr)
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalDenormalAsZero()
Set threading flush-to-zero and denormal-as-zero.
Sets global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools. Flush-to-zero and denormal-as-zero are applied to threads in both intra and inter global thread pool.
- Note
- This option is not needed if the models used have no denormals. Having no denormals is recommended as this option may hurt model accuracy.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalInterOpNumThreads()
Set global inter-op thread count.
This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools
- Parameters
-
[in] tp_options [in] inter_op_num_threads Number of threads, special values:
0 = Use default thread count
1 = The invoking thread will be used; no threads will be created in the thread pool.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalIntraOpNumThreads()
Set global intra-op thread count.
This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools
- Parameters
-
[in] tp_options [in] intra_op_num_threads Number of threads, special values:
0 = Use default thread count
1 = The invoking thread will be used; no threads will be created in the thread pool.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetGlobalIntraOpThreadAffinity()
◆ SetGlobalSpinControl()
Set global spin control options.
This will configure the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools. Allow spinning of thread pools when their queues are empty. This will set the value for both inter_op and intra_op threadpools.
- Parameters
-
[in] tp_options [in] allow_spinning Valid values are 0 or 1.
0 = It won't spin (recommended if CPU usage is high)
1 = Threadpool will spin to wait for queue to become non-empty
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetInterOpNumThreads()
Sets the number of threads used to parallelize the execution of the graph.
If nodes can be run in parallel, this sets the maximum number of threads to use to run them in parallel.
- Note
- If sequential execution is enabled this value is ignored, it acts as if it was set to 1.
- Parameters
-
[in] options [in] inter_op_num_threads Number of threads to use
A value of 0 will use the default number of threads
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetIntraOpNumThreads()
Sets the number of threads used to parallelize the execution within nodes.
When running a single node operation, ex. add, this sets the maximum number of threads to use.
- Note
- If built with OpenMP, this has no effect on the number of threads used. In this case use the OpenMP env variables to configure the number of intra op num threads.
- Parameters
-
[in] options [in] intra_op_num_threads Number of threads to use
A value of 0 will use the default number of threads
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetLanguageProjection()
Set language projection.
Set the language projection for collecting telemetry data when Env is created.
The default is ORT_PROJECTION_C, which means it will classify the language not in the list to C also.
- Parameters
-
[in] ort_env [in] projection
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetOptimizedModelFilePath()
Set filepath to save optimized model after graph level transformations.
- Parameters
-
[in] options [in] optimized_model_filepath
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetSessionExecutionMode()
Set execution mode.
Controls whether you want to execute operators in your graph sequentially or in parallel. Usually when the model has many branches, setting this option to ExecutionMode.ORT_PARALLEL will give you better performance. See [docs/ONNX_Runtime_Perf_Tuning.md] for more details.
- Parameters
-
[in] options [in] execution_mode
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetSessionGraphOptimizationLevel()
◆ SetSessionLogId()
Set session log id.
- Parameters
-
[in] options [in] logid The log identifier.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetSessionLogSeverityLevel()
Set session log severity level.
- Parameters
-
[in] options [in] session_log_severity_level The log severity level (refer to OrtLoggingLevel for possible values).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetSessionLogVerbosityLevel()
Set session log verbosity level.
Applies to session load, initialization, etc
- Parameters
-
[in] options [in] session_log_verbosity_level The log verbosity level controls the display of ORT_LOGGING_LEVEL_VERBOSE severity log messages at a finer granularity. It only has an effect in debug builds. The higher the value, the more verbose the log output will be.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SetSymbolicDimensions()
Set symbolic shape to type shape info
- Parameters
-
[in] info Type shape info [in] dim_params Symbolic strings [in] dim_params_length Number of strings
- Since
- Version 1.17.
◆ SetTensorElementType()
◆ SetUserLoggingFunction()
Set user logging function.
By default the logger created by the CreateEnv* functions is used to create the session logger as well. This function allows a user to override this default session logger with a logger of their own choosing. This way the user doesn't have to create a separate environment with a custom logger. This addresses the problem when the user already created an env but now wants to use a different logger for a specific session (for debugging or other reasons).
- Parameters
-
[in] options [in] user_logging_function A pointer to a logging function. [in] user_logging_param A pointer to arbitrary data passed as the OrtLoggingFunction paramparameter touser_logging_function. This parameter is optional.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.17.
◆ ShapeInferContext_GetAttribute()
Get attribute from OrtShapeInferContext. Note that OrtShapeInferContext is a per-node context, one could only read attribute from current node.
- Parameters
-
[in] context [in] attr_name Name of the attribute [out] attr Handle of the attribute fetched
- Since
- Version 1.17.
◆ ShapeInferContext_GetInputCount()
Get number of input from OrtShapeInferContext
- Parameters
-
[in] context [out] out The number of inputs
- Since
- Version 1.17.
◆ ShapeInferContext_GetInputTypeShape()
Get type and shape info of an input
- Parameters
-
[in] context [in] index The index of the input [out] info Type shape info of the input
- Since
- Version 1.17.
◆ ShapeInferContext_SetOutputTypeShape()
Set type and shape info of an output
- Parameters
-
[in] context [in] index The index of the output [out] info Type shape info of the output
- Since
- Version 1.17.
◆ SynchronizeBoundInputs()
Synchronize bound inputs. The call may be necessary for some providers, such as cuda, in case the system that allocated bound memory operated on a different stream. However, the operation is provider specific and could be a no-op.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ SynchronizeBoundOutputs()
Synchronize bound outputs. The call may be necessary for some providers, such as cuda, in case the system that allocated bound memory operated on a different stream. However, the operation is provider specific and could be a no-op.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ TensorAt()
| OrtStatus * OrtApi::TensorAt | ( | OrtValue * | value, |
| const int64_t * | location_values, | ||
| size_t | location_values_count, | ||
| void ** | out | ||
| ) |
Direct memory access to a specified tensor element.
For example, given a tensor with shape of [3,224,224], a pointer to the element at location [2,150,128] can be retrieved
This function only works for numeric type tensors (No strings, etc). This is a no-copy method whose returned pointer is valid until the passed in OrtValue is free'd.
- Parameters
-
[in] value [in] location_values Pointer to an array of index values that specify an element's location relative to its shape [in] location_values_count Number of elements in location_values. Must match the number of elements in the tensor's shape. [out] out Set to a pointer to the element specified
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ UnregisterAllocator()
Unregister a custom allocator.
It is an error if you provide an OrtMemoryInfo not corresponding to any registered allocators for sharing.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ UnregisterExecutionProviderLibrary()
| OrtStatus * OrtApi::UnregisterExecutionProviderLibrary | ( | OrtEnv * | env, |
| const char * | registration_name | ||
| ) |
Unregister an execution provider library with ORT.
ORT will call ReleaseEpFactory for all factories created by the library, and unload the library.
You MUST ensure there are no Session instances using execution providers created by the library before calling this function.
- Parameters
-
[in] env The OrtEnv instance to unregister the library from. [in] registration_name The name the execution provider library was registered under.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.22.
◆ UpdateCANNProviderOptions()
| OrtStatus * OrtApi::UpdateCANNProviderOptions | ( | OrtCANNProviderOptions * | cann_options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Set options in a CANN Execution Provider.
- Parameters
-
[in] cann_options [in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys [in] provider_options_values Array of UTF-8 null-terminated string for provider options values [in] num_keys Number of elements in the provider_option_keysandprovider_options_valuesarrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.13.
◆ UpdateCUDAProviderOptions()
| OrtStatus * OrtApi::UpdateCUDAProviderOptions | ( | OrtCUDAProviderOptionsV2 * | cuda_options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Set options in a CUDA Execution Provider.
Please refer to https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#configuration-options to know the available keys and values. Key should be in null terminated string format of the member of OrtCUDAProviderOptionsV2 and value should be its related range. Recreates the options and only sets the supplied values.
For example, key="device_id" and value="0"
- Parameters
-
[in] cuda_options [in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys [in] provider_options_values Array of UTF-8 null-terminated string for provider options values [in] num_keys Number of elements in the provider_option_keysandprovider_options_valuesarrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.11.
◆ UpdateCUDAProviderOptionsWithValue()
Update CUDA EP provider option where its data type is pointer, for example 'user_compute_stream'. If the data type of the provider option can be represented by string please use UpdateCUDAProviderOptions.
Note: It's caller's responsibility to properly manage the lifetime of the instance pointed by this pointer.
- Parameters
-
cuda_options - OrtCUDAProviderOptionsV2 instance key - Name of the provider option value - A pointer to the instance that will be assigned to this provider option
- Since
- Version 1.16.
◆ UpdateDnnlProviderOptions()
| OrtStatus * OrtApi::UpdateDnnlProviderOptions | ( | OrtDnnlProviderOptions * | dnnl_options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Set options in a oneDNN Execution Provider.
Key should be in null terminated string format of the member of OrtDnnlProviderOptions and value should be its related range.
For example, key="use_arena" and value="1"
- Parameters
-
[in] dnnl_options [in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys [in] provider_options_values Array of UTF-8 null-terminated string for provider options values [in] num_keys Number of elements in the provider_option_keysandprovider_options_valuesarrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.15.
◆ UpdateEnvWithCustomLogLevel()
◆ UpdateROCMProviderOptions()
| OrtStatus * OrtApi::UpdateROCMProviderOptions | ( | OrtROCMProviderOptions * | rocm_options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Set options in a ROCm Execution Provider.
Please refer to https://onnxruntime.ai/docs/execution-providers/ROCm-ExecutionProvider.html to know the available keys and values. Key should be in null terminated string format of the member of OrtROCMProviderOptions and value should be its related range.
For example, key="device_id" and value="0"
- Parameters
-
[in] rocm_options [in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys [in] provider_options_values Array of UTF-8 null-terminated string for provider options values [in] num_keys Number of elements in the provider_option_keysandprovider_options_valuesarrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.16.
◆ UpdateTensorRTProviderOptions()
| OrtStatus * OrtApi::UpdateTensorRTProviderOptions | ( | OrtTensorRTProviderOptionsV2 * | tensorrt_options, |
| const char *const * | provider_options_keys, | ||
| const char *const * | provider_options_values, | ||
| size_t | num_keys | ||
| ) |
Set options in a TensorRT Execution Provider.
Please refer to https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#cc to know the available keys and values. Key should be in null terminated string format of the member of OrtTensorRTProviderOptionsV2 and value should be its related range. Recreates the options and only sets the supplied values.
For example, key="trt_max_workspace_size" and value="2147483648"
- Parameters
-
[in] tensorrt_options [in] provider_options_keys Array of UTF-8 null-terminated string for provider options keys [in] provider_options_values Array of UTF-8 null-terminated string for provider options values [in] num_keys Number of elements in the provider_option_keysandprovider_options_valuesarrays
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ UpdateTensorRTProviderOptionsWithValue()
Update TensorRT EP provider option where its data type is pointer, for example 'user_compute_stream'. If the data type of the provider option can be represented by string please use UpdateTensorRTProviderOptions.
Note: It's caller's responsibility to properly manage the lifetime of the instance pointed by this pointer.
- Parameters
-
tensorrt_options - OrtTensorRTProviderOptionsV2 instance key - Name of the provider option value - A pointer to the instance that will be assigned to this provider option
- Since
- Version 1.16.
◆ UseBlockSparseIndices()
| OrtStatus * OrtApi::UseBlockSparseIndices | ( | OrtValue * | ort_value, |
| const int64_t * | indices_shape, | ||
| size_t | indices_shape_len, | ||
| int32_t * | indices_data | ||
| ) |
The assigns BlockSparse format indices to the SparseTensor that was created by OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to ORT_SPARSE_BLOCK_SPARSE. This will not allocate any additional memory for data. The life span of indices_data buffer must eclipse the lifespan of this OrtValue.
- Parameters
-
[in,out] ort_value OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue [in] indices_shape pointer to indices shape. Use {0} for fully sparse tensors [in] indices_shape_len length of the indices shape [in,out] indices_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ UseCooIndices()
| OrtStatus * OrtApi::UseCooIndices | ( | OrtValue * | ort_value, |
| int64_t * | indices_data, | ||
| size_t | indices_num | ||
| ) |
This assigns Coo format indices to the SparseTensor that was created by OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to ORT_SPARSE_COO. This will not allocate any additional memory for data. The life span of indices_data buffer should eclipse the life span of this OrtValue.
- Parameters
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ UseCsrIndices()
| OrtStatus * OrtApi::UseCsrIndices | ( | OrtValue * | ort_value, |
| int64_t * | inner_data, | ||
| size_t | inner_num, | ||
| int64_t * | outer_data, | ||
| size_t | outer_num | ||
| ) |
The assigns CSR format indices to the SparseTensor that was created by OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets OrtSparseFormat to ORT_SPARSE_CSRC. This will not allocate any additional memory for data. The life spans of inner_data and outer_data buffers should eclipse the life span of this OrtValue.
- Parameters
-
[in,out] ort_value OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue [in,out] inner_data pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. [in] inner_num number of inner CSR indices. Should either be 0 for fully sparse tensors or be equal to the number of nnz values specified to OrtApi::CreateSparseTensorWithValuesAsOrtValue. [in,out] outer_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors. [in] outer_num number of CSR outer indices. Should either be 0 for fully sparse tensors or equal to rows + 1 of the dense shape.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
◆ ValueInfo_GetExternalInitializerInfo()
Get information about an external initializer (e.g., filepath, file offset, byte size).
Sets the output parameter info to NULL if the given OrtValueInfo does not represent an initializer with external data. In this case, a NULL status (non-error) is returned.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] info Output parameter set to an OrtExternalInitializerInfo instance that can be used to query file path, file offset, etc. ORT sets this to NULL if the OrtValueInfo does not represent an external initializer. Must release with ReleaseExternalInitializerInfo.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_GetInitializerValue()
Get the underlying initializer value, as an OrtValue, from the given OrtValueInfo.
Sets the output parameter to NULL if the given OrtValueInfo does not represent an initializer. Does not return an error status in this case.
Supports initializers defined in an outer scope (i.e., a parent graph).
Supports initializers stored in an external file. For external initializers, ORT memory maps the initializer data on the first call to this function. If caller needs custom memory mapping, use ValueInfo_GetExternalInitializerInfo to get the location of the initializer data.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] initializer_value Output parameter set to the initializer value or NULL. Do not cache the OrtValue as it is released when the owning OrtGraph is released.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_GetValueConsumers()
| OrtStatus * OrtApi::ValueInfo_GetValueConsumers | ( | const OrtValueInfo * | value_info, |
| const OrtNode ** | nodes, | ||
| int64_t * | input_indices, | ||
| size_t | num_consumers | ||
| ) |
Returns information (OrtNode and input index) for all consumer nodes that use the value as an input.
Only nodes are considered "consumers" by this function.
Caller provides 2 pre-allocated arrays that will be filled with the OrtNode and input index values. Use ValueInfo_GetValueNumConsumers() to get the number of consumers of the value.
An OrtNode instance may appear multiple times if it uses the given value more than once. Example: For a node MulNode(x, x) that consumes the value 'x' twice, the following is returned:
- nodes: [MulNode, MulNode]
- input_indices: [0, 1]
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] nodes Pre-allocated array of size num_consumersthat is filled with OrtNode instances.[out] input_indices Pre-allocated array of num_consumerselements that is filled with input indices. Index is set to -1 for an "implicit" input to a consumer node that contains a subgraph (e.g., If, Loop) with nodes that use the value internally.[in] num_consumers The size of the consumer_nodesandconsumer_input_indicesarrays. Typical usage sets this to the value of ValueInfo_GetValueNumConsumers(). An error status is returned ifnum_consumersis less than the number of actual consumers.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_GetValueNumConsumers()
| OrtStatus * OrtApi::ValueInfo_GetValueNumConsumers | ( | const OrtValueInfo * | value_info, |
| size_t * | num_consumers | ||
| ) |
Get the number of consumers of a value as a node input.
Only nodes are considered "consumers" by this function. To check if an OrtValueInfo is a graph output, call ValueInfo_IsGraphOutput().
A single OrtNode may use a single value for more than one input (e.g., Mul(x, x)), so the returned num_consumers may be larger than the number of unique OrtNode instances that consume the value.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] num_consumers Output parameter set to the number of consumers of the value.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_GetValueProducer()
| OrtStatus * OrtApi::ValueInfo_GetValueProducer | ( | const OrtValueInfo * | value_info, |
| const OrtNode ** | producer_node, | ||
| size_t * | producer_output_index | ||
| ) |
Get the OrtNode that produces the value represented by the given OrtValueInfo. Optionally returns the associated output index.
- Parameters
-
[in] value_info The OrtValueInfo instance. [out] producer_node Output parameter set to the OrtNode that produces the OrtValueInfo. [out] producer_output_index Optional output parameter set to the OrtNode instance's output index that produces the value. Ignored if set to NULL. - Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_IsConstantInitializer()
| OrtStatus * OrtApi::ValueInfo_IsConstantInitializer | ( | const OrtValueInfo * | value_info, |
| bool * | is_constant_initializer | ||
| ) |
Returns a boolean indicating if the given value is a constant initializer.
For ONNX IR version < 4, all initializers are constant.
For ONNX IR version >=4, an initializer that serves as the default value for a matching graph input is not a constant initializer.
- Parameters
-
[in] value_info The OrtValueInfo instance representing the graph value. [out] is_constant_initializer Output parameter set to true if the graph value is a constant initializer.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_IsFromOuterScope()
| OrtStatus * OrtApi::ValueInfo_IsFromOuterScope | ( | const OrtValueInfo * | value_info, |
| bool * | is_from_outer_scope | ||
| ) |
Returns a boolean indicating if the given value is defined in an outer scope.
Certain operator types (e.g., If and Loop) contain nested subgraphs. This function enables determining whether a value is defined in a parent node's graph.
- Parameters
-
[in] value_info The OrtValueInfo instance representing the graph value. [out] is_from_outer_scope Output parameter set to true if the value is defined in an outer scope (i.e., a parent graph).
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_IsGraphOutput()
Returns a boolean indicating if the given value is a graph output.
- Parameters
-
[in] value_info The OrtValueInfo instance representing the graph value. [out] is_graph_output Output parameter set to true if the graph value is a graph output.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_IsOptionalGraphInput()
| OrtStatus * OrtApi::ValueInfo_IsOptionalGraphInput | ( | const OrtValueInfo * | value_info, |
| bool * | is_optional_graph_input | ||
| ) |
Returns a boolean indicating if the given value is an optional graph input.
Optional graph inputs were introduced in ONNX IR version 4. For ONNX IR version >=4, a graph input with a matching initializer is an optional graph input with the initializer serving as the default value. The matching initializer is also known as a non-constant initializer.
- Parameters
-
[in] value_info The OrtValueInfo instance representing the graph value. [out] is_optional_graph_input Output parameter set to true if the graph value is an optional graph input.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ ValueInfo_IsRequiredGraphInput()
| OrtStatus * OrtApi::ValueInfo_IsRequiredGraphInput | ( | const OrtValueInfo * | value_info, |
| bool * | is_required_graph_input | ||
| ) |
Returns a boolean indicating if the given value is a required graph input.
For ONNX IR version < 4, all graph inputs without a matching initializer are required.
For ONNX IR version >=4, a graph input with a matching initializer is an optional graph input with the initializer serving as the default value.
- Parameters
-
[in] value_info The OrtValueInfo instance representing the graph value. [out] is_required_graph_input Output parameter set to true if the graph value is a required graph input.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23.
◆ AddKeyValuePair
void( * OrtApi::AddKeyValuePair) (OrtKeyValuePairs *kvps, const char *key, const char *value)
Add a key-value pair to the OrtKeyValuePairs instance.
If a pair with the same key already exists, it is overwritten.
- Parameters
-
[in] kvps OrtKeyValuePairs instance. [in] key Key to be added. [in] value Value to be added.
- Note
- The
keyandvalueare copied internally.
- Since
- Version 1.22.
◆ ClearBoundInputs
void( * OrtApi::ClearBoundInputs) (OrtIoBinding *binding_ptr) __attribute__((nonnull))
Clears any previously set Inputs for an OrtIoBinding.
◆ ClearBoundOutputs
void( * OrtApi::ClearBoundOutputs) (OrtIoBinding *binding_ptr) __attribute__((nonnull))
Clears any previously set Outputs for an OrtIoBinding.
◆ CreateKeyValuePairs
Create an OrtKeyValuePairs instance.
- Parameters
-
[out] out A pointer to a newly created OrtKeyValuePairs instance.
- Note
- Must be released by calling ReleaseKeyValuePairs.
- Since
- Version 1.22.
◆ CreateStatus
Create an OrtStatus from a null terminated string.
- Parameters
-
[in] code [in] msg A null-terminated string. Its contents will be copied.
- Returns
- A new OrtStatus object, must be destroyed with OrtApi::ReleaseStatus
◆ EpDevice_Device
Get the OrtHardwareDevice instance for the OrtEpDevice.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query.
- Returns
- The OrtHardwareDevice instance for the device.
- Since
- Version 1.22.
◆ EpDevice_EpMetadata
Get the metadata for the OrtEpDevice.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query.
- Returns
- An OrtKeyValuePairs instance containing the metadata for the device.
- Since
- Version 1.22.
◆ EpDevice_EpName
const char *( * OrtApi::EpDevice_EpName) (const OrtEpDevice *ep_device)
Get the execution provider name.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query.
- Returns
- The execution provider name.
- Since
- Version 1.22.
◆ EpDevice_EpOptions
Get the execution provider options for the OrtEpDevice.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query.
- Returns
- An OrtKeyValuePairs instance containing the execution provider options for the device.
- Since
- Version 1.22.
◆ EpDevice_EpVendor
const char *( * OrtApi::EpDevice_EpVendor) (const OrtEpDevice *ep_device)
Get the execution provider's vendor name.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query.
- Returns
- The execution provider's vendor name.
- Since
- Version 1.22.
◆ EpDevice_MemoryInfo
Get the OrtMemoryInfo for the device.
- Parameters
-
[in] ep_device The OrtEpDevice instance to query. [in] memory_type The memory type to return.
- Returns
- A pointer to the OrtMemoryInfo for the device. This may be nullptr if not set. If memory_type is OrtDeviceMemoryType_DEFAULT and nullptr is returned the EP uses CPU memory.
- Since
- Version 1.23
◆ ExternalInitializerInfo_GetByteSize
Get the size in bytes of the initializer's data within the file.
- Parameters
-
[in] info The OrtExternalInitializerInfo instance.
- Returns
- The size in bytes of the initializer's data within the file.
- Since
- Version 1.23.
◆ ExternalInitializerInfo_GetFileOffset
Get the byte offset within the file where the initializer's data is stored.
- Parameters
-
[in] info The OrtExternalInitializerInfo instance.
- Returns
- The byte offset where the initializer's data is stored within the file.
- Since
- Version 1.23.
◆ ExternalInitializerInfo_GetFilePath
Get the relative path to the file that stores the initializer's data.
- Note
- The path is relative to the filesystem directory where the ONNX model was stored. Caller can use Graph_GetModelPath to get the model's full path and construct the absolute path to the external initializer file if necessary.
- Parameters
-
[in] info The OrtExternalInitializerInfo instance.
- Returns
- The relative path to the file that stores the initializer's data. Do NOT free this pointer.
- Since
- Version 1.23.
◆ GetBuildInfoString
const char *( * OrtApi::GetBuildInfoString) (void)
Returns a null terminated string of the build info including git info and cxx flags.
- Returns
- UTF-8 encoded version string. Do not deallocate the returned buffer.
- Since
- Version 1.15.
◆ GetCompileApi
Get the Compile API instance.
Get the Compile API instance to compile ONNX models. Execution providers that support compilation fuse a subgraph into an EPContext node that wraps a provider-specific binary representation of the subgraph. For more details about the EPContext design, refer to: EPContext design document.
- Returns
- Compile API struct instance.
- Since
- Version 1.22.
◆ GetEpApi
const OrtEpApi *( * OrtApi::GetEpApi) (void)
Get the OrtEpApi instance for implementing an execution provider.
- Since
- Version 1.22.
◆ GetErrorCode
Get OrtErrorCode from OrtStatus.
- Parameters
- Returns
- OrtErrorCode that
statuswas created with
◆ GetErrorMessage
const char *( * OrtApi::GetErrorMessage) (const OrtStatus *status) __attribute__((nonnull))
Get error string from OrtStatus.
- Parameters
- Returns
- The error message inside the
status. Do not free the returned value.
◆ GetInteropApi
Get the EP Interop API instance.
Get the Interop API instance to work with external resources. This API provides functions for importing external GPU memory and semaphores for zero-copy sharing between ORT inference and other GPU workloads.
- Returns
- Interop API struct instance.
- Since
- Version 1.24.
◆ GetKeyValue
const char *( * OrtApi::GetKeyValue) (const OrtKeyValuePairs *kvps, const char *key)
Get the value associated with a key in the OrtKeyValuePairs instance.
- Parameters
-
[in] kvps OrtKeyValuePairs instance. [in] key Key to be searched.
- Returns
- The value associated with the key, or nullptr if the key does not exist.
- Since
- Version 1.22.
◆ GetKeyValuePairs
void( * OrtApi::GetKeyValuePairs) (const OrtKeyValuePairs *kvps, const char *const **keys, const char *const **values, size_t *num_entries)
Get all the key-value pairs from the OrtKeyValuePairs instance.
- Parameters
-
[in] kvps OrtKeyValuePairs instance. [out] keys Array of keys from kvps.[out] values Array of values from kvps.[out] num_entries Number of entries in keysandvalues.
- Since
- Version 1.22.
◆ GetModelEditorApi
Get the Model Editor API instance.
Get the Model Editor API instance to create a new model or augment an existing model.
- Returns
- Model Editor API struct
- Since
- Version 1.22.
◆ GetRunConfigEntry
const char *( * OrtApi::GetRunConfigEntry) (const OrtRunOptions *options, const char *config_key)
Get a run configuration entry.
If a run configuration entry with key config_key doesn't exist, config_value will be set to NULL.
config_keys are defined in onnxruntime_run_options_config_keys.h.
- Parameters
-
[in] options The OrtRunOptions instance. [in] config_key The configuration entry key. A null-terminated string.
- Returns
- The configuration entry value. Either a null-terminated string if the entry was found. nullptr otherwise.
- Returns
- If no error, nullptr will be returned. If there is an error, a pointer to an OrtStatus that contains error details will be returned. Use OrtApi::ReleaseStatus to free this pointer.
- Since
- Version 1.23
◆ GetTrainingApi
Gets the Training C Api struct.
Call this function to access the OrtTrainingApi structure that holds pointers to functions that enable training with onnxruntime.
- Note
- A NULL pointer will be returned and no error message will be printed if the training api is not supported with this build. A NULL pointer will be returned and an error message will be printed if the provided version is unsupported, for example when using a runtime older than the version created with this header file.
- Parameters
- Returns
- The OrtTrainingApi struct for the version requested.
- Since
- Version 1.13
◆ HardwareDevice_DeviceId
Get the hardware device's unique identifier.
- Parameters
-
[in] device The OrtHardwareDevice instance to query.
- Returns
- The device id.
- Note
- This is not a unique identifier. It identifies the hardware type when combined with vendor id.
- Since
- Version 1.22.
◆ HardwareDevice_Metadata
Get hardware device metadata.
- Parameters
-
[in] device The OrtHardwareDevice instance to query.
- Returns
- An OrtKeyValuePairs instance containing the metadata for the device. Note: ORT owns the instance so the user must not call ReleaseKeyValuePairs with it.
- Since
- Version 1.22.
◆ HardwareDevice_Type
Get the hardware device type.
- Parameters
-
[in] device The OrtHardwareDevice instance to query.
- Returns
- The hardware device type.
- Since
- Version 1.22.
◆ HardwareDevice_Vendor
Get the hardware device's vendor name.
- Parameters
-
[in] device The OrtHardwareDevice instance to query.
- Returns
- The hardware device's vendor name.
- Since
- Version 1.22.
◆ HardwareDevice_VendorId
Get the hardware device's vendor identifier.
- Parameters
-
[in] device The OrtHardwareDevice instance to query.
- Returns
- The hardware device vendor identifier.
- Since
- Version 1.22.
◆ MemoryInfoGetDeviceMemType
Get the device memory type from OrtMemoryInfo.
- Parameters
-
[in] ptr The OrtMemoryInfo instance to query.
- Returns
- The device memory type.
- Since
- Version 1.23
◆ MemoryInfoGetDeviceType
◆ MemoryInfoGetVendorId
uint32_t( * OrtApi::MemoryInfoGetVendorId) (const OrtMemoryInfo *ptr)
Get the vendor id from OrtMemoryInfo.
- Parameters
-
[in] ptr The OrtMemoryInfo instance to query.
- Returns
- The vendor id.
- Since
- Version 1.23
◆ ReleaseCANNProviderOptions
Release an OrtCANNProviderOptions.
- Parameters
-
[in] input The pointer of OrtCANNProviderOptions which will been deleted
- Since
- Version 1.13.
◆ ReleaseCUDAProviderOptions
Release an OrtCUDAProviderOptionsV2.
- Note
- This is an exception in the naming convention of other Release* functions, as the name of the method does not have the V2 suffix, but the type does
- Since
- Version 1.11.
◆ ReleaseDnnlProviderOptions
◆ ReleaseROCMProviderOptions
Release an OrtROCMProviderOptions.
- Note
- This is an exception in the naming convention of other Release* functions, as the name of the method does not have the V2 suffix, but the type does
- Since
- Version 1.16.
◆ ReleaseTensorRTProviderOptions
Release an OrtTensorRTProviderOptionsV2.
- Note
- This is an exception in the naming convention of other Release* functions, as the name of the method does not have the V2 suffix, but the type does
◆ RemoveKeyValuePair
Remove a key-value pair from the OrtKeyValuePairs instance.
- Parameters
-
[in] kvps OrtKeyValuePairs instance. [in] key Key to be removed. No error if not found.
- Since
- Version 1.22.
◆ RunOptionsSetSyncStream
Sets OrtSyncStream for the run options.
OrtSyncStream is used to synchronize the execution of the model run for the device of the stream. It overrides the existing stream for the duration of the Run(). The stream instance must be alive for the duration of the Run() call.
- Parameters
-
[in] options [in] sync_stream The synchronization stream. Pass nullptr to clear previous setting.
- Since
- 1.24
◆ SyncStream_GetHandle
Get the native handle of the sync stream.
This returns the native handle for the stream. e.g. cudaStream_t for CUDA streams.
- Parameters
-
[in] stream The OrtSyncStream instance to get the handle from.
- Returns
- The native handle of the stream.
- Since
- Version 1.23
◆ TensorTypeAndShape_HasShape
Fetch whether the tensor has shape information.
- Parameters
-
[in] info The OrtTensorTypeAndShapeInfo instance.
- Returns
- true if the tensor has shape information, false otherwise.
- Since
- Version 1.24