OnnxRuntime
|
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. More... | |
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. More... | |
OrtStatus | |
OrtStatus *(* | CreateStatus )(OrtErrorCode code, const char *msg) __attribute__((nonnull)) |
Create an OrtStatus from a null terminated string. More... | |
OrtErrorCode(* | GetErrorCode )(const OrtStatus *status) __attribute__((nonnull)) |
Get OrtErrorCode from OrtStatus. More... | |
const char *(* | GetErrorMessage )(const OrtStatus *status) __attribute__((nonnull)) |
Get error string from OrtStatus. More... | |
void | ReleaseStatus (OrtStatus *input) |
OrtIoBinding | |
void(* | ClearBoundInputs )(OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
Clears any previously set Inputs for an OrtIoBinding. More... | |
void(* | ClearBoundOutputs )(OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
Clears any previously set Outputs for an OrtIoBinding. More... | |
void | ReleaseIoBinding (OrtIoBinding *input) |
Release an OrtIoBinding obtained from OrtApi::CreateIoBinding. More... | |
OrtStatus * | BindInput (OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr) |
Bind an OrtValue to an OrtIoBinding input. More... | |
OrtStatus * | BindOutput (OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr) |
Bind an OrtValue to an OrtIoBinding output. More... | |
OrtStatus * | BindOutputToDevice (OrtIoBinding *binding_ptr, const char *name, const OrtMemoryInfo *mem_info_ptr) |
Bind an OrtIoBinding output to a device. More... | |
OrtStatus * | GetBoundOutputNames (const OrtIoBinding *binding_ptr, OrtAllocator *allocator, char **buffer, size_t **lengths, size_t *count) |
Get the names of an OrtIoBinding's outputs. More... | |
OrtStatus * | GetBoundOutputValues (const OrtIoBinding *binding_ptr, OrtAllocator *allocator, OrtValue ***output, size_t *output_count) |
Get the output OrtValue objects from an OrtIoBinding. More... | |
OrtTensorRTProviderOptionsV2 | |
void(* | ReleaseTensorRTProviderOptions )(OrtTensorRTProviderOptionsV2 *input) |
Release an OrtTensorRTProviderOptionsV2. More... | |
OrtStatus * | CreateTensorRTProviderOptions (OrtTensorRTProviderOptionsV2 **out) |
Create an OrtTensorRTProviderOptionsV2. More... | |
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. More... | |
OrtStatus * | GetTensorRTProviderOptionsAsString (const OrtTensorRTProviderOptionsV2 *tensorrt_options, OrtAllocator *allocator, char **ptr) |
Get serialized TensorRT provider options string. More... | |
OrtCUDAProviderOptionsV2 | |
void(* | ReleaseCUDAProviderOptions )(OrtCUDAProviderOptionsV2 *input) |
Release an OrtCUDAProviderOptionsV2. More... | |
OrtStatus * | CreateCUDAProviderOptions (OrtCUDAProviderOptionsV2 **out) |
Create an OrtCUDAProviderOptionsV2. More... | |
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. More... | |
OrtStatus * | GetCUDAProviderOptionsAsString (const OrtCUDAProviderOptionsV2 *cuda_options, OrtAllocator *allocator, char **ptr) |
OrtEnv | |
OrtStatus * | CreateEnv (OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out) |
Create an OrtEnv. More... | |
OrtStatus * | CreateEnvWithCustomLogger (OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out) |
Create an OrtEnv. More... | |
OrtStatus * | EnableTelemetryEvents (const OrtEnv *env) |
Enable Telemetry. More... | |
OrtStatus * | DisableTelemetryEvents (const OrtEnv *env) |
Disable Telemetry. More... | |
void | ReleaseEnv (OrtEnv *input) |
OrtStatus * | CreateEnvWithGlobalThreadPools (OrtLoggingLevel log_severity_level, const char *logid, const OrtThreadingOptions *tp_options, OrtEnv **out) |
Create an OrtEnv. More... | |
OrtStatus * | CreateAndRegisterAllocator (OrtEnv *env, const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg) |
Create an allocator and register it with the OrtEnv. More... | |
OrtStatus * | SetLanguageProjection (const OrtEnv *ort_env, OrtLanguageProjection projection) |
Set language projection. More... | |
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. More... | |
OrtStatus * | CreateSessionFromArray (const OrtEnv *env, const void *model_data, size_t model_data_length, const OrtSessionOptions *options, OrtSession **out) |
Create an OrtSession from memory. More... | |
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. More... | |
OrtStatus * | SessionGetInputCount (const OrtSession *session, size_t *out) |
Get input count for a session. More... | |
OrtStatus * | SessionGetOutputCount (const OrtSession *session, size_t *out) |
Get output count for a session. More... | |
OrtStatus * | SessionGetOverridableInitializerCount (const OrtSession *session, size_t *out) |
Get overridable initializer count. More... | |
OrtStatus * | SessionGetInputTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
Get input type information. More... | |
OrtStatus * | SessionGetOutputTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
Get output type information. More... | |
OrtStatus * | SessionGetOverridableInitializerTypeInfo (const OrtSession *session, size_t index, OrtTypeInfo **type_info) |
Get overridable initializer type information. More... | |
OrtStatus * | SessionGetInputName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
Get input name. More... | |
OrtStatus * | SessionGetOutputName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
Get output name. More... | |
OrtStatus * | SessionGetOverridableInitializerName (const OrtSession *session, size_t index, OrtAllocator *allocator, char **value) |
Get overridable initializer name. More... | |
void | ReleaseSession (OrtSession *input) |
OrtStatus * | SessionEndProfiling (OrtSession *session, OrtAllocator *allocator, char **out) |
End profiling and return filename of the profile data. More... | |
OrtStatus * | SessionGetModelMetadata (const OrtSession *session, OrtModelMetadata **out) |
Get OrtModelMetadata from an OrtSession. More... | |
OrtStatus * | RunWithBinding (OrtSession *session, const OrtRunOptions *run_options, const OrtIoBinding *binding_ptr) |
Run a model using Io Bindings for the inputs & outputs. More... | |
OrtStatus * | CreateIoBinding (OrtSession *session, OrtIoBinding **out) |
Create an OrtIoBinding instance. More... | |
OrtStatus * | SessionGetProfilingStartTimeNs (const OrtSession *session, uint64_t *out) |
Return the time that profiling was started. More... | |
OrtStatus * | CreateSessionWithPrepackedWeightsContainer (const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtPrepackedWeightsContainer *prepacked_weights_container, OrtSession **out) |
Create session with prepacked weights container. More... | |
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. More... | |
OrtSessionOptions | |
OrtStatus * | CreateSessionOptions (OrtSessionOptions **options) |
Create an OrtSessionOptions object. More... | |
OrtStatus * | SetOptimizedModelFilePath (OrtSessionOptions *options, const char *optimized_model_filepath) |
Set filepath to save optimized model after graph level transformations. More... | |
OrtStatus * | CloneSessionOptions (const OrtSessionOptions *in_options, OrtSessionOptions **out_options) |
Create a copy of an existing OrtSessionOptions. More... | |
OrtStatus * | SetSessionExecutionMode (OrtSessionOptions *options, ExecutionMode execution_mode) |
Set execution mode. More... | |
OrtStatus * | EnableProfiling (OrtSessionOptions *options, const char *profile_file_prefix) |
Enable profiling for a session. More... | |
OrtStatus * | DisableProfiling (OrtSessionOptions *options) |
Disable profiling for a session. More... | |
OrtStatus * | EnableMemPattern (OrtSessionOptions *options) |
Enable the memory pattern optimization. More... | |
OrtStatus * | DisableMemPattern (OrtSessionOptions *options) |
Disable the memory pattern optimization. More... | |
OrtStatus * | EnableCpuMemArena (OrtSessionOptions *options) |
Enable the memory arena on CPU. More... | |
OrtStatus * | DisableCpuMemArena (OrtSessionOptions *options) |
Disable the memory arena on CPU. More... | |
OrtStatus * | SetSessionLogId (OrtSessionOptions *options, const char *logid) |
Set session log id. More... | |
OrtStatus * | SetSessionLogVerbosityLevel (OrtSessionOptions *options, int session_log_verbosity_level) |
Set session log verbosity level. More... | |
OrtStatus * | SetSessionLogSeverityLevel (OrtSessionOptions *options, int session_log_severity_level) |
Set session log severity level. More... | |
OrtStatus * | SetSessionGraphOptimizationLevel (OrtSessionOptions *options, GraphOptimizationLevel graph_optimization_level) |
Set the optimization level to apply when loading a graph. More... | |
OrtStatus * | SetIntraOpNumThreads (OrtSessionOptions *options, int intra_op_num_threads) |
Sets the number of threads used to parallelize the execution within nodes. More... | |
OrtStatus * | SetInterOpNumThreads (OrtSessionOptions *options, int inter_op_num_threads) |
Sets the number of threads used to parallelize the execution of the graph. More... | |
OrtStatus * | AddCustomOpDomain (OrtSessionOptions *options, OrtCustomOpDomain *custom_op_domain) |
Add custom op domain to a session options. More... | |
OrtStatus * | RegisterCustomOpsLibrary (OrtSessionOptions *options, const char *library_path, void **library_handle) |
Register custom ops from a shared library. More... | |
OrtStatus * | AddFreeDimensionOverride (OrtSessionOptions *options, const char *dim_denotation, int64_t dim_value) |
Override session symbolic dimensions. More... | |
void | ReleaseSessionOptions (OrtSessionOptions *input) |
OrtStatus * | DisablePerSessionThreads (OrtSessionOptions *options) |
Use global thread pool on a session. More... | |
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. More... | |
OrtStatus * | AddInitializer (OrtSessionOptions *options, const char *name, const OrtValue *val) |
Add a pre-allocated initializer to a session. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_CUDA (OrtSessionOptions *options, const OrtCUDAProviderOptions *cuda_options) |
Append CUDA provider to session options. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_ROCM (OrtSessionOptions *options, const OrtROCMProviderOptions *rocm_options) |
Append ROCM execution provider to the session options. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_OpenVINO (OrtSessionOptions *options, const OrtOpenVINOProviderOptions *provider_options) |
Append OpenVINO execution provider to the session options. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_TensorRT (OrtSessionOptions *options, const OrtTensorRTProviderOptions *tensorrt_options) |
Append TensorRT provider to session options. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_TensorRT_V2 (OrtSessionOptions *options, const OrtTensorRTProviderOptionsV2 *tensorrt_options) |
Append TensorRT execution provider to the session options. More... | |
OrtStatus * | EnableOrtCustomOps (OrtSessionOptions *options) |
Enable custom operators. More... | |
OrtStatus * | SessionOptionsAppendExecutionProvider_CUDA_V2 (OrtSessionOptions *options, const OrtCUDAProviderOptionsV2 *cuda_options) |
Append CUDA execution provider to the session options. More... | |
OrtCustomOpDomain | |
OrtStatus * | CreateCustomOpDomain (const char *domain, OrtCustomOpDomain **out) |
Create a custom op domain. More... | |
OrtStatus * | CustomOpDomain_Add (OrtCustomOpDomain *custom_op_domain, const OrtCustomOp *op) |
Add a custom op to a custom op domain. More... | |
void | ReleaseCustomOpDomain (OrtCustomOpDomain *input) |
OrtRunOptions | |
OrtStatus * | CreateRunOptions (OrtRunOptions **out) |
Create an OrtRunOptions. More... | |
OrtStatus * | RunOptionsSetRunLogVerbosityLevel (OrtRunOptions *options, int log_verbosity_level) |
Set per-run log verbosity level. More... | |
OrtStatus * | RunOptionsSetRunLogSeverityLevel (OrtRunOptions *options, int log_severity_level) |
Set per-run log severity level. More... | |
OrtStatus * | RunOptionsSetRunTag (OrtRunOptions *options, const char *run_tag) |
Set per-run tag. More... | |
OrtStatus * | RunOptionsGetRunLogVerbosityLevel (const OrtRunOptions *options, int *log_verbosity_level) |
Get per-run log verbosity level. More... | |
OrtStatus * | RunOptionsGetRunLogSeverityLevel (const OrtRunOptions *options, int *log_severity_level) |
Get per-run log severity level. More... | |
OrtStatus * | RunOptionsGetRunTag (const OrtRunOptions *options, const char **run_tag) |
Get per-run tag. More... | |
OrtStatus * | RunOptionsSetTerminate (OrtRunOptions *options) |
Set terminate flag. More... | |
OrtStatus * | RunOptionsUnsetTerminate (OrtRunOptions *options) |
Clears the terminate flag. More... | |
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. More... | |
OrtValue | |
OrtStatus * | CreateTensorAsOrtValue (OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out) |
Create a tensor. More... | |
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. More... | |
OrtStatus * | IsTensor (const OrtValue *value, int *out) |
Return if an OrtValue is a tensor type. More... | |
OrtStatus * | GetTensorMutableData (OrtValue *value, void **out) |
Get a pointer to the raw data inside a tensor. More... | |
OrtStatus * | FillStringTensor (OrtValue *value, const char *const *s, size_t s_len) |
Set all strings at once in a string tensor. More... | |
OrtStatus * | GetStringTensorDataLength (const OrtValue *value, size_t *len) |
Get total byte length for all strings in a string tensor. More... | |
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. More... | |
OrtStatus * | GetTensorTypeAndShape (const OrtValue *value, OrtTensorTypeAndShapeInfo **out) |
Get type and shape information from a tensor OrtValue. More... | |
OrtStatus * | GetTypeInfo (const OrtValue *value, OrtTypeInfo **out) |
Get type information of an OrtValue. More... | |
OrtStatus * | GetValueType (const OrtValue *value, enum ONNXType *out) |
Get ONNXType of an OrtValue. More... | |
OrtStatus * | GetValue (const OrtValue *value, int index, OrtAllocator *allocator, OrtValue **out) |
Get non tensor data from an OrtValue. More... | |
OrtStatus * | GetValueCount (const OrtValue *value, size_t *out) |
Get non tensor value count from an OrtValue. More... | |
OrtStatus * | CreateValue (const OrtValue *const *in, size_t num_values, enum ONNXType value_type, OrtValue **out) |
Create a map or sequence OrtValue. More... | |
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. More... | |
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. More... | |
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. More... | |
OrtStatus * | GetStringTensorElement (const OrtValue *value, size_t s_len, size_t index, void *s) |
Get a single string from a string tensor. More... | |
OrtStatus * | FillStringTensorElement (OrtValue *value, const char *s, size_t index) |
Set a single string in a string tensor. More... | |
OrtStatus * | TensorAt (OrtValue *value, const int64_t *location_values, size_t location_values_count, void **out) |
Direct memory access to a specified tensor element. More... | |
OrtStatus * | IsSparseTensor (const OrtValue *value, int *out) |
Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise. More... | |
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. More... | |
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. More... | |
OrtStatus * | GetSparseTensorValuesTypeAndShape (const OrtValue *ort_value, OrtTensorTypeAndShapeInfo **out) |
Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor. More... | |
OrtStatus * | GetSparseTensorValues (const OrtValue *ort_value, const void **out) |
Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*(). More... | |
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. More... | |
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. More... | |
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. More... | |
OrtTypeInfo | |
OrtStatus * | CastTypeInfoToTensorInfo (const OrtTypeInfo *type_info, const OrtTensorTypeAndShapeInfo **out) |
Get OrtTensorTypeAndShapeInfo from an OrtTypeInfo. More... | |
OrtStatus * | GetOnnxTypeFromTypeInfo (const OrtTypeInfo *type_info, enum ONNXType *out) |
Get ONNXType from OrtTypeInfo. More... | |
void | ReleaseTypeInfo (OrtTypeInfo *input) |
OrtStatus * | GetDenotationFromTypeInfo (const OrtTypeInfo *type_info, const char **const denotation, size_t *len) |
Get denotation from type information. More... | |
OrtStatus * | CastTypeInfoToMapTypeInfo (const OrtTypeInfo *type_info, const OrtMapTypeInfo **out) |
Get detailed map information from an OrtTypeInfo. More... | |
OrtStatus * | CastTypeInfoToSequenceTypeInfo (const OrtTypeInfo *type_info, const OrtSequenceTypeInfo **out) |
Cast OrtTypeInfo to an OrtSequenceTypeInfo. More... | |
OrtKernelInfo | |
OrtStatus * | KernelInfoGetAttribute_float (const OrtKernelInfo *info, const char *name, float *out) |
Get a float stored as an attribute in the graph node. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
OrtKernelContext | |
OrtStatus * | KernelContext_GetInputCount (const OrtKernelContext *context, size_t *out) |
Used for custom operators, get the input count of a kernel. More... | |
OrtStatus * | KernelContext_GetOutputCount (const OrtKernelContext *context, size_t *out) |
Used for custom operators, get the output count of a kernel. More... | |
OrtStatus * | KernelContext_GetInput (const OrtKernelContext *context, size_t index, const OrtValue **out) |
Used for custom operators, get an input of a kernel. More... | |
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. More... | |
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 More... | |
OrtMapTypeInfo | |
OrtStatus * | GetMapKeyType (const OrtMapTypeInfo *map_type_info, enum ONNXTensorElementDataType *out) |
Get key type from an OrtMapTypeInfo. More... | |
OrtStatus * | GetMapValueType (const OrtMapTypeInfo *map_type_info, OrtTypeInfo **type_info) |
Get the value type from an OrtMapTypeInfo. More... | |
void | ReleaseMapTypeInfo (OrtMapTypeInfo *input) |
OrtSequenceTypeInfo | |
OrtStatus * | GetSequenceElementType (const OrtSequenceTypeInfo *sequence_type_info, OrtTypeInfo **type_info) |
Get element type from an OrtSequenceTypeInfo. More... | |
void | ReleaseSequenceTypeInfo (OrtSequenceTypeInfo *input) |
OrtModelMetadata | |
OrtStatus * | ModelMetadataGetProducerName (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get producer name from an OrtModelMetadata. More... | |
OrtStatus * | ModelMetadataGetGraphName (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get graph name from an OrtModelMetadata. More... | |
OrtStatus * | ModelMetadataGetDomain (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get domain from an OrtModelMetadata. More... | |
OrtStatus * | ModelMetadataGetDescription (const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value) |
Get description from an OrtModelMetadata. More... | |
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. More... | |
OrtStatus * | ModelMetadataGetVersion (const OrtModelMetadata *model_metadata, int64_t *value) |
Get version number from an OrtModelMetadata. More... | |
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. More... | |
void | ReleaseThreadingOptions (OrtThreadingOptions *input) |
OrtStatus * | SetGlobalIntraOpNumThreads (OrtThreadingOptions *tp_options, int intra_op_num_threads) |
Set global intra-op thread count. More... | |
OrtStatus * | SetGlobalInterOpNumThreads (OrtThreadingOptions *tp_options, int inter_op_num_threads) |
Set global inter-op thread count. More... | |
OrtStatus * | SetGlobalSpinControl (OrtThreadingOptions *tp_options, int allow_spinning) |
Set global spin control options. More... | |
OrtStatus * | SetGlobalDenormalAsZero (OrtThreadingOptions *tp_options) |
Set threading flush-to-zero and denormal-as-zero. More... | |
OrtStatus * | SetGlobalCustomCreateThreadFn (OrtThreadingOptions *tp_options, OrtCustomCreateThreadFn ort_custom_create_thread_fn) |
Set custom thread creation function for global thread pools. More... | |
OrtStatus * | SetGlobalCustomThreadCreationOptions (OrtThreadingOptions *tp_options, void *ort_custom_thread_creation_options) |
Set custom thread creation options for global thread pools. More... | |
OrtStatus * | SetGlobalCustomJoinThreadFn (OrtThreadingOptions *tp_options, OrtCustomJoinThreadFn ort_custom_join_thread_fn) |
Set custom thread join function for global thread pools. More... | |
Misc | |
OrtStatus * | GetAvailableProviders (char ***out_ptr, int *provider_length) |
Get the names of all available providers. More... | |
OrtStatus * | ReleaseAvailableProviders (char **ptr, int providers_length) |
Release data from OrtApi::GetAvailableProviders. More... | |
OrtStatus * | SetCurrentGpuDeviceId (int device_id) |
Set current GPU device ID. More... | |
OrtStatus * | GetCurrentGpuDeviceId (int *device_id) |
Get current GPU device ID. More... | |
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. More... | |
OrtPrepackedWeightsContainer | |
OrtStatus * | CreatePrepackedWeightsContainer (OrtPrepackedWeightsContainer **out) |
Create an OrtPrepackedWeightsContainer. More... | |
void | ReleasePrepackedWeightsContainer (OrtPrepackedWeightsContainer *input) |
Release OrtPrepackedWeightsContainer instance. More... | |
GetTensorMemoryInfo | |
OrtStatus * | GetTensorMemoryInfo (const OrtValue *value, const OrtMemoryInfo **mem_info) |
Returns a pointer to the OrtMemoryInfo of a Tensor. More... | |
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. More... | |
SessionOptions | |
OrtStatus * | SessionOptionsSetCustomCreateThreadFn (OrtSessionOptions *options, OrtCustomCreateThreadFn ort_custom_create_thread_fn) |
Set custom thread creation function. More... | |
OrtStatus * | SessionOptionsSetCustomThreadCreationOptions (OrtSessionOptions *options, void *ort_custom_thread_creation_options) |
Set creation options for custom thread. More... | |
OrtStatus * | SessionOptionsSetCustomJoinThreadFn (OrtSessionOptions *options, OrtCustomJoinThreadFn ort_custom_join_thread_fn) |
Set custom thread join function. More... | |
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
OrtStatus * OrtApi::AddCustomOpDomain | ( | OrtSessionOptions * | options, |
OrtCustomOpDomain * | custom_op_domain | ||
) |
Add custom op domain to a session options.
[in] | options | |
[in] | custom_op_domain |
OrtStatus * OrtApi::AddFreeDimensionOverride | ( | OrtSessionOptions * | options, |
const char * | dim_denotation, | ||
int64_t | dim_value | ||
) |
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)
[in] | options | |
[in] | dim_denotation | |
[in] | dim_value |
OrtStatus * OrtApi::AddFreeDimensionOverrideByName | ( | OrtSessionOptions * | options, |
const char * | dim_name, | ||
int64_t | dim_value | ||
) |
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)
OrtStatus * OrtApi::AddInitializer | ( | OrtSessionOptions * | options, |
const char * | name, | ||
const OrtValue * | val | ||
) |
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.
[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. |
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
[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 |
OrtStatus * OrtApi::AddSessionConfigEntry | ( | OrtSessionOptions * | options, |
const char * | config_key, | ||
const char * | config_value | ||
) |
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
[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 |
OrtStatus * OrtApi::AllocatorAlloc | ( | OrtAllocator * | ort_allocator, |
size_t | size, | ||
void ** | out | ||
) |
Calls OrtAllocator::Alloc function.
OrtStatus * OrtApi::AllocatorFree | ( | OrtAllocator * | ort_allocator, |
void * | p | ||
) |
Calls OrtAllocator::Free function.
OrtStatus * OrtApi::AllocatorGetInfo | ( | const OrtAllocator * | ort_allocator, |
const struct OrtMemoryInfo ** | out | ||
) |
Calls OrtAllocator::Info function.
OrtStatus * OrtApi::BindInput | ( | OrtIoBinding * | binding_ptr, |
const char * | name, | ||
const OrtValue * | val_ptr | ||
) |
Bind an OrtValue to an OrtIoBinding input.
When using OrtApi::RunWithBinding this value is used for the named input
[in] | binding_ptr | |
[in] | name | Name for the model input |
[in] | val_ptr | OrtValue of Tensor type. |
OrtStatus * OrtApi::BindOutput | ( | OrtIoBinding * | binding_ptr, |
const char * | name, | ||
const OrtValue * | val_ptr | ||
) |
Bind an OrtValue to an OrtIoBinding output.
When using OrtApi::RunWithBinding this value is used for the named output
[in] | binding_ptr | |
[in] | name | Null terminated string of the model output name |
[in] | val_ptr | OrtValue of Tensor type. |
OrtStatus * OrtApi::BindOutputToDevice | ( | OrtIoBinding * | binding_ptr, |
const char * | name, | ||
const OrtMemoryInfo * | mem_info_ptr | ||
) |
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.
[in] | binding_ptr | |
[in] | name | Null terminated string of the device name |
[in] | mem_info_ptr |
OrtStatus * OrtApi::CastTypeInfoToMapTypeInfo | ( | const OrtTypeInfo * | type_info, |
const OrtMapTypeInfo ** | out | ||
) |
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.
[out] | type_info | |
[out] | out | A pointer to the OrtMapTypeInfo. Do not free this value |
OrtStatus * OrtApi::CastTypeInfoToSequenceTypeInfo | ( | const OrtTypeInfo * | type_info, |
const OrtSequenceTypeInfo ** | out | ||
) |
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.
[in] | type_info | |
[out] | out | A pointer to the OrtSequenceTypeInfo. Do not free this value |
OrtStatus * OrtApi::CastTypeInfoToTensorInfo | ( | const OrtTypeInfo * | type_info, |
const OrtTensorTypeAndShapeInfo ** | out | ||
) |
Get OrtTensorTypeAndShapeInfo from an OrtTypeInfo.
[in] | type_info | |
[out] | out | Do not free this value, it will be valid until type_info is freed. |
OrtStatus * OrtApi::CloneSessionOptions | ( | const OrtSessionOptions * | in_options, |
OrtSessionOptions ** | out_options | ||
) |
Create a copy of an existing OrtSessionOptions.
[in] | in_options | OrtSessionOptions to copy |
[out] | out_options | Returned newly created OrtSessionOptions. Must be freed with OrtApi::ReleaseSessionOptions |
OrtStatus * OrtApi::CompareMemoryInfo | ( | const OrtMemoryInfo * | info1, |
const OrtMemoryInfo * | info2, | ||
int * | out | ||
) |
Compare OrtMemoryInfo objects for equality.
Compares all settings of each OrtMemoryInfo for equality
[in] | info1 | |
[in] | info2 | |
[out] | out | Set to 0 if equal, -1 if not equal |
OrtStatus * OrtApi::CreateAllocator | ( | const OrtSession * | session, |
const OrtMemoryInfo * | mem_info, | ||
OrtAllocator ** | out | ||
) |
Create an allocator for an OrtSession following an OrtMemoryInfo.
[in] | session | |
[in] | mem_info | valid OrtMemoryInfo instance |
[out] | out | Newly created OrtAllocator. Must be freed with OrtApi::ReleaseAllocator |
OrtStatus * OrtApi::CreateAndRegisterAllocator | ( | OrtEnv * | env, |
const OrtMemoryInfo * | mem_info, | ||
const OrtArenaCfg * | arena_cfg | ||
) |
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/reference/api/c-api.html for details.
[in] | env | OrtEnv instance |
[in] | mem_info | |
[in] | arena_cfg | Pass nullptr for defaults |
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
[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 |
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/reference/api/c-api.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. Ultimately, the allocation size is determined by the allocation memory request. Further allocation sizes are governed by the arena extend strategy.
[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_keys and arena_config_values |
[out] | out | Newly created OrtArenaCfg. Must be freed with OrtApi::ReleaseArenaCfg |
OrtStatus * OrtApi::CreateCpuMemoryInfo | ( | enum OrtAllocatorType | type, |
enum OrtMemType | mem_type, | ||
OrtMemoryInfo ** | out | ||
) |
Create an OrtMemoryInfo for CPU memory.
Special case version of OrtApi::CreateMemoryInfo for CPU based memory. Same as using OrtApi::CreateMemoryInfo with name = "Cpu" and id = 0.
[in] | type | |
[in] | mem_type | |
[out] | out |
OrtStatus * OrtApi::CreateCUDAProviderOptions | ( | OrtCUDAProviderOptionsV2 ** | out | ) |
Create an OrtCUDAProviderOptionsV2.
[out] | out | Newly created OrtCUDAProviderOptionsV2. Must be released with OrtApi::ReleaseCudaProviderOptions |
OrtStatus * OrtApi::CreateCustomOpDomain | ( | const char * | domain, |
OrtCustomOpDomain ** | out | ||
) |
Create a custom op domain.
[in] | domain | |
[out] | out | Newly created domain. Must be freed with OrtApi::ReleaseCustomOpDomain |
OrtStatus * OrtApi::CreateEnv | ( | OrtLoggingLevel | log_severity_level, |
const char * | logid, | ||
OrtEnv ** | out | ||
) |
Create an OrtEnv.
[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 |
OrtStatus * OrtApi::CreateEnvWithCustomLogger | ( | OrtLoggingFunction | logging_function, |
void * | logger_param, | ||
OrtLoggingLevel | log_severity_level, | ||
const char * | logid, | ||
OrtEnv ** | out | ||
) |
Create an OrtEnv.
[in] | logging_function | A pointer to a logging function. |
[in] | logger_param | A pointer to arbitrary data passed as the OrtLoggingFunction param parameter to logging_function . |
[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 |
OrtStatus * OrtApi::CreateEnvWithCustomLoggerAndGlobalThreadPools | ( | OrtLoggingFunction | logging_function, |
void * | logger_param, | ||
OrtLoggingLevel | log_severity_level, | ||
const char * | logid, | ||
const struct OrtThreadingOptions * | tp_options, | ||
OrtEnv ** | out | ||
) |
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.
[in] | logging_function | A pointer to a logging function. |
[in] | logger_param | A pointer to arbitrary data passed as the OrtLoggingFunction param parameter to logging_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 |
OrtStatus * OrtApi::CreateEnvWithGlobalThreadPools | ( | OrtLoggingLevel | log_severity_level, |
const char * | logid, | ||
const OrtThreadingOptions * | tp_options, | ||
OrtEnv ** | out | ||
) |
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.
[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 |
OrtStatus * OrtApi::CreateIoBinding | ( | OrtSession * | session, |
OrtIoBinding ** | out | ||
) |
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.
[in] | session | |
[out] | out | Newly created OrtIoBinding. Must be freed with OrtApi::ReleaseIoBinding |
OrtStatus * OrtApi::CreateMemoryInfo | ( | const char * | name, |
enum OrtAllocatorType | type, | ||
int | id, | ||
enum OrtMemType | mem_type, | ||
OrtMemoryInfo ** | out | ||
) |
Create an OrtMemoryInfo.
[in] | name | |
[in] | type | |
[in] | id | |
[in] | mem_type | |
[out] | out | Newly created OrtMemoryInfo. Must be freed with OrtAPi::ReleaseMemoryInfo |
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.
[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_container points to |
[out] | out | Newly created OrtValue. Must be freed with OrtApi::ReleaseValue |
OrtStatus * OrtApi::CreatePrepackedWeightsContainer | ( | OrtPrepackedWeightsContainer ** | out | ) |
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.
[out] | out | Newly created OrtPrepackedWeightsContainer. Must be freed with OrtApi::ReleasePrepackedWeightsContainer |
OrtStatus * OrtApi::CreateRunOptions | ( | OrtRunOptions ** | out | ) |
Create an OrtRunOptions.
[out] | out | Returned newly created OrtRunOptions. Must be freed with OrtApi::ReleaseRunOptions |
OrtStatus * OrtApi::CreateSession | ( | const OrtEnv * | env, |
const char * | model_path, | ||
const OrtSessionOptions * | options, | ||
OrtSession ** | out | ||
) |
Create an OrtSession from a model file.
[in] | env | |
[in] | model_path | |
[in] | options | |
[out] | out | Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession |
OrtStatus * OrtApi::CreateSessionFromArray | ( | const OrtEnv * | env, |
const void * | model_data, | ||
size_t | model_data_length, | ||
const OrtSessionOptions * | options, | ||
OrtSession ** | out | ||
) |
Create an OrtSession from memory.
[in] | env | |
[in] | model_data | |
[in] | model_data_length | |
[in] | options | |
[out] | out | Returned newly created OrtSession. Must be freed with OrtApi::ReleaseSession |
OrtStatus * OrtApi::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.
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.
[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 |
OrtStatus * OrtApi::CreateSessionOptions | ( | OrtSessionOptions ** | options | ) |
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.
[out] | options | The newly created OrtSessionOptions. Must be freed with OrtApi::ReleaseSessionOptions |
OrtStatus * OrtApi::CreateSessionWithPrepackedWeightsContainer | ( | const OrtEnv * | env, |
const char * | model_path, | ||
const OrtSessionOptions * | options, | ||
OrtPrepackedWeightsContainer * | prepacked_weights_container, | ||
OrtSession ** | out | ||
) |
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.
[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 |
OrtStatus * OrtApi::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.
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.
[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 |
OrtStatus * OrtApi::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 | ||
) |
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.
[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 |
OrtStatus * OrtApi::CreateTensorAsOrtValue | ( | OrtAllocator * | allocator, |
const int64_t * | shape, | ||
size_t | shape_len, | ||
ONNXTensorElementDataType | type, | ||
OrtValue ** | out | ||
) |
Create a tensor.
Create a tensor using a supplied OrtAllocator
[in] | allocator | |
[in] | shape | Tensor shape |
[in] | shape_len | Number of elements in shape |
[in] | type | |
[out] | out | Returns newly created OrtValue. Must be freed with OrtApi::ReleaseValue |
OrtStatus * OrtApi::CreateTensorRTProviderOptions | ( | OrtTensorRTProviderOptionsV2 ** | out | ) |
Create an OrtTensorRTProviderOptionsV2.
[out] | out | Newly created OrtTensorRTProviderOptionsV2. Must be released with OrtApi::ReleaseTensorRTProviderOptions |
OrtStatus * OrtApi::CreateTensorTypeAndShapeInfo | ( | OrtTensorTypeAndShapeInfo ** | out | ) |
Create an OrtTensorTypeAndShapeInfo object.
[out] | out | Returns newly created OrtTensorTypeAndShapeInfo. Must be freed with OrtApi::ReleaseTensorTypeAndShapeInfo |
OrtStatus * OrtApi::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.
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.
[in] | info | |
[in] | p_data | |
[in] | p_data_len | |
[in] | shape | |
[in] | shape_len | |
[in] | type | |
[out] | out | Returns newly created OrtValue. Must be freed with OrtApi::ReleaseValue |
OrtStatus * OrtApi::CreateThreadingOptions | ( | OrtThreadingOptions ** | out | ) |
Create an OrtThreadingOptions.
[out] | out | Newly created OrtThreadingOptions. Must be freed with OrtApi::ReleaseThreadingOptions
|
OrtStatus * OrtApi::CreateValue | ( | const OrtValue *const * | in, |
size_t | num_values, | ||
enum ONNXType | value_type, | ||
OrtValue ** | out | ||
) |
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.
[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 |
OrtStatus * OrtApi::CustomOpDomain_Add | ( | OrtCustomOpDomain * | custom_op_domain, |
const OrtCustomOp * | op | ||
) |
Add a custom op to a custom op domain.
[in] | custom_op_domain | |
[in] | op |
OrtStatus * OrtApi::DisableCpuMemArena | ( | OrtSessionOptions * | options | ) |
Disable the memory arena on CPU.
[in] | options |
OrtStatus * OrtApi::DisableMemPattern | ( | OrtSessionOptions * | options | ) |
Disable the memory pattern optimization.
[in] | options |
OrtStatus * OrtApi::DisablePerSessionThreads | ( | OrtSessionOptions * | options | ) |
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.
[in] | options |
OrtStatus * OrtApi::DisableProfiling | ( | OrtSessionOptions * | options | ) |
Disable profiling for a session.
[in] | options |
Disable Telemetry.
[in] | env |
OrtStatus * OrtApi::EnableCpuMemArena | ( | OrtSessionOptions * | options | ) |
Enable the memory arena on CPU.
Arena may pre-allocate memory for future usage.
[in] | options |
OrtStatus * OrtApi::EnableMemPattern | ( | OrtSessionOptions * | options | ) |
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.
[in] | options |
OrtStatus * OrtApi::EnableOrtCustomOps | ( | OrtSessionOptions * | options | ) |
Enable custom operators.
See onnxruntime-extensions: https://github.com/microsoft/onnxruntime-extensions.git
OrtStatus * OrtApi::EnableProfiling | ( | OrtSessionOptions * | options, |
const char * | profile_file_prefix | ||
) |
Enable profiling for a session.
[in] | options | |
[in] | profile_file_prefix |
Enable Telemetry.
[in] | env |
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.
[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. |
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.
[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 |
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.
[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 |
Set all strings at once in a string tensor.
[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's tensor shape) |
Set a single string in a string tensor.
[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 |
OrtStatus * OrtApi::GetAllocatorWithDefaultOptions | ( | OrtAllocator ** | out | ) |
Get the default allocator.
The default allocator is a CPU based, non-arena. Always returns the same pointer to the same default allocator.
[out] | out | Returned value should NOT be freed |
OrtStatus * OrtApi::GetAvailableProviders | ( | char *** | out_ptr, |
int * | provider_length | ||
) |
Get the names of all available providers.
[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_ptr array |
OrtStatus * OrtApi::GetBoundOutputNames | ( | const OrtIoBinding * | binding_ptr, |
OrtAllocator * | allocator, | ||
char ** | buffer, | ||
size_t ** | lengths, | ||
size_t * | count | ||
) |
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.
[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 allocator and must be freed using it. |
[out] | lengths | Returns an array of count lengths of the strings returned in buffer This buffer is allocated using allocator and must be freed using it. |
[out] | count | Number of strings returned. If binding_ptr has no bound outputs, zero is returned, no memory allocation is performed and buffer and lengths are set to nullptr. |
OrtStatus * OrtApi::GetBoundOutputValues | ( | const OrtIoBinding * | binding_ptr, |
OrtAllocator * | allocator, | ||
OrtValue *** | output, | ||
size_t * | output_count | ||
) |
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.
[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 |
OrtStatus * OrtApi::GetCUDAProviderOptionsAsString | ( | const OrtCUDAProviderOptionsV2 * | cuda_options, |
OrtAllocator * | allocator, | ||
char ** | ptr | ||
) |
Get serialized CUDA provider options string.
For example, "device_id=0;arena_extend_strategy=0;......"
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. |
OrtStatus * OrtApi::GetCurrentGpuDeviceId | ( | int * | device_id | ) |
Get current GPU device ID.
Get the current device id of the GPU execution provider (CUDA/tensorrt/rocm).
[out] | device_id |
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.
[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 |
OrtStatus * OrtApi::GetDimensions | ( | const OrtTensorTypeAndShapeInfo * | info, |
int64_t * | dim_values, | ||
size_t | dim_values_length | ||
) |
Get dimensions in OrtTensorTypeAndShapeInfo.
[in] | info | |
[out] | dim_values | Array with dim_values_length elements. On return, filled with the dimensions stored in the OrtTensorTypeAndShapeInfo |
[in] | dim_values_length | Number of elements in dim_values . Use OrtApi::GetDimensionsCount to get this value |
OrtStatus * OrtApi::GetDimensionsCount | ( | const OrtTensorTypeAndShapeInfo * | info, |
size_t * | out | ||
) |
Get dimension count in OrtTensorTypeAndShapeInfo.
[in] | info | |
[out] | out |
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.
[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". |
OrtStatus * OrtApi::GetMapKeyType | ( | const OrtMapTypeInfo * | map_type_info, |
enum ONNXTensorElementDataType * | out | ||
) |
Get key type from an OrtMapTypeInfo.
Key types are restricted to being scalar types.
This is used by WinML to support model reflection APIs.
[in] | map_type_info | |
[out] | out |
OrtStatus * OrtApi::GetMapValueType | ( | const OrtMapTypeInfo * | map_type_info, |
OrtTypeInfo ** | type_info | ||
) |
Get the value type from an OrtMapTypeInfo.
[in] | map_type_info | |
[out] | type_info |
OrtStatus * OrtApi::GetOnnxTypeFromTypeInfo | ( | const OrtTypeInfo * | type_info, |
enum ONNXType * | out | ||
) |
Get ONNXType from OrtTypeInfo.
[in] | type_info | |
[out] | out |
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
[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. |
OrtStatus * OrtApi::GetSequenceElementType | ( | const OrtSequenceTypeInfo * | sequence_type_info, |
OrtTypeInfo ** | type_info | ||
) |
Get element type from an OrtSequenceTypeInfo.
This is used by WinML to support model reflection APIs.
[in] | sequence_type_info | |
[out] | type_info |
OrtStatus * OrtApi::GetSparseTensorFormat | ( | const OrtValue * | ort_value, |
enum OrtSparseFormat * | out | ||
) |
Returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor.
[in] | ort_value | OrtValue that contains an instance of sparse tensor |
[out] | out | pointer to out parameter |
OrtStatus * OrtApi::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.
[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 |
OrtStatus * OrtApi::GetSparseTensorIndicesTypeShape | ( | const OrtValue * | ort_value, |
enum OrtSparseIndicesFormat | indices_format, | ||
OrtTensorTypeAndShapeInfo ** | out | ||
) |
Returns data type, shape for the type of indices specified by indices_format.
[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] | out | an instance of OrtTensorTypeAndShapeInfo. Must be freed by OrtApi::ReleaseTensorTypeAndShapeInfo |
Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*().
[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. |
OrtStatus * OrtApi::GetSparseTensorValuesTypeAndShape | ( | const OrtValue * | ort_value, |
OrtTensorTypeAndShapeInfo ** | out | ||
) |
Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor.
[in] | ort_value | An OrtValue that contains a fully constructed sparse tensor |
[out] | out | Must be freed by OrtApi::ReleaseTensorTypeAndShapeInfo |
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]
[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 |
Get total byte length for all strings in a string tensor.
Typically used with OrtApi::GetStringTensorContent
[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) |
OrtStatus * OrtApi::GetStringTensorElement | ( | const OrtValue * | value, |
size_t | s_len, | ||
size_t | index, | ||
void * | s | ||
) |
Get a single string from a string tensor.
[in] | value | A string tensor |
[in] | s_len | Number of bytes in the s buffer. 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. |
OrtStatus * OrtApi::GetStringTensorElementLength | ( | const OrtValue * | value, |
size_t | index, | ||
size_t * | out | ||
) |
Get the length of a single string in a string tensor.
[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 |
OrtStatus * OrtApi::GetSymbolicDimensions | ( | const OrtTensorTypeAndShapeInfo * | info, |
const char * | dim_params[], | ||
size_t | dim_params_length | ||
) |
Get symbolic dimension names in OrtTensorTypeAndShapeInfo.
[in] | info | |
[in] | dim_params | Array with dim_params_length elements. 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 |
OrtStatus * OrtApi::GetTensorElementType | ( | const OrtTensorTypeAndShapeInfo * | info, |
enum ONNXTensorElementDataType * | out | ||
) |
Get element type in OrtTensorTypeAndShapeInfo.
[in] | info | |
[out] | out |
OrtStatus * OrtApi::GetTensorMemoryInfo | ( | const OrtValue * | value, |
const OrtMemoryInfo ** | mem_info | ||
) |
Returns a pointer to the OrtMemoryInfo of a Tensor.
[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 |
Get a pointer to the raw data inside a tensor.
Used to read/write/modify the internal tensor data directly.
value
is destroyed.[in] | value | A tensor type (string tensors are not supported) |
[out] | out | Filled in with a pointer to the internal storage |
OrtStatus * OrtApi::GetTensorRTProviderOptionsAsString | ( | const OrtTensorRTProviderOptionsV2 * | tensorrt_options, |
OrtAllocator * | allocator, | ||
char ** | ptr | ||
) |
Get serialized TensorRT provider options string.
For example, "trt_max_workspace_size=2147483648;trt_max_partition_iterations=10;trt_int8_enable=1;......"
tensorrt_options | - OrTensorRTProviderOptionsV2 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. |
OrtStatus * OrtApi::GetTensorShapeElementCount | ( | const OrtTensorTypeAndShapeInfo * | info, |
size_t * | out | ||
) |
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
[in] | info | |
[out] | out | Number of elements |
OrtStatus * OrtApi::GetTensorTypeAndShape | ( | const OrtValue * | value, |
OrtTensorTypeAndShapeInfo ** | out | ||
) |
Get type and shape information from a tensor OrtValue.
[in] | value | Must be a tensor (not a map/sequence/etc) or will return failure |
[out] | out | Newly created OrtTensorTypeAndShapeInfo. Must be freed with OrtApi::ReleaseTensorTypeAndShapeInfo |
OrtStatus * OrtApi::GetTypeInfo | ( | const OrtValue * | value, |
OrtTypeInfo ** | out | ||
) |
Get type information of an OrtValue.
[in] | value | |
[out] | out | Newly created OrtTypeInfo. Must be freed with OrtApi::ReleaseTypeInfo |
OrtStatus * OrtApi::GetValue | ( | const OrtValue * | value, |
int | index, | ||
OrtAllocator * | allocator, | ||
OrtValue ** | out | ||
) |
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.
[in] | value | |
[in] | index | See above for usage based on value type |
[in] | allocator | Allocator used to allocate OrtValue |
[out] | out | Created OrtValue that holds the element requested. Must be freed with OrtApi::ReleaseValue |
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
[in] | value | |
[out] | out |
Get ONNXType of an OrtValue.
[in] | value | |
[out] | 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.
[in] | value | Input OrtValue. |
[out] | out | indicating if the input OrtValue contains data (1) or if it is a None (0) |
Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise.
[in] | value | existing OrtValue |
[out] | out | unless an error occurs, contains 1 iff the value contains an instance of sparse tensor or 0 otherwise. |
Return if an OrtValue is a tensor type.
[in] | value | A tensor type (string tensors are not supported) |
[out] | out | Set to 1 iff OrtValue is a tensor, 0 otherwise |
OrtStatus * OrtApi::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
[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. |
OrtStatus * OrtApi::KernelContext_GetInput | ( | const OrtKernelContext * | context, |
size_t | index, | ||
const OrtValue ** | out | ||
) |
Used for custom operators, get an input of a kernel.
OrtStatus * OrtApi::KernelContext_GetInputCount | ( | const OrtKernelContext * | context, |
size_t * | out | ||
) |
Used for custom operators, get the input count of a kernel.
OrtStatus * OrtApi::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 * OrtApi::KernelContext_GetOutputCount | ( | const OrtKernelContext * | context, |
size_t * | out | ||
) |
Used for custom operators, get the output count of a kernel.
OrtStatus * OrtApi::KernelInfoGetAttribute_float | ( | const OrtKernelInfo * | info, |
const char * | name, | ||
float * | out | ||
) |
Get a float stored as an attribute in the graph node.
[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 |
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.
[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 |
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.)
[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 |
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.)
[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 |
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.)
[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 |
OrtStatus * OrtApi::MemoryInfoGetId | ( | const OrtMemoryInfo * | ptr, |
int * | out | ||
) |
Get the id from OrtMemoryInfo.
OrtStatus * OrtApi::MemoryInfoGetMemType | ( | const OrtMemoryInfo * | ptr, |
OrtMemType * | out | ||
) |
Get the OrtMemType from OrtMemoryInfo.
OrtStatus * OrtApi::MemoryInfoGetName | ( | const OrtMemoryInfo * | ptr, |
const char ** | out | ||
) |
Get name from OrtMemoryInfo.
[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 |
OrtStatus * OrtApi::MemoryInfoGetType | ( | const OrtMemoryInfo * | ptr, |
OrtAllocatorType * | out | ||
) |
Get the OrtAllocatorType from OrtMemoryInfo.
OrtStatus * OrtApi::ModelMetadataGetCustomMetadataMapKeys | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char *** | keys, | ||
int64_t * | num_keys | ||
) |
[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 using allocator keys will be set to nullptr if the custom metadata map is empty. |
[out] | num_keys | Set to the number of elements in the keys array |
OrtStatus * OrtApi::ModelMetadataGetDescription | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get description
from an OrtModelMetadata.
[in] | model_metadata | |
[in] | allocator | |
[out] | value | Set to a null terminated string allocated using allocator . Must be freed using allocator |
OrtStatus * OrtApi::ModelMetadataGetDomain | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get domain
from an OrtModelMetadata.
[in] | model_metadata | |
[in] | allocator | |
[out] | value | Set to a null terminated string allocated using allocator . Must be freed using allocator |
OrtStatus * OrtApi::ModelMetadataGetGraphDescription | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
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.
[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 using allocator |
OrtStatus * OrtApi::ModelMetadataGetGraphName | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get graph name
from an OrtModelMetadata.
[in] | model_metadata | |
[in] | allocator | |
[out] | value | Set to a null terminated string allocated using allocator . Must be freed using allocator |
OrtStatus * OrtApi::ModelMetadataGetProducerName | ( | const OrtModelMetadata * | model_metadata, |
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get producer name
from an OrtModelMetadata.
[in] | model_metadata | |
[in] | allocator | |
[out] | value | Set to a null terminated string allocated using allocator . Must be freed using allocator |
OrtStatus * OrtApi::ModelMetadataGetVersion | ( | const OrtModelMetadata * | model_metadata, |
int64_t * | value | ||
) |
Get version number from an OrtModelMetadata.
[in] | model_metadata | |
[out] | value | Set to the version number |
OrtStatus * OrtApi::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.
[in] | model_metadata | |
[in] | allocator | |
[in] | key | Null terminated string |
[out] | value | Set to a null terminated string allocated using allocator . Must be freed using allocator value will be set to nullptr if the given key is not found in the custom metadata map. |
OrtStatus * OrtApi::RegisterAllocator | ( | OrtEnv * | env, |
OrtAllocator * | allocator | ||
) |
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/reference/api/c-api.html for details.
[in] | env | |
[in] | allocator | User provided allocator |
OrtStatus * OrtApi::RegisterCustomOpsLibrary | ( | OrtSessionOptions * | options, |
const char * | library_path, | ||
void ** | library_handle | ||
) |
Register 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.
[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) |
void OrtApi::ReleaseAllocator | ( | OrtAllocator * | input | ) |
Release an OrtAllocator obtained from OrtApi::CreateAllocator.
void OrtApi::ReleaseArenaCfg | ( | OrtArenaCfg * | input | ) |
OrtStatus * OrtApi::ReleaseAvailableProviders | ( | char ** | ptr, |
int | providers_length | ||
) |
Release data from OrtApi::GetAvailableProviders.
[in] | ptr | The out_ptr result from OrtApi::GetAvailableProviders. |
[in] | providers_length | The provider_length result from OrtApi::GetAvailableProviders |
void OrtApi::ReleaseCustomOpDomain | ( | OrtCustomOpDomain * | input | ) |
void OrtApi::ReleaseEnv | ( | OrtEnv * | input | ) |
void OrtApi::ReleaseIoBinding | ( | OrtIoBinding * | input | ) |
Release an OrtIoBinding obtained from OrtApi::CreateIoBinding.
void OrtApi::ReleaseMapTypeInfo | ( | OrtMapTypeInfo * | input | ) |
void OrtApi::ReleaseMemoryInfo | ( | OrtMemoryInfo * | input | ) |
void OrtApi::ReleaseModelMetadata | ( | OrtModelMetadata * | input | ) |
void OrtApi::ReleasePrepackedWeightsContainer | ( | OrtPrepackedWeightsContainer * | input | ) |
Release OrtPrepackedWeightsContainer instance.
void OrtApi::ReleaseRunOptions | ( | OrtRunOptions * | input | ) |
void OrtApi::ReleaseSequenceTypeInfo | ( | OrtSequenceTypeInfo * | input | ) |
void OrtApi::ReleaseSession | ( | OrtSession * | input | ) |
void OrtApi::ReleaseSessionOptions | ( | OrtSessionOptions * | input | ) |
void OrtApi::ReleaseStatus | ( | OrtStatus * | input | ) |
void OrtApi::ReleaseTensorTypeAndShapeInfo | ( | OrtTensorTypeAndShapeInfo * | input | ) |
void OrtApi::ReleaseThreadingOptions | ( | OrtThreadingOptions * | input | ) |
void OrtApi::ReleaseTypeInfo | ( | OrtTypeInfo * | input | ) |
void OrtApi::ReleaseValue | ( | OrtValue * | input | ) |
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
[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 outputs array. |
OrtStatus * OrtApi::RunOptionsGetRunLogSeverityLevel | ( | const OrtRunOptions * | options, |
int * | log_severity_level | ||
) |
Get per-run log severity level.
[in] | options | |
[out] | log_severity_level | The log severity level (refer to OrtLoggingLevel for possible values). |
OrtStatus * OrtApi::RunOptionsGetRunLogVerbosityLevel | ( | const OrtRunOptions * | options, |
int * | log_verbosity_level | ||
) |
Get per-run log verbosity level.
[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. |
OrtStatus * OrtApi::RunOptionsGetRunTag | ( | const OrtRunOptions * | options, |
const char ** | run_tag | ||
) |
Get per-run tag.
This is used in a per-run log identifier.
[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) or options is freed. |
OrtStatus * OrtApi::RunOptionsSetRunLogSeverityLevel | ( | OrtRunOptions * | options, |
int | log_severity_level | ||
) |
Set per-run log severity level.
[in] | options | |
[in] | log_severity_level | The log severity level (refer to OrtLoggingLevel for possible values). |
OrtStatus * OrtApi::RunOptionsSetRunLogVerbosityLevel | ( | OrtRunOptions * | options, |
int | log_verbosity_level | ||
) |
Set per-run log verbosity level.
[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. |
OrtStatus * OrtApi::RunOptionsSetRunTag | ( | OrtRunOptions * | options, |
const char * | run_tag | ||
) |
Set per-run tag.
This is used in a per-run log identifier.
[in] | options | |
[in] | run_tag | The run tag. |
OrtStatus * OrtApi::RunOptionsSetTerminate | ( | OrtRunOptions * | options | ) |
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.
[in] | options |
OrtStatus * OrtApi::RunOptionsUnsetTerminate | ( | OrtRunOptions * | options | ) |
Clears the terminate flag.
Used so the OrtRunOptions instance can be used in a new OrtApi::Run call without it instantly terminating
[in] | options |
OrtStatus * OrtApi::RunWithBinding | ( | OrtSession * | session, |
const OrtRunOptions * | run_options, | ||
const OrtIoBinding * | binding_ptr | ||
) |
Run a model using Io Bindings for the inputs & outputs.
[in] | session | |
[in] | run_options | |
[in] | binding_ptr |
OrtStatus * OrtApi::SessionEndProfiling | ( | OrtSession * | session, |
OrtAllocator * | allocator, | ||
char ** | out | ||
) |
End profiling and return filename of the profile data.
Profiling is turned on through OrtApi::EnableProfiling
[in] | session | |
[in] | allocator | |
[out] | out | Null terminated string of the filename, allocated using allocator . Must be freed using allocator |
OrtStatus * OrtApi::SessionGetInputCount | ( | const OrtSession * | session, |
size_t * | out | ||
) |
Get input count for a session.
This number must also match the number of inputs passed to OrtApi::Run
[in] | session | |
[out] | out | Number of inputs |
OrtStatus * OrtApi::SessionGetInputName | ( | const OrtSession * | session, |
size_t | index, | ||
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get input name.
[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 using allocator . |
OrtStatus * OrtApi::SessionGetInputTypeInfo | ( | const OrtSession * | session, |
size_t | index, | ||
OrtTypeInfo ** | type_info | ||
) |
Get input type information.
[in] | session | |
[in] | index | Must be between 0 (inclusive) and what OrtApi::SessionGetInputCount returns (exclusive) |
[out] | type_info | Must be freed with OrtApi::ReleaseTypeInfo |
OrtStatus * OrtApi::SessionGetModelMetadata | ( | const OrtSession * | session, |
OrtModelMetadata ** | out | ||
) |
Get OrtModelMetadata from an OrtSession.
[in] | session | |
[out] | out | Newly created OrtModelMetadata. Must be freed using OrtApi::ReleaseModelMetadata |
OrtStatus * OrtApi::SessionGetOutputCount | ( | const OrtSession * | session, |
size_t * | out | ||
) |
Get output count for a session.
This number must also match the number of outputs returned by OrtApi::Run
[in] | session | |
[out] | out | Number of outputs |
OrtStatus * OrtApi::SessionGetOutputName | ( | const OrtSession * | session, |
size_t | index, | ||
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get output name.
[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 using allocator . |
OrtStatus * OrtApi::SessionGetOutputTypeInfo | ( | const OrtSession * | session, |
size_t | index, | ||
OrtTypeInfo ** | type_info | ||
) |
Get output type information.
[in] | session | |
[in] | index | Must be between 0 (inclusive) and what OrtApi::SessionGetOutputCount returns (exclusive) |
[out] | type_info | Must be freed with OrtApi::ReleaseTypeInfo |
OrtStatus * OrtApi::SessionGetOverridableInitializerCount | ( | const OrtSession * | session, |
size_t * | out | ||
) |
Get overridable initializer count.
[in] | session | |
[in] | out |
OrtStatus * OrtApi::SessionGetOverridableInitializerName | ( | const OrtSession * | session, |
size_t | index, | ||
OrtAllocator * | allocator, | ||
char ** | value | ||
) |
Get overridable initializer name.
[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 using allocator . |
OrtStatus * OrtApi::SessionGetOverridableInitializerTypeInfo | ( | const OrtSession * | session, |
size_t | index, | ||
OrtTypeInfo ** | type_info | ||
) |
Get overridable initializer type information.
[in] | session | |
[in] | index | Must be between 0 (inclusive) and what OrtApi::SessionGetOverridableInitializerCount returns (exclusive) |
[out] | type_info | Must be freed with OrtApi::ReleaseTypeInfo |
OrtStatus * OrtApi::SessionGetProfilingStartTimeNs | ( | const OrtSession * | session, |
uint64_t * | out | ||
) |
Return the time that profiling was started.
[in] | session | |
[out] | out | nanoseconds of profiling's start time |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_CUDA | ( | OrtSessionOptions * | options, |
const OrtCUDAProviderOptions * | cuda_options | ||
) |
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.
[in] | options | |
[in] | cuda_options |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_CUDA_V2 | ( | OrtSessionOptions * | options, |
const OrtCUDAProviderOptionsV2 * | cuda_options | ||
) |
Append CUDA execution provider to the session options.
If CUDA is not available (due to a non CUDA enabled build), this function will return failure.
This is slightly different from OrtApi::SessionOptionsAppendExecutionProvider_CUDA, it takes an OrtCUDAProviderOptions which is publicly defined. This takes an opaque OrtCUDAProviderOptionsV2 which must be created with OrtApi::CreateCUDAProviderOptions.
For OrtApi::SessionOptionsAppendExecutionProvider_CUDA, the user needs to instantiate OrtCUDAProviderOptions as well as allocate/release buffers for some members of OrtCUDAProviderOptions. Here, OrtApi::CreateCUDAProviderOptions and Ortapi::ReleaseCUDAProviderOptions will do the memory management for you.
[in] | options | |
[in] | cuda_options |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO | ( | OrtSessionOptions * | options, |
const OrtOpenVINOProviderOptions * | provider_options | ||
) |
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.
[in] | options | |
[in] | provider_options |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_ROCM | ( | OrtSessionOptions * | options, |
const OrtROCMProviderOptions * | rocm_options | ||
) |
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.
[in] | options | |
[in] | rocm_options |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_TensorRT | ( | OrtSessionOptions * | options, |
const OrtTensorRTProviderOptions * | tensorrt_options | ||
) |
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.
[in] | options | |
[in] | tensorrt_options |
OrtStatus * OrtApi::SessionOptionsAppendExecutionProvider_TensorRT_V2 | ( | OrtSessionOptions * | options, |
const OrtTensorRTProviderOptionsV2 * | tensorrt_options | ||
) |
Append TensorRT execution provider to the session options.
If TensorRT is not available (due to a non TensorRT enabled build), this function will return failure.
This is slightly different from OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, it takes an OrtTensorRTProviderOptions which is publicly defined. This takes an opaque OrtTensorRTProviderOptionsV2 which must be created with OrtApi::CreateTensorRTProviderOptions.
For OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, the user needs to instantiate OrtTensorRTProviderOptions as well as allocate/release buffers for some members of OrtTensorRTProviderOptions. Here, OrtApi::CreateTensorRTProviderOptions and Ortapi::ReleaseTensorRTProviderOptions will do the memory management for you.
[in] | options | |
[in] | tensorrt_options |
OrtStatus * OrtApi::SessionOptionsSetCustomCreateThreadFn | ( | OrtSessionOptions * | options, |
OrtCustomCreateThreadFn | ort_custom_create_thread_fn | ||
) |
Set custom thread creation function.
[in] | options | Session options |
[in] | ort_custom_create_thread_fn | Custom thread creation function |
OrtStatus * OrtApi::SessionOptionsSetCustomJoinThreadFn | ( | OrtSessionOptions * | options, |
OrtCustomJoinThreadFn | ort_custom_join_thread_fn | ||
) |
Set custom thread join function.
[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 |
OrtStatus * OrtApi::SessionOptionsSetCustomThreadCreationOptions | ( | OrtSessionOptions * | options, |
void * | ort_custom_thread_creation_options | ||
) |
Set creation options for custom thread.
[in] | options | Session options |
[in] | ort_custom_thread_creation_options | Custom thread creation options (can be nullptr) |
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.
[in] | device_id |
OrtStatus * OrtApi::SetDimensions | ( | OrtTensorTypeAndShapeInfo * | info, |
const int64_t * | dim_values, | ||
size_t | dim_count | ||
) |
Set shape information in OrtTensorTypeAndShapeInfo.
[in] | info | |
[in] | dim_values | Array with dim_count elements. Can contain negative values. |
[in] | dim_count | Number of elements in dim_values |
OrtStatus * OrtApi::SetGlobalCustomCreateThreadFn | ( | OrtThreadingOptions * | tp_options, |
OrtCustomCreateThreadFn | ort_custom_create_thread_fn | ||
) |
Set custom thread creation function for global thread pools.
[in,out] | tp_options | |
[in] | ort_custom_create_thread_fn | Custom thread creation function |
OrtStatus * OrtApi::SetGlobalCustomJoinThreadFn | ( | OrtThreadingOptions * | tp_options, |
OrtCustomJoinThreadFn | ort_custom_join_thread_fn | ||
) |
Set custom thread join function for global thread pools.
[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 |
OrtStatus * OrtApi::SetGlobalCustomThreadCreationOptions | ( | OrtThreadingOptions * | tp_options, |
void * | ort_custom_thread_creation_options | ||
) |
Set custom thread creation options for global thread pools.
[in,out] | tp_options | |
[in] | ort_custom_thread_creation_options | Custom thread creation options (can be nullptr) |
OrtStatus * OrtApi::SetGlobalDenormalAsZero | ( | OrtThreadingOptions * | tp_options | ) |
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.
[in] | tp_options |
OrtStatus * OrtApi::SetGlobalInterOpNumThreads | ( | OrtThreadingOptions * | tp_options, |
int | inter_op_num_threads | ||
) |
Set global inter-op thread count.
This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools
[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. |
OrtStatus * OrtApi::SetGlobalIntraOpNumThreads | ( | OrtThreadingOptions * | tp_options, |
int | intra_op_num_threads | ||
) |
Set global intra-op thread count.
This configures the global thread pool options to be used in the call to OrtApi::CreateEnvWithGlobalThreadPools
[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. |
OrtStatus * OrtApi::SetGlobalSpinControl | ( | OrtThreadingOptions * | tp_options, |
int | allow_spinning | ||
) |
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.
[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 |
OrtStatus * OrtApi::SetInterOpNumThreads | ( | OrtSessionOptions * | options, |
int | inter_op_num_threads | ||
) |
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.
[in] | options | |
[in] | inter_op_num_threads | Number of threads to use A value of 0 will use the default number of threads |
OrtStatus * OrtApi::SetIntraOpNumThreads | ( | OrtSessionOptions * | options, |
int | intra_op_num_threads | ||
) |
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.
[in] | options | |
[in] | intra_op_num_threads | Number of threads to use A value of 0 will use the default number of threads |
OrtStatus * OrtApi::SetLanguageProjection | ( | const OrtEnv * | ort_env, |
OrtLanguageProjection | projection | ||
) |
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.
[in] | ort_env | |
[in] | projection |
OrtStatus * OrtApi::SetOptimizedModelFilePath | ( | OrtSessionOptions * | options, |
const char * | optimized_model_filepath | ||
) |
Set filepath to save optimized model after graph level transformations.
[in] | options | |
[in] | optimized_model_filepath |
OrtStatus * OrtApi::SetSessionExecutionMode | ( | OrtSessionOptions * | options, |
ExecutionMode | execution_mode | ||
) |
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.
[in] | options | |
[in] | execution_mode |
OrtStatus * OrtApi::SetSessionGraphOptimizationLevel | ( | OrtSessionOptions * | options, |
GraphOptimizationLevel | graph_optimization_level | ||
) |
Set the optimization level to apply when loading a graph.
Please see https://www.onnxruntime.ai/docs/resources/graph-optimizations.html for an in-depth explanation
[in,out] | options | The session options object |
[in] | graph_optimization_level | The optimization level |
OrtStatus * OrtApi::SetSessionLogId | ( | OrtSessionOptions * | options, |
const char * | logid | ||
) |
Set session log id.
[in] | options | |
[in] | logid | The log identifier. |
OrtStatus * OrtApi::SetSessionLogSeverityLevel | ( | OrtSessionOptions * | options, |
int | session_log_severity_level | ||
) |
Set session log severity level.
[in] | options | |
[in] | session_log_severity_level | The log severity level (refer to OrtLoggingLevel for possible values). |
OrtStatus * OrtApi::SetSessionLogVerbosityLevel | ( | OrtSessionOptions * | options, |
int | session_log_verbosity_level | ||
) |
Set session log verbosity level.
Applies to session load, initialization, etc
[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. |
OrtStatus * OrtApi::SetTensorElementType | ( | OrtTensorTypeAndShapeInfo * | info, |
enum ONNXTensorElementDataType | type | ||
) |
Set element type in OrtTensorTypeAndShapeInfo.
[in] | info | |
[in] | type |
OrtStatus * OrtApi::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.
[in,out] | binding_ptr |
OrtStatus * OrtApi::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.
[in,out] | binding_ptr |
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.
[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 |
OrtStatus * OrtApi::UnregisterAllocator | ( | OrtEnv * | env, |
const OrtMemoryInfo * | mem_info | ||
) |
Unregister a custom allocator.
It is an error if you provide an OrtMemoryInfo not corresponding to any registered allocators for sharing.
[in] | env | |
[in] | mem_info |
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.
For example, key="device_id" and value="0"
[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_keys and provider_options_values arrays |
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://www.onnxruntime.ai/docs/reference/execution-providers/TensorRT-ExecutionProvider.html#c-api-example 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.
For example, key="trt_max_workspace_size" and value="2147483648"
[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_keys and provider_options_values arrays |
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.
[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. |
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.
[in,out] | ort_value | OrtValue instance constructed with OrtApi::CreateSparseTensorWithValuesAsOrtValue |
[in,out] | indices_data | pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. |
[in] | indices_num | number of COO indices. Should either be 0 for fully sparse tensors, be equal to the number of nnz values specified to OrtApi::CreateSparseTensorWithValuesAsOrtValue for 1-D {nnz} indices or be twice as number of nnz values for a 2-D indices {nnz, 2} |
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.
[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. |
void( * OrtApi::ClearBoundInputs) (OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
Clears any previously set Inputs for an OrtIoBinding.
void( * OrtApi::ClearBoundOutputs) (OrtIoBinding *binding_ptr) __attribute__((nonnull)) |
Clears any previously set Outputs for an OrtIoBinding.
OrtStatus *( * OrtApi::CreateStatus) (OrtErrorCode code, const char *msg) __attribute__((nonnull)) |
Create an OrtStatus from a null terminated string.
[in] | code | |
[in] | msg | A null-terminated string. Its contents will be copied. |
OrtErrorCode( * OrtApi::GetErrorCode) (const OrtStatus *status) __attribute__((nonnull)) |
Get OrtErrorCode from OrtStatus.
[in] | status |
status
was created with const char *( * OrtApi::GetErrorMessage) (const OrtStatus *status) __attribute__((nonnull)) |
Get error string from OrtStatus.
[in] | status |
status
. Do not free the returned value. void( * OrtApi::ReleaseCUDAProviderOptions) (OrtCUDAProviderOptionsV2 *input) |
Release an OrtCUDAProviderOptionsV2.
void( * OrtApi::ReleaseTensorRTProviderOptions) (OrtTensorRTProviderOptionsV2 *input) |
Release an OrtTensorRTProviderOptionsV2.