ONNX Runtime
Loading...
Searching...
No Matches
onnxruntime_c_api.h
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4// See docs\c_cxx\README.md on generating the Doxygen documentation from this file
5
31#pragma once
32#include <stdlib.h>
33#include <stdint.h>
34#include <string.h>
35
40#define ORT_API_VERSION 17
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
47// SAL2 Definitions
48#ifndef _WIN32
49#define _In_
50#define _In_z_
51#define _In_opt_
52#define _In_opt_z_
53#define _Out_
54#define _Outptr_
55#define _Out_opt_
56#define _Inout_
57#define _Inout_opt_
58#define _Frees_ptr_opt_
59#define _Ret_maybenull_
60#define _Ret_notnull_
61#define _Check_return_
62#define _Outptr_result_maybenull_
63#define _In_reads_(X)
64#define _Inout_updates_(X)
65#define _Out_writes_(X)
66#define _Inout_updates_all_(X)
67#define _Out_writes_bytes_all_(X)
68#define _Out_writes_all_(X)
69#define _Success_(X)
70#define _Outptr_result_buffer_maybenull_(X)
71#define ORT_ALL_ARGS_NONNULL __attribute__((nonnull))
72#else
73#include <specstrings.h>
74#define ORT_ALL_ARGS_NONNULL
75#endif
76
77#ifdef _WIN32
78// Define ORT_DLL_IMPORT if your program is dynamically linked to Ort.
79// dllexport is not used, we use a .def file.
80#ifdef ORT_DLL_IMPORT
81#define ORT_EXPORT __declspec(dllimport)
82#else
83#define ORT_EXPORT
84#endif
85#define ORT_API_CALL _stdcall
86#define ORT_MUST_USE_RESULT
87#define ORTCHAR_T wchar_t
88#else
89// To make symbols visible on macOS/iOS
90#ifdef __APPLE__
91#define ORT_EXPORT __attribute__((visibility("default")))
92#else
93#define ORT_EXPORT
94#endif
95#define ORT_API_CALL
96#define ORT_MUST_USE_RESULT __attribute__((warn_unused_result))
97#define ORTCHAR_T char
98#endif
99
102#ifndef ORT_TSTR
103#ifdef _WIN32
104#define ORT_TSTR(X) L##X
105// When X is a macro, L##X is not defined. In this case, we need to use ORT_TSTR_ON_MACRO.
106#define ORT_TSTR_ON_MACRO(X) L"" X
107#else
108#define ORT_TSTR(X) X
109#define ORT_TSTR_ON_MACRO(X) X
110#endif
111#endif
112
113// On Windows, ORT_FILE is a wchar_t version of the __FILE__ macro.
114// Otherwise, ORT_FILE is equivalent to __FILE__.
115#ifndef ORT_FILE
116#define ORT_FILE_INTERNAL(x) ORT_TSTR(x)
117#define ORT_FILE ORT_FILE_INTERNAL(__FILE__)
118#endif
119
120// Any pointer marked with _In_ or _Out_, cannot be NULL.
121
122// Windows users should use unicode paths when possible to bypass the MAX_PATH limitation
123// Every pointer marked with _In_ or _Out_, cannot be NULL. Caller should ensure that.
124// for ReleaseXXX(...) functions, they can accept NULL pointer.
125
126#ifdef __cplusplus
127// For any compiler with C++11 support, MSVC 2015 and greater, or Clang version supporting noexcept.
128// Such complex condition is needed because compilers set __cplusplus value differently.
129#ifndef __has_feature
130#define __has_feature(x) 0
131#endif
132#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || (defined(__has_feature) && __has_feature(cxx_noexcept)))
133#define NO_EXCEPTION noexcept
134#else
135#define NO_EXCEPTION throw()
136#endif
137#else
138#define NO_EXCEPTION
139#endif
140
141// __VA_ARGS__ on Windows and Linux are different
142#define ORT_API(RETURN_TYPE, NAME, ...) RETURN_TYPE ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION
143
144#define ORT_API_STATUS(NAME, ...) \
145 _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) \
146 NO_EXCEPTION ORT_MUST_USE_RESULT
147
148// XXX: Unfortunately, SAL annotations are known to not work with function pointers
149#define ORT_API2_STATUS(NAME, ...) \
150 _Check_return_ _Ret_maybenull_ OrtStatusPtr(ORT_API_CALL* NAME)(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT
151
152// Used in *.cc files. Almost as same as ORT_API_STATUS, except without ORT_MUST_USE_RESULT and ORT_EXPORT
153#define ORT_API_STATUS_IMPL(NAME, ...) \
154 _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION
155
156#define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
157
158#ifdef __DOXYGEN__
159#undef ORT_API_STATUS
160#define ORT_API_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
161#undef ORT_API2_STATUS
162#define ORT_API2_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
163#undef ORT_CLASS_RELEASE
164#define ORT_CLASS_RELEASE(X) void Release##X(Ort##X* input)
165#undef NO_EXCEPTION
166#define NO_EXCEPTION
167#endif
178 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, // maps to c type float
179 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8, // maps to c type uint8_t
180 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8, // maps to c type int8_t
181 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16, // maps to c type uint16_t
182 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16, // maps to c type int16_t
183 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32, // maps to c type int32_t
184 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64, // maps to c type int64_t
185 ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING, // maps to c++ type std::string
188 ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE, // maps to c type double
189 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32, // maps to c type uint32_t
190 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64, // maps to c type uint64_t
191 ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64, // complex with float32 real and imaginary components
192 ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128, // complex with float64 real and imaginary components
193 ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16, // Non-IEEE floating-point format based on IEEE754 single-precision
194 // float 8 types were introduced in onnx 1.14, see https://onnx.ai/onnx/technical/float8.html
195 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FN, // Non-IEEE floating-point format based on IEEE754 single-precision
196 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FNUZ, // Non-IEEE floating-point format based on IEEE754 single-precision
197 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2, // Non-IEEE floating-point format based on IEEE754 single-precision
198 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2FNUZ // Non-IEEE floating-point format based on IEEE754 single-precision
200
201// Synced with onnx TypeProto oneof
211
212// These types are synced with internal
213// SparseFormatFlags
220
221// Enum allows to query sparse tensor indices
228
240
255
265
267#define ORT_RUNTIME_CLASS(X) \
268 struct Ort##X; \
269 typedef struct Ort##X Ort##X;
270
275// The actual types defined have an Ort prefix
276ORT_RUNTIME_CLASS(Env);
277ORT_RUNTIME_CLASS(Status); // nullptr for Status* indicates success
278ORT_RUNTIME_CLASS(MemoryInfo);
279ORT_RUNTIME_CLASS(IoBinding);
280ORT_RUNTIME_CLASS(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool)
281ORT_RUNTIME_CLASS(Value);
282ORT_RUNTIME_CLASS(RunOptions);
283ORT_RUNTIME_CLASS(TypeInfo);
284ORT_RUNTIME_CLASS(TensorTypeAndShapeInfo);
285ORT_RUNTIME_CLASS(MapTypeInfo);
286ORT_RUNTIME_CLASS(SequenceTypeInfo);
287ORT_RUNTIME_CLASS(OptionalTypeInfo);
288ORT_RUNTIME_CLASS(SessionOptions);
289ORT_RUNTIME_CLASS(CustomOpDomain);
290ORT_RUNTIME_CLASS(ModelMetadata);
291ORT_RUNTIME_CLASS(ThreadPoolParams);
292ORT_RUNTIME_CLASS(ThreadingOptions);
293ORT_RUNTIME_CLASS(ArenaCfg);
294ORT_RUNTIME_CLASS(PrepackedWeightsContainer);
295ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2);
296ORT_RUNTIME_CLASS(CUDAProviderOptionsV2);
297ORT_RUNTIME_CLASS(CANNProviderOptions);
298ORT_RUNTIME_CLASS(DnnlProviderOptions);
299ORT_RUNTIME_CLASS(Op);
300ORT_RUNTIME_CLASS(OpAttr);
301ORT_RUNTIME_CLASS(Logger);
302ORT_RUNTIME_CLASS(ShapeInferContext);
303
304#ifdef _WIN32
305typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr;
306#else
308#endif
309
316typedef struct OrtAllocator {
317 uint32_t version;
318 void*(ORT_API_CALL* Alloc)(struct OrtAllocator* this_, size_t size);
319 void(ORT_API_CALL* Free)(struct OrtAllocator* this_, void* p);
320 const struct OrtMemoryInfo*(ORT_API_CALL* Info)(const struct OrtAllocator* this_);
322
323typedef void(ORT_API_CALL* OrtLoggingFunction)(
324 void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location,
325 const char* message);
326
338
343
356
357struct OrtKernelInfo;
359struct OrtKernelContext;
361struct OrtCustomOp;
363
369
372// Whenever this struct is updated, please also update the MakeKey function in onnxruntime / core / framework / execution_provider.cc
379
387
391 OrtCudnnConvAlgoSearchExhaustive, // expensive exhaustive benchmarking using cudnnFindConvolutionForwardAlgorithmEx
392 OrtCudnnConvAlgoSearchHeuristic, // lightweight heuristic based search using cudnnGetConvolutionForwardAlgorithm_v7
393 OrtCudnnConvAlgoSearchDefault, // default algorithm using CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM
395
482
568
575 int has_user_compute_stream; // indicator of user specified CUDA compute stream.
576 void* user_compute_stream; // user specified CUDA compute stream.
577 int trt_max_partition_iterations; // maximum iterations for TensorRT parser to get capability
578 int trt_min_subgraph_size; // minimum size of TensorRT subgraphs
579 size_t trt_max_workspace_size; // maximum workspace size for TensorRT.
580 int trt_fp16_enable; // enable TensorRT FP16 precision. Default 0 = false, nonzero = true
581 int trt_int8_enable; // enable TensorRT INT8 precision. Default 0 = false, nonzero = true
582 const char* trt_int8_calibration_table_name; // TensorRT INT8 calibration table name.
583 int trt_int8_use_native_calibration_table; // use native TensorRT generated calibration table. Default 0 = false, nonzero = true
584 int trt_dla_enable; // enable DLA. Default 0 = false, nonzero = true
585 int trt_dla_core; // DLA core number. Default 0
586 int trt_dump_subgraphs; // dump TRT subgraph. Default 0 = false, nonzero = true
587 int trt_engine_cache_enable; // enable engine caching. Default 0 = false, nonzero = true
588 const char* trt_engine_cache_path; // specify engine cache path
589 int trt_engine_decryption_enable; // enable engine decryption. Default 0 = false, nonzero = true
590 const char* trt_engine_decryption_lib_path; // specify engine decryption library path
591 int trt_force_sequential_engine_build; // force building TensorRT engine sequentially. Default 0 = false, nonzero = true
592 // This is the legacy struct and don't add new fields here.
593 // For new field that can be represented by string, please add it in include/onnxruntime/core/providers/tensorrt/tensorrt_provider_options.h
594 // For non-string field, need to create a new separate api to handle it.
596
602 int device_id; // hip device id.
603 int migraphx_fp16_enable; // MIGraphX FP16 precision. Default 0 = false, nonzero = true
604 int migraphx_int8_enable; // MIGraphX INT8 precision. Default 0 = false, nonzero = true
605 int migraphx_use_native_calibration_table; // MIGraphx INT8 cal table. Default 0 = false, noznero = true
606 const char* migraphx_int8_calibration_table_name; // MIGraphx INT8 calibration table name
608
614#ifdef __cplusplus
623#endif
628 const char* device_type;
630 const char* device_id;
632 const char* cache_dir; // path is set to empty by default
633 void* context;
635 unsigned char enable_dynamic_shapes;
637
638struct OrtApi;
639typedef struct OrtApi OrtApi;
640
641struct OrtTrainingApi;
643
658 const OrtApi*(ORT_API_CALL* GetApi)(uint32_t version)NO_EXCEPTION;
659
664 const char*(ORT_API_CALL* GetVersionString)(void)NO_EXCEPTION;
665};
666
667typedef struct OrtApiBase OrtApiBase;
668
673ORT_EXPORT const OrtApiBase* ORT_API_CALL OrtGetApiBase(void) NO_EXCEPTION;
674
680typedef void (*OrtThreadWorkerFn)(void* ort_worker_fn_param);
681
685
691typedef OrtCustomThreadHandle (*OrtCustomCreateThreadFn)(void* ort_custom_thread_creation_options, OrtThreadWorkerFn ort_thread_worker_fn, void* ort_worker_fn_param);
692
698typedef void (*OrtCustomJoinThreadFn)(OrtCustomThreadHandle ort_custom_thread_handle);
699
700typedef OrtStatus*(ORT_API_CALL* RegisterCustomOpsFn)(OrtSessionOptions* options, const OrtApiBase* api);
701
709typedef void (*RunAsyncCallbackFn)(void* user_data, OrtValue** outputs, size_t num_outputs, OrtStatusPtr status);
710
718struct OrtApi {
721
729 OrtStatus*(ORT_API_CALL* CreateStatus)(OrtErrorCode code, _In_ const char* msg)NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
730
736 OrtErrorCode(ORT_API_CALL* GetErrorCode)(_In_ const OrtStatus* status) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
737
743 const char*(ORT_API_CALL* GetErrorMessage)(_In_ const OrtStatus* status)NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
744
748
759 ORT_API2_STATUS(CreateEnv, OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out);
760
775 ORT_API2_STATUS(CreateEnvWithCustomLogger, _In_ OrtLoggingFunction logging_function, _In_opt_ void* logger_param,
776 _In_ OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out);
777
785 ORT_API2_STATUS(EnableTelemetryEvents, _In_ const OrtEnv* env);
793 ORT_API2_STATUS(DisableTelemetryEvents, _In_ const OrtEnv* env);
794
798
808 // TODO: document the path separator convention? '/' vs '\'
809 // TODO: should specify the access characteristics of model_path. Is this read only during the
810 // execution of CreateSession, or does the OrtSession retain a handle to the file/directory
811 // and continue to access throughout the OrtSession lifetime?
812 // What sort of access is needed to model_path : read or read/write?
813 ORT_API2_STATUS(CreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
814 _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
815
826 ORT_API2_STATUS(CreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
827 _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
828
847 ORT_API2_STATUS(Run, _Inout_ OrtSession* session, _In_opt_ const OrtRunOptions* run_options,
848 _In_reads_(input_len) const char* const* input_names,
849 _In_reads_(input_len) const OrtValue* const* inputs, size_t input_len,
850 _In_reads_(output_names_len) const char* const* output_names, size_t output_names_len,
851 _Inout_updates_all_(output_names_len) OrtValue** outputs);
852
856
872 ORT_API2_STATUS(CreateSessionOptions, _Outptr_ OrtSessionOptions** options);
873
881 ORT_API2_STATUS(SetOptimizedModelFilePath, _Inout_ OrtSessionOptions* options,
882 _In_ const ORTCHAR_T* optimized_model_filepath);
883
891 ORT_API2_STATUS(CloneSessionOptions, _In_ const OrtSessionOptions* in_options,
892 _Outptr_ OrtSessionOptions** out_options);
893
905 ORT_API2_STATUS(SetSessionExecutionMode, _Inout_ OrtSessionOptions* options, ExecutionMode execution_mode);
906
914 ORT_API2_STATUS(EnableProfiling, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix);
915
922 ORT_API2_STATUS(DisableProfiling, _Inout_ OrtSessionOptions* options);
923
937 ORT_API2_STATUS(EnableMemPattern, _Inout_ OrtSessionOptions* options);
938
947 ORT_API2_STATUS(DisableMemPattern, _Inout_ OrtSessionOptions* options);
948
957 ORT_API2_STATUS(EnableCpuMemArena, _Inout_ OrtSessionOptions* options);
958
965 ORT_API2_STATUS(DisableCpuMemArena, _Inout_ OrtSessionOptions* options);
966
974 ORT_API2_STATUS(SetSessionLogId, _Inout_ OrtSessionOptions* options, const char* logid);
975
985 ORT_API2_STATUS(SetSessionLogVerbosityLevel, _Inout_ OrtSessionOptions* options, int session_log_verbosity_level);
986
994 ORT_API2_STATUS(SetSessionLogSeverityLevel, _Inout_ OrtSessionOptions* options, int session_log_severity_level);
995
1004 ORT_API2_STATUS(SetSessionGraphOptimizationLevel, _Inout_ OrtSessionOptions* options,
1005 GraphOptimizationLevel graph_optimization_level);
1006
1020 ORT_API2_STATUS(SetIntraOpNumThreads, _Inout_ OrtSessionOptions* options, int intra_op_num_threads);
1021
1034 ORT_API2_STATUS(SetInterOpNumThreads, _Inout_ OrtSessionOptions* options, int inter_op_num_threads);
1035
1039
1047 ORT_API2_STATUS(CreateCustomOpDomain, _In_ const char* domain, _Outptr_ OrtCustomOpDomain** out);
1048
1058 ORT_API2_STATUS(CustomOpDomain_Add, _Inout_ OrtCustomOpDomain* custom_op_domain, _In_ const OrtCustomOp* op);
1059
1063
1073 ORT_API2_STATUS(AddCustomOpDomain, _Inout_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain);
1074
1091 ORT_API2_STATUS(RegisterCustomOpsLibrary, _Inout_ OrtSessionOptions* options, _In_ const char* library_path, _Outptr_ void** library_handle);
1092
1096
1108 ORT_API2_STATUS(SessionGetInputCount, _In_ const OrtSession* session, _Out_ size_t* out);
1109
1121 ORT_API2_STATUS(SessionGetOutputCount, _In_ const OrtSession* session, _Out_ size_t* out);
1122
1132 ORT_API2_STATUS(SessionGetOverridableInitializerCount, _In_ const OrtSession* session, _Out_ size_t* out);
1133
1142 ORT_API2_STATUS(SessionGetInputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
1143
1152 ORT_API2_STATUS(SessionGetOutputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
1153
1162 ORT_API2_STATUS(SessionGetOverridableInitializerTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
1163
1173 ORT_API2_STATUS(SessionGetInputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1174
1184 ORT_API2_STATUS(SessionGetOutputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1185
1195 ORT_API2_STATUS(SessionGetOverridableInitializerName, _In_ const OrtSession* session, size_t index,
1196 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1197
1201
1208 ORT_API2_STATUS(CreateRunOptions, _Outptr_ OrtRunOptions** out);
1209
1219 ORT_API2_STATUS(RunOptionsSetRunLogVerbosityLevel, _Inout_ OrtRunOptions* options, int log_verbosity_level);
1220
1228 ORT_API2_STATUS(RunOptionsSetRunLogSeverityLevel, _Inout_ OrtRunOptions* options, int log_severity_level);
1229
1239 ORT_API2_STATUS(RunOptionsSetRunTag, _Inout_ OrtRunOptions* options, _In_ const char* run_tag);
1240
1250 ORT_API2_STATUS(RunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* options,
1251 _Out_ int* log_verbosity_level);
1252
1260 ORT_API2_STATUS(RunOptionsGetRunLogSeverityLevel, _In_ const OrtRunOptions* options, _Out_ int* log_severity_level);
1261
1273 ORT_API2_STATUS(RunOptionsGetRunTag, _In_ const OrtRunOptions* options, _Out_ const char** run_tag);
1274
1283 ORT_API2_STATUS(RunOptionsSetTerminate, _Inout_ OrtRunOptions* options);
1284
1293 ORT_API2_STATUS(RunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options);
1294
1298
1311 ORT_API2_STATUS(CreateTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* shape, size_t shape_len,
1313
1329 ORT_API2_STATUS(CreateTensorWithDataAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
1330 size_t p_data_len, _In_ const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type,
1331 _Outptr_ OrtValue** out);
1332
1340 ORT_API2_STATUS(IsTensor, _In_ const OrtValue* value, _Out_ int* out);
1341
1352 ORT_API2_STATUS(GetTensorMutableData, _In_ OrtValue* value, _Outptr_ void** out);
1353
1362 ORT_API2_STATUS(FillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len);
1363
1373 ORT_API2_STATUS(GetStringTensorDataLength, _In_ const OrtValue* value, _Out_ size_t* len);
1374
1394 ORT_API2_STATUS(GetStringTensorContent, _In_ const OrtValue* value, _Out_writes_bytes_all_(s_len) void* s,
1395 size_t s_len, _Out_writes_all_(offsets_len) size_t* offsets, size_t offsets_len);
1396
1400
1409 ORT_API2_STATUS(CastTypeInfoToTensorInfo, _In_ const OrtTypeInfo* type_info,
1410 _Outptr_result_maybenull_ const OrtTensorTypeAndShapeInfo** out);
1411
1419 ORT_API2_STATUS(GetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ enum ONNXType* out);
1420
1424
1432
1441
1450 ORT_API2_STATUS(SetDimensions, OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count);
1451
1461 ORT_API2_STATUS(GetTensorElementType, _In_ const OrtTensorTypeAndShapeInfo* info,
1463
1473 ORT_API2_STATUS(GetDimensionsCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out);
1474
1483 ORT_API2_STATUS(GetDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values,
1484 size_t dim_values_length);
1485
1494 ORT_API2_STATUS(GetSymbolicDimensions, _In_ const OrtTensorTypeAndShapeInfo* info,
1495 _Out_writes_all_(dim_params_length) const char* dim_params[], size_t dim_params_length);
1496
1513 ORT_API2_STATUS(GetTensorShapeElementCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out);
1514
1518
1526 ORT_API2_STATUS(GetTensorTypeAndShape, _In_ const OrtValue* value, _Outptr_ OrtTensorTypeAndShapeInfo** out);
1527
1535 ORT_API2_STATUS(GetTypeInfo, _In_ const OrtValue* value, _Outptr_result_maybenull_ OrtTypeInfo** out);
1536
1544 ORT_API2_STATUS(GetValueType, _In_ const OrtValue* value, _Out_ enum ONNXType* out);
1545
1549
1560 ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name, enum OrtAllocatorType type, int id,
1561 enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out);
1562
1573 ORT_API2_STATUS(CreateCpuMemoryInfo, enum OrtAllocatorType type, enum OrtMemType mem_type,
1574 _Outptr_ OrtMemoryInfo** out);
1575
1586 ORT_API2_STATUS(CompareMemoryInfo, _In_ const OrtMemoryInfo* info1, _In_ const OrtMemoryInfo* info2, _Out_ int* out);
1587
1595 ORT_API2_STATUS(MemoryInfoGetName, _In_ const OrtMemoryInfo* ptr, _Out_ const char** out);
1596
1599 ORT_API2_STATUS(MemoryInfoGetId, _In_ const OrtMemoryInfo* ptr, _Out_ int* out);
1600
1603 ORT_API2_STATUS(MemoryInfoGetMemType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtMemType* out);
1604
1607 ORT_API2_STATUS(MemoryInfoGetType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtAllocatorType* out);
1608
1612
1614 ORT_API2_STATUS(AllocatorAlloc, _Inout_ OrtAllocator* ort_allocator, size_t size, _Outptr_ void** out);
1616 ORT_API2_STATUS(AllocatorFree, _Inout_ OrtAllocator* ort_allocator, void* p);
1618 ORT_API2_STATUS(AllocatorGetInfo, _In_ const OrtAllocator* ort_allocator, _Outptr_ const struct OrtMemoryInfo** out);
1619
1628 ORT_API2_STATUS(GetAllocatorWithDefaultOptions, _Outptr_ OrtAllocator** out);
1629
1633
1645 ORT_API2_STATUS(AddFreeDimensionOverride, _Inout_ OrtSessionOptions* options, _In_ const char* dim_denotation,
1646 _In_ int64_t dim_value);
1647
1651
1652 /* Internal information (not seen in Doxygen)
1653 *
1654 * APIs to support non-tensor types - map and sequence.
1655 * Currently only the following types are supported
1656 * Note: the following types should be kept in sync with data_types.h
1657 * Map types
1658 * =========
1659 * std::map<std::string, std::string>
1660 * std::map<std::string, int64_t>
1661 * std::map<std::string, float>
1662 * std::map<std::string, double>
1663 * std::map<int64_t, std::string>
1664 * std::map<int64_t, int64_t>
1665 * std::map<int64_t, float>
1666 * std::map<int64_t, double>
1667 *
1668 * Sequence types
1669 * ==============
1670 * std::vector<std::string>
1671 * std::vector<int64_t>
1672 * std::vector<float>
1673 * std::vector<double>
1674 * std::vector<std::map<std::string, float>>
1675 * std::vector<std::map<int64_t, float>
1676 */
1677
1692 ORT_API2_STATUS(GetValue, _In_ const OrtValue* value, int index, _Inout_ OrtAllocator* allocator,
1693 _Outptr_ OrtValue** out);
1694
1705 ORT_API2_STATUS(GetValueCount, _In_ const OrtValue* value, _Out_ size_t* out);
1706
1722 ORT_API2_STATUS(CreateValue, _In_reads_(num_values) const OrtValue* const* in, size_t num_values,
1723 enum ONNXType value_type, _Outptr_ OrtValue** out);
1724
1747 ORT_API2_STATUS(CreateOpaqueValue, _In_z_ const char* domain_name, _In_z_ const char* type_name,
1748 _In_ const void* data_container, size_t data_container_size, _Outptr_ OrtValue** out);
1749
1764 ORT_API2_STATUS(GetOpaqueValue, _In_ const char* domain_name, _In_ const char* type_name, _In_ const OrtValue* in,
1765 _Out_ void* data_container, size_t data_container_size);
1766
1771
1780 ORT_API2_STATUS(KernelInfoGetAttribute_float, _In_ const OrtKernelInfo* info, _In_ const char* name,
1781 _Out_ float* out);
1782
1791 ORT_API2_STATUS(KernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* info, _In_ const char* name,
1792 _Out_ int64_t* out);
1793
1814 ORT_API2_STATUS(KernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out,
1815 _Inout_ size_t* size);
1816
1821
1826 ORT_API2_STATUS(KernelContext_GetInputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out);
1827
1832 ORT_API2_STATUS(KernelContext_GetOutputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out);
1833
1838 ORT_API2_STATUS(KernelContext_GetInput, _In_ const OrtKernelContext* context, _In_ size_t index,
1839 _Out_ const OrtValue** out);
1840
1845 ORT_API2_STATUS(KernelContext_GetOutput, _Inout_ OrtKernelContext* context, _In_ size_t index,
1846 _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out);
1847
1851 ORT_CLASS_RELEASE(Env);
1855 ORT_CLASS_RELEASE(Status);
1859 ORT_CLASS_RELEASE(MemoryInfo);
1863 ORT_CLASS_RELEASE(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool)
1867 ORT_CLASS_RELEASE(Value);
1871 ORT_CLASS_RELEASE(RunOptions);
1875 ORT_CLASS_RELEASE(TypeInfo);
1879 ORT_CLASS_RELEASE(TensorTypeAndShapeInfo);
1883 ORT_CLASS_RELEASE(SessionOptions);
1887 ORT_CLASS_RELEASE(CustomOpDomain);
1888
1892
1905 ORT_API2_STATUS(GetDenotationFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ const char** const denotation,
1906 _Out_ size_t* len);
1907
1921 ORT_API2_STATUS(CastTypeInfoToMapTypeInfo, _In_ const OrtTypeInfo* type_info,
1922 _Outptr_result_maybenull_ const OrtMapTypeInfo** out);
1923
1937 ORT_API2_STATUS(CastTypeInfoToSequenceTypeInfo, _In_ const OrtTypeInfo* type_info,
1938 _Outptr_result_maybenull_ const OrtSequenceTypeInfo** out);
1939
1943
1955 ORT_API2_STATUS(GetMapKeyType, _In_ const OrtMapTypeInfo* map_type_info, _Out_ enum ONNXTensorElementDataType* out);
1956
1964 ORT_API2_STATUS(GetMapValueType, _In_ const OrtMapTypeInfo* map_type_info, _Outptr_ OrtTypeInfo** type_info);
1965
1969
1979 ORT_API2_STATUS(GetSequenceElementType, _In_ const OrtSequenceTypeInfo* sequence_type_info,
1980 _Outptr_ OrtTypeInfo** type_info);
1981
1985 ORT_CLASS_RELEASE(MapTypeInfo);
1989 ORT_CLASS_RELEASE(SequenceTypeInfo);
1990
1994
2005 ORT_API2_STATUS(SessionEndProfiling, _In_ OrtSession* session, _Inout_ OrtAllocator* allocator, _Outptr_ char** out);
2006
2014 ORT_API2_STATUS(SessionGetModelMetadata, _In_ const OrtSession* session, _Outptr_ OrtModelMetadata** out);
2015
2019
2028 ORT_API2_STATUS(ModelMetadataGetProducerName, _In_ const OrtModelMetadata* model_metadata,
2029 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
2030
2039 ORT_API2_STATUS(ModelMetadataGetGraphName, _In_ const OrtModelMetadata* model_metadata,
2040 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
2041
2050 ORT_API2_STATUS(ModelMetadataGetDomain, _In_ const OrtModelMetadata* model_metadata, _Inout_ OrtAllocator* allocator,
2051 _Outptr_ char** value);
2052
2061 ORT_API2_STATUS(ModelMetadataGetDescription, _In_ const OrtModelMetadata* model_metadata,
2062 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
2063
2074 ORT_API2_STATUS(ModelMetadataLookupCustomMetadataMap, _In_ const OrtModelMetadata* model_metadata,
2075 _Inout_ OrtAllocator* allocator, _In_ const char* key, _Outptr_result_maybenull_ char** value);
2076
2084 ORT_API2_STATUS(ModelMetadataGetVersion, _In_ const OrtModelMetadata* model_metadata, _Out_ int64_t* value);
2085
2086 ORT_CLASS_RELEASE(ModelMetadata);
2087
2091
2105 ORT_API2_STATUS(CreateEnvWithGlobalThreadPools, OrtLoggingLevel log_severity_level, _In_ const char* logid,
2106 _In_ const OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out);
2107
2111
2121 ORT_API2_STATUS(DisablePerSessionThreads, _Inout_ OrtSessionOptions* options);
2122
2126
2132 ORT_API2_STATUS(CreateThreadingOptions, _Outptr_ OrtThreadingOptions** out);
2133
2134 ORT_CLASS_RELEASE(ThreadingOptions);
2135
2139
2151 ORT_API2_STATUS(ModelMetadataGetCustomMetadataMapKeys, _In_ const OrtModelMetadata* model_metadata,
2152 _Inout_ OrtAllocator* allocator, _Outptr_result_buffer_maybenull_(*num_keys) char*** keys, _Out_ int64_t* num_keys);
2153
2157
2165 ORT_API2_STATUS(AddFreeDimensionOverrideByName,
2166 _Inout_ OrtSessionOptions* options, _In_ const char* dim_name,
2167 _In_ int64_t dim_value);
2168
2172
2184 ORT_API2_STATUS(GetAvailableProviders, _Outptr_ char*** out_ptr, _Out_ int* provider_length);
2185
2194 ORT_API2_STATUS(ReleaseAvailableProviders, _In_ char** ptr,
2195 _In_ int providers_length);
2196
2200
2209 ORT_API2_STATUS(GetStringTensorElementLength, _In_ const OrtValue* value, size_t index, _Out_ size_t* out);
2210
2220 ORT_API2_STATUS(GetStringTensorElement, _In_ const OrtValue* value, size_t s_len, size_t index, _Out_writes_bytes_all_(s_len) void* s);
2221
2230 ORT_API2_STATUS(FillStringTensorElement, _Inout_ OrtValue* value, _In_ const char* s, size_t index);
2231
2235
2248 ORT_API2_STATUS(AddSessionConfigEntry, _Inout_ OrtSessionOptions* options,
2249 _In_z_ const char* config_key, _In_z_ const char* config_value);
2250
2254
2263 ORT_API2_STATUS(CreateAllocator, _In_ const OrtSession* session, _In_ const OrtMemoryInfo* mem_info,
2264 _Outptr_ OrtAllocator** out);
2265
2268 ORT_CLASS_RELEASE(Allocator);
2269
2273
2284 ORT_API2_STATUS(RunWithBinding, _Inout_ OrtSession* session, _In_ const OrtRunOptions* run_options, _In_ const OrtIoBinding* binding_ptr);
2285
2297 ORT_API2_STATUS(CreateIoBinding, _Inout_ OrtSession* session, _Outptr_ OrtIoBinding** out);
2298
2302
2305 ORT_CLASS_RELEASE(IoBinding);
2306
2317 ORT_API2_STATUS(BindInput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr);
2318
2329 ORT_API2_STATUS(BindOutput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr);
2330
2346 ORT_API2_STATUS(BindOutputToDevice, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtMemoryInfo* mem_info_ptr);
2347
2365 ORT_API2_STATUS(GetBoundOutputNames, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator,
2366 _Out_ char** buffer, _Out_writes_all_(count) size_t** lengths, _Out_ size_t* count);
2367
2385 ORT_API2_STATUS(GetBoundOutputValues, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator,
2386 _Out_writes_all_(output_count) OrtValue*** output, _Out_ size_t* output_count);
2387
2390 void(ORT_API_CALL* ClearBoundInputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
2391
2394 void(ORT_API_CALL* ClearBoundOutputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
2395
2399
2414 ORT_API2_STATUS(TensorAt, _Inout_ OrtValue* value, const int64_t* location_values, size_t location_values_count, _Outptr_ void** out);
2415
2419
2434 ORT_API2_STATUS(CreateAndRegisterAllocator, _Inout_ OrtEnv* env, _In_ const OrtMemoryInfo* mem_info,
2435 _In_ const OrtArenaCfg* arena_cfg);
2436
2448 ORT_API2_STATUS(SetLanguageProjection, _In_ const OrtEnv* ort_env, _In_ OrtLanguageProjection projection);
2449
2453
2463 ORT_API2_STATUS(SessionGetProfilingStartTimeNs, _In_ const OrtSession* session, _Outptr_ uint64_t* out);
2464
2468
2480 ORT_API2_STATUS(SetGlobalIntraOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int intra_op_num_threads);
2481
2493 ORT_API2_STATUS(SetGlobalInterOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int inter_op_num_threads);
2494
2508 ORT_API2_STATUS(SetGlobalSpinControl, _Inout_ OrtThreadingOptions* tp_options, int allow_spinning);
2509
2513
2528 ORT_API2_STATUS(AddInitializer, _Inout_ OrtSessionOptions* options, _In_z_ const char* name,
2529 _In_ const OrtValue* val);
2530
2534
2550 ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel log_severity_level,
2551 _In_ const char* logid, _In_ const struct OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out);
2552
2556
2567 _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptions* cuda_options);
2568
2579 _In_ OrtSessionOptions* options, _In_ const OrtROCMProviderOptions* rocm_options);
2580
2591 _In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options);
2592
2596
2607 ORT_API2_STATUS(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* tp_options);
2608
2612
2625 ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes,
2626 int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out);
2627
2628 ORT_CLASS_RELEASE(ArenaCfg);
2629
2633
2645 ORT_API2_STATUS(ModelMetadataGetGraphDescription, _In_ const OrtModelMetadata* model_metadata,
2646 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
2647
2651
2662 _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options);
2663
2667
2678 ORT_API2_STATUS(SetCurrentGpuDeviceId, _In_ int device_id);
2679
2690 ORT_API2_STATUS(GetCurrentGpuDeviceId, _In_ int* device_id);
2691
2696
2719 ORT_API2_STATUS(KernelInfoGetAttributeArray_float, _In_ const OrtKernelInfo* info, _In_ const char* name,
2720 _Out_ float* out, _Inout_ size_t* size);
2721
2743 ORT_API2_STATUS(KernelInfoGetAttributeArray_int64, _In_ const OrtKernelInfo* info, _In_ const char* name,
2744 _Out_ int64_t* out, _Inout_ size_t* size);
2745
2749
2781 ORT_API2_STATUS(CreateArenaCfgV2, _In_reads_(num_keys) const char* const* arena_config_keys,
2782 _In_reads_(num_keys) const size_t* arena_config_values, _In_ size_t num_keys,
2783 _Outptr_ OrtArenaCfg** out);
2784
2788
2801 ORT_API2_STATUS(AddRunConfigEntry, _Inout_ OrtRunOptions* options,
2802 _In_z_ const char* config_key, _In_z_ const char* config_value);
2803
2807
2821
2826 ORT_CLASS_RELEASE(PrepackedWeightsContainer);
2827
2831
2849 ORT_API2_STATUS(CreateSessionWithPrepackedWeightsContainer, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
2850 _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
2851 _Outptr_ OrtSession** out);
2852
2871 ORT_API2_STATUS(CreateSessionFromArrayWithPrepackedWeightsContainer, _In_ const OrtEnv* env,
2872 _In_ const void* model_data, size_t model_data_length,
2873 _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
2874 _Outptr_ OrtSession** out);
2875
2879
2898 _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options);
2899
2903
2911
2927 ORT_API2_STATUS(UpdateTensorRTProviderOptions, _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options,
2928 _In_reads_(num_keys) const char* const* provider_options_keys,
2929 _In_reads_(num_keys) const char* const* provider_options_values,
2930 _In_ size_t num_keys);
2931
2943 ORT_API2_STATUS(GetTensorRTProviderOptionsAsString, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
2944
2949 void(ORT_API_CALL* ReleaseTensorRTProviderOptions)(_Frees_ptr_opt_ OrtTensorRTProviderOptionsV2* input);
2950
2954
2961 ORT_API2_STATUS(EnableOrtCustomOps, _Inout_ OrtSessionOptions* options);
2962
2966
2982 ORT_API2_STATUS(RegisterAllocator, _Inout_ OrtEnv* env, _In_ OrtAllocator* allocator);
2983
2994 ORT_API2_STATUS(UnregisterAllocator, _Inout_ OrtEnv* env,
2995 _In_ const OrtMemoryInfo* mem_info);
2996
3000
3009 ORT_API2_STATUS(IsSparseTensor, _In_ const OrtValue* value, _Out_ int* out);
3010
3027 ORT_API2_STATUS(CreateSparseTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* dense_shape,
3028 size_t dense_shape_len, ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
3029
3047 ORT_API2_STATUS(FillSparseTensorCoo, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
3048 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
3049 _In_ const int64_t* indices_data, size_t indices_num);
3050
3070 ORT_API2_STATUS(FillSparseTensorCsr, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
3071 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
3072 _In_ const int64_t* inner_indices_data, size_t inner_indices_num,
3073 _In_ const int64_t* outer_indices_data, size_t outer_indices_num);
3074
3093 ORT_API2_STATUS(FillSparseTensorBlockSparse, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
3094 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
3095 _In_ const int64_t* indices_shape_data, size_t indices_shape_len,
3096 _In_ const int32_t* indices_data);
3097
3122 ORT_API2_STATUS(CreateSparseTensorWithValuesAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
3123 _In_ const int64_t* dense_shape, size_t dense_shape_len,
3124 _In_ const int64_t* values_shape, size_t values_shape_len,
3126
3141 ORT_API2_STATUS(UseCooIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* indices_data, size_t indices_num);
3142
3159 ORT_API2_STATUS(UseCsrIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* inner_data, size_t inner_num,
3160 _Inout_ int64_t* outer_data, size_t outer_num);
3161
3175 ORT_API2_STATUS(UseBlockSparseIndices, _Inout_ OrtValue* ort_value, const int64_t* indices_shape, size_t indices_shape_len, _Inout_ int32_t* indices_data);
3176
3184 ORT_API2_STATUS(GetSparseTensorFormat, _In_ const OrtValue* ort_value, _Out_ enum OrtSparseFormat* out);
3185
3193 ORT_API2_STATUS(GetSparseTensorValuesTypeAndShape, _In_ const OrtValue* ort_value, _Outptr_ OrtTensorTypeAndShapeInfo** out);
3194
3202 ORT_API2_STATUS(GetSparseTensorValues, _In_ const OrtValue* ort_value, _Outptr_ const void** out);
3203
3213 ORT_API2_STATUS(GetSparseTensorIndicesTypeShape, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Outptr_ OrtTensorTypeAndShapeInfo** out);
3214
3224 ORT_API2_STATUS(GetSparseTensorIndices, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Out_ size_t* num_indices, _Outptr_ const void** indices);
3228
3241 ORT_API2_STATUS(HasValue, _In_ const OrtValue* value, _Out_ int* out);
3242
3247
3259 ORT_API2_STATUS(KernelContext_GetGPUComputeStream, _In_ const OrtKernelContext* context, _Outptr_ void** out);
3260
3264
3270 ORT_API2_STATUS(GetTensorMemoryInfo, _In_ const OrtValue* value, _Out_ const OrtMemoryInfo** mem_info);
3271
3275
3285 ORT_API2_STATUS(GetExecutionProviderApi, _In_ const char* provider_name, _In_ uint32_t version, _Outptr_ const void** provider_api);
3286
3288
3291
3298 ORT_API2_STATUS(SessionOptionsSetCustomCreateThreadFn, _Inout_ OrtSessionOptions* options, _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn);
3299
3307 ORT_API2_STATUS(SessionOptionsSetCustomThreadCreationOptions, _Inout_ OrtSessionOptions* options, _In_ void* ort_custom_thread_creation_options);
3308
3316 ORT_API2_STATUS(SessionOptionsSetCustomJoinThreadFn, _Inout_ OrtSessionOptions* options, _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn);
3318
3321
3328 ORT_API2_STATUS(SetGlobalCustomCreateThreadFn, _Inout_ OrtThreadingOptions* tp_options, _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn);
3329
3337 ORT_API2_STATUS(SetGlobalCustomThreadCreationOptions, _Inout_ OrtThreadingOptions* tp_options, _In_ void* ort_custom_thread_creation_options);
3338
3346 ORT_API2_STATUS(SetGlobalCustomJoinThreadFn, _Inout_ OrtThreadingOptions* tp_options, _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn);
3348
3357 ORT_API2_STATUS(SynchronizeBoundInputs, _Inout_ OrtIoBinding* binding_ptr);
3358
3367 ORT_API2_STATUS(SynchronizeBoundOutputs, _Inout_ OrtIoBinding* binding_ptr);
3368
3371
3392 _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptionsV2* cuda_options);
3393
3397
3406 ORT_API2_STATUS(CreateCUDAProviderOptions, _Outptr_ OrtCUDAProviderOptionsV2** out);
3407
3425 ORT_API2_STATUS(UpdateCUDAProviderOptions, _Inout_ OrtCUDAProviderOptionsV2* cuda_options,
3426 _In_reads_(num_keys) const char* const* provider_options_keys,
3427 _In_reads_(num_keys) const char* const* provider_options_values,
3428 _In_ size_t num_keys);
3429
3444 ORT_API2_STATUS(GetCUDAProviderOptionsAsString, _In_ const OrtCUDAProviderOptionsV2* cuda_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
3445
3452 void(ORT_API_CALL* ReleaseCUDAProviderOptions)(_Frees_ptr_opt_ OrtCUDAProviderOptionsV2* input);
3453
3455
3468 _In_ OrtSessionOptions* options, _In_ const OrtMIGraphXProviderOptions* migraphx_options);
3469
3491 ORT_API2_STATUS(AddExternalInitializers, _In_ OrtSessionOptions* options,
3492 _In_reads_(input_len) const char* const* initializer_names,
3493 _In_reads_(input_len) const OrtValue* const* initializers, size_t initializers_num);
3494
3505 ORT_API2_STATUS(CreateOpAttr,
3506 _In_ const char* name,
3507 _In_ const void* data,
3508 _In_ int len,
3509 _In_ OrtOpAttrType type,
3510 _Outptr_ OrtOpAttr** op_attr);
3511
3512 /* \brief: Release op attribute
3513 *
3514 * \param[in] opAttr Attribute created by OrtApi::CreateOpAttr
3515 *
3516 * \since Version 1.12.
3517 */
3518 ORT_CLASS_RELEASE(OpAttr);
3519
3537 ORT_API2_STATUS(CreateOp,
3538 _In_ const OrtKernelInfo* info,
3539 _In_z_ const char* op_name,
3540 _In_z_ const char* domain,
3541 int version,
3542 _In_reads_(type_constraint_count) const char** type_constraint_names,
3543 _In_reads_(type_constraint_count) const ONNXTensorElementDataType* type_constraint_values,
3544 int type_constraint_count,
3545 _In_reads_(attr_count) const OrtOpAttr* const* attr_values,
3546 int attr_count,
3547 int input_count,
3548 int output_count,
3549 _Outptr_ OrtOp** ort_op);
3550
3563 ORT_API2_STATUS(InvokeOp,
3564 _In_ const OrtKernelContext* context,
3565 _In_ const OrtOp* ort_op,
3566 _In_ const OrtValue* const* input_values,
3567 _In_ int input_count,
3568 _Inout_ OrtValue* const* output_values,
3569 _In_ int output_count);
3570
3571 /* \brief: Release an onnxruntime operator
3572 *
3573 * \param[in] Op Operator created by OrtApi::CreateOp
3574 *
3575 * \since Version 1.12.
3576 */
3577 ORT_CLASS_RELEASE(Op);
3578
3637 ORT_API2_STATUS(SessionOptionsAppendExecutionProvider, _In_ OrtSessionOptions* options,
3638 _In_ const char* provider_name,
3639 _In_reads_(num_keys) const char* const* provider_options_keys,
3640 _In_reads_(num_keys) const char* const* provider_options_values,
3641 _In_ size_t num_keys);
3642
3643 /* \brief: Get a copy of kernel info
3644 *
3645 * \param[in] info Kernel info
3646 * \param[out] info_copy Copy of kernel info
3647 *
3648 * \since Version 1.12.
3649 */
3650 ORT_API2_STATUS(CopyKernelInfo,
3651 _In_ const OrtKernelInfo* info,
3652 _Outptr_ OrtKernelInfo** info_copy);
3653
3654 /* \brief: Release kernel info
3655 *
3656 * \param[in] KernelInfo A copy of kernel info returned by CopyKernelInfo
3657 *
3658 * \since Version 1.12.
3659 */
3660 ORT_CLASS_RELEASE(KernelInfo);
3661
3664
3678 const OrtTrainingApi*(ORT_API_CALL* GetTrainingApi)(uint32_t version)NO_EXCEPTION;
3679
3681
3694 _In_ OrtSessionOptions* options, _In_ const OrtCANNProviderOptions* cann_options);
3695
3704 ORT_API2_STATUS(CreateCANNProviderOptions, _Outptr_ OrtCANNProviderOptions** out);
3705
3717 ORT_API2_STATUS(UpdateCANNProviderOptions, _Inout_ OrtCANNProviderOptions* cann_options,
3718 _In_reads_(num_keys) const char* const* provider_options_keys,
3719 _In_reads_(num_keys) const char* const* provider_options_values,
3720 _In_ size_t num_keys);
3721
3735 ORT_API2_STATUS(GetCANNProviderOptionsAsString, _In_ const OrtCANNProviderOptions* cann_options,
3736 _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
3737
3744 void(ORT_API_CALL* ReleaseCANNProviderOptions)(_Frees_ptr_opt_ OrtCANNProviderOptions* input);
3745
3746 /* \brief Get OrtDevice type from MemoryInfo
3747 *
3748 * \since Version 1.14
3749 */
3750 void(ORT_API_CALL* MemoryInfoGetDeviceType)(_In_ const OrtMemoryInfo* ptr, _Out_ OrtMemoryInfoDeviceType* out);
3751
3752 /* \brief Update the OrtEnv instance with custom log severity level
3753 *
3754 * \param[in] ort_env The OrtEnv instance being used
3755 * \param[in] log_severity_level The log severity level.
3756 *
3757 * \since Version 1.14.
3758 */
3759 ORT_API2_STATUS(UpdateEnvWithCustomLogLevel, _In_ OrtEnv* ort_env, OrtLoggingLevel log_severity_level);
3760
3761 /* \brief Set affinities for intra op threads
3762 *
3763 * Affinity string follows format:
3764 * logical_processor_id,logical_processor_id;logical_processor_id,logical_processor_id
3765 * Semicolon isolates configurations among threads, while comma split processors where ith thread expected to attach to.
3766 * e.g. 1,2,3;4,5
3767 * specifies affinities for two threads, with the 1st thread attach to the 1st, 2nd, and 3rd processor, and 2nd thread to the 4th and 5th.
3768 * To ease the configuration, an "interval" is also allowed:
3769 * e.g. 1-8;8-16;17-24
3770 * orders that the 1st thread runs on first eight processors, 2nd thread runs on next eight processors, and so forth.
3771 * Note:
3772 * 1. Once set, the number of thread affinities must equal to intra_op_num_threads - 1,
3773 * ort does not set affinity on the main thread which is started and managed by the calling app;
3774 * 2. For windows, ort will infer the group id from a logical processor id, for example, assuming there are two groups with each has 64 logical processors,
3775 * an id of 64 will be inferred as the last processor of the 1st group, while 65 will be interpreted as the 1st processor of the second group.
3776 * Hence 64-65 is an invalid configuration, because a windows thread cannot be attached to processors across group boundary.
3777 *
3778 * \since Version 1.14
3779 */
3780 ORT_API2_STATUS(SetGlobalIntraOpThreadAffinity, _Inout_ OrtThreadingOptions* tp_options, const char* affinity_string);
3781
3800 ORT_API2_STATUS(RegisterCustomOpsLibrary_V2, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* library_name);
3801
3826 ORT_API2_STATUS(RegisterCustomOpsUsingFunction, _Inout_ OrtSessionOptions* options,
3827 _In_ const char* registration_func_name);
3828
3832
3844 ORT_API2_STATUS(KernelInfo_GetInputCount, _In_ const OrtKernelInfo* info, _Out_ size_t* out);
3845
3857 ORT_API2_STATUS(KernelInfo_GetOutputCount, _In_ const OrtKernelInfo* info, _Out_ size_t* out);
3858
3883 ORT_API2_STATUS(KernelInfo_GetInputName, _In_ const OrtKernelInfo* info, size_t index, _Out_ char* out,
3884 _Inout_ size_t* size);
3885
3911 ORT_API2_STATUS(KernelInfo_GetOutputName, _In_ const OrtKernelInfo* info, size_t index, _Out_ char* out,
3912 _Inout_ size_t* size);
3913
3926 ORT_API2_STATUS(KernelInfo_GetInputTypeInfo, _In_ const OrtKernelInfo* info, size_t index,
3927 _Outptr_ OrtTypeInfo** type_info);
3928
3941 ORT_API2_STATUS(KernelInfo_GetOutputTypeInfo, _In_ const OrtKernelInfo* info, size_t index,
3942 _Outptr_ OrtTypeInfo** type_info);
3943
3956 ORT_API2_STATUS(KernelInfoGetAttribute_tensor, _In_ const OrtKernelInfo* info, _In_z_ const char* name,
3957 _Inout_ OrtAllocator* allocator, _Outptr_ OrtValue** out);
3958
3963
3979 ORT_API2_STATUS(HasSessionConfigEntry, _In_ const OrtSessionOptions* options,
3980 _In_z_ const char* config_key, _Out_ int* out);
3981
4010 ORT_API2_STATUS(GetSessionConfigEntry, _In_ const OrtSessionOptions* options,
4011 _In_z_ const char* config_key, _Out_ char* config_value, _Inout_ size_t* size);
4012
4014
4027 _In_ OrtSessionOptions* options, _In_ const OrtDnnlProviderOptions* dnnl_options);
4028
4037 ORT_API2_STATUS(CreateDnnlProviderOptions, _Outptr_ OrtDnnlProviderOptions** out);
4038
4055 ORT_API2_STATUS(UpdateDnnlProviderOptions, _Inout_ OrtDnnlProviderOptions* dnnl_options,
4056 _In_reads_(num_keys) const char* const* provider_options_keys,
4057 _In_reads_(num_keys) const char* const* provider_options_values,
4058 _In_ size_t num_keys);
4059
4074 ORT_API2_STATUS(GetDnnlProviderOptionsAsString, _In_ const OrtDnnlProviderOptions* dnnl_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
4075
4080 void(ORT_API_CALL* ReleaseDnnlProviderOptions)(_Frees_ptr_opt_ OrtDnnlProviderOptions* input);
4081
4085
4108 ORT_API2_STATUS(KernelInfo_GetNodeName, _In_ const OrtKernelInfo* info, _Out_ char* out, _Inout_ size_t* size);
4109
4121 ORT_API2_STATUS(KernelInfo_GetLogger, _In_ const OrtKernelInfo* info, _Outptr_ const OrtLogger** logger);
4122
4127
4139 ORT_API2_STATUS(KernelContext_GetLogger, _In_ const OrtKernelContext* context, _Outptr_ const OrtLogger** logger);
4140
4145
4164 ORT_API2_STATUS(Logger_LogMessage, _In_ const OrtLogger* logger, OrtLoggingLevel log_severity_level,
4165 _In_z_ const char* message, _In_z_ const ORTCHAR_T* file_path, int line_number,
4166 _In_z_ const char* func_name);
4167
4179 ORT_API2_STATUS(Logger_GetLoggingSeverityLevel, _In_ const OrtLogger* logger, _Out_ OrtLoggingLevel* out);
4180
4182
4196 ORT_API2_STATUS(KernelInfoGetConstantInput_tensor, _In_ const OrtKernelInfo* info, size_t index, _Out_ int* is_constant, _Outptr_ const OrtValue** out);
4197
4218 ORT_API2_STATUS(CastTypeInfoToOptionalTypeInfo, _In_ const OrtTypeInfo* type_info,
4219 _Outptr_result_maybenull_ const OrtOptionalTypeInfo** out);
4220
4237 ORT_API2_STATUS(GetOptionalContainedTypeInfo, _In_ const OrtOptionalTypeInfo* optional_type_info,
4238 _Outptr_ OrtTypeInfo** out);
4239
4250 ORT_API2_STATUS(GetResizedStringTensorElementBuffer, _Inout_ OrtValue* value, _In_ size_t index, _In_ size_t length_in_bytes, _Inout_ char** buffer);
4251
4262 ORT_API2_STATUS(KernelContext_GetAllocator, _In_ const OrtKernelContext* context, _In_ const OrtMemoryInfo* mem_info, _Outptr_ OrtAllocator** out);
4263
4270 const char*(ORT_API_CALL* GetBuildInfoString)(void);
4271
4274
4283 ORT_API2_STATUS(CreateROCMProviderOptions, _Outptr_ OrtROCMProviderOptions** out);
4284
4302 ORT_API2_STATUS(UpdateROCMProviderOptions, _Inout_ OrtROCMProviderOptions* rocm_options,
4303 _In_reads_(num_keys) const char* const* provider_options_keys,
4304 _In_reads_(num_keys) const char* const* provider_options_values,
4305 _In_ size_t num_keys);
4306
4321 ORT_API2_STATUS(GetROCMProviderOptionsAsString, _In_ const OrtROCMProviderOptions* rocm_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
4322
4329 void(ORT_API_CALL* ReleaseROCMProviderOptions)(_Frees_ptr_opt_ OrtROCMProviderOptions* input);
4330
4344 ORT_API2_STATUS(CreateAndRegisterAllocatorV2, _Inout_ OrtEnv* env, _In_ const char* provider_type, _In_ const OrtMemoryInfo* mem_info, _In_ const OrtArenaCfg* arena_cfg,
4345 _In_reads_(num_keys) const char* const* provider_options_keys, _In_reads_(num_keys) const char* const* provider_options_values, _In_ size_t num_keys);
4346
4365 ORT_API2_STATUS(RunAsync, _Inout_ OrtSession* session, _In_opt_ const OrtRunOptions* run_options,
4366 _In_reads_(input_len) const char* const* input_names,
4367 _In_reads_(input_len) const OrtValue* const* input, size_t input_len,
4368 _In_reads_(output_names_len) const char* const* output_names, size_t output_names_len,
4369 _Inout_updates_all_(output_names_len) OrtValue** output,
4370 _In_ RunAsyncCallbackFn run_async_callback, _In_opt_ void* user_data);
4371
4384 ORT_API2_STATUS(UpdateTensorRTProviderOptionsWithValue, _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options, _In_ const char* key, _In_ void* value);
4385
4396 ORT_API2_STATUS(GetTensorRTProviderOptionsByName, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options, _In_ const char* key, _Outptr_ void** ptr);
4397
4410 ORT_API2_STATUS(UpdateCUDAProviderOptionsWithValue, _Inout_ OrtCUDAProviderOptionsV2* cuda_options, _In_ const char* key, _In_ void* value);
4411
4422 ORT_API2_STATUS(GetCUDAProviderOptionsByName, _In_ const OrtCUDAProviderOptionsV2* cuda_options, _In_ const char* key, _Outptr_ void** ptr);
4423
4435 ORT_API2_STATUS(KernelContext_GetResource, _In_ const OrtKernelContext* context, _In_ int resouce_version, _In_ int resource_id, _Outptr_ void** resource);
4436
4454 ORT_API2_STATUS(SetUserLoggingFunction, _Inout_ OrtSessionOptions* options,
4455 _In_ OrtLoggingFunction user_logging_function, _In_opt_ void* user_logging_param);
4456
4465 ORT_API2_STATUS(ShapeInferContext_GetInputCount, _In_ const OrtShapeInferContext* context, _Out_ size_t* out);
4466
4476 ORT_API2_STATUS(ShapeInferContext_GetInputTypeShape, _In_ const OrtShapeInferContext* context, _In_ size_t index, _Outptr_ OrtTensorTypeAndShapeInfo** info);
4477
4487 ORT_API2_STATUS(ShapeInferContext_GetAttribute, _In_ const OrtShapeInferContext* context, _In_ const char* attr_name, _Outptr_ const OrtOpAttr** attr);
4488
4498 ORT_API2_STATUS(ShapeInferContext_SetOutputTypeShape, _In_ const OrtShapeInferContext* context, _In_ size_t index, _In_ const OrtTensorTypeAndShapeInfo* info);
4499
4509 ORT_API2_STATUS(SetSymbolicDimensions, _In_ OrtTensorTypeAndShapeInfo* info, _In_ const char* dim_params[], _In_ size_t dim_params_length);
4510
4522 ORT_API2_STATUS(ReadOpAttr, _In_ const OrtOpAttr* op_attr, _In_ OrtOpAttrType type, _Inout_ void* data, _In_ size_t len, _Out_ size_t* out);
4523};
4524
4525/*
4526 * Steps to use a custom op:
4527 * 1 Create an OrtCustomOpDomain with the domain name used by the custom ops
4528 * 2 Create an OrtCustomOp structure for each op and add them to the domain
4529 * 3 Call OrtAddCustomOpDomain to add the custom domain of ops to the session options
4530 */
4531
4532// Specifies some characteristics of inputs/outputs of custom ops:
4533// Specify if the inputs/outputs are one of:
4534// 1) Non-optional (input/output must be present in the node)
4535// 2) Optional (input/output may be absent in the node)
4536// 3) Variadic: A variadic input or output specifies N (i.e., the minimum arity) or more operands.
4537// Only the last input or output of a custom op may be marked as variadic.
4538// The homogeneity of the variadic input or output determines whether all operands must be of the same
4539// tensor element type.
4545
4546/*
4547 * The OrtCustomOp structure defines a custom op's schema and its kernel callbacks. The callbacks are filled in by
4548 * the implementor of the custom op.
4549 */
4551 uint32_t version; // Must be initialized to ORT_API_VERSION
4552
4553 // This callback creates the kernel, which is a user defined
4554 // parameter that is passed to the Kernel* callbacks below. It is
4555 // recommended to use CreateKernelV2 which allows for a safe error
4556 // propagation by returning an OrtStatusPtr.
4557 void*(ORT_API_CALL* CreateKernel)(_In_ const struct OrtCustomOp* op, _In_ const OrtApi* api,
4558 _In_ const OrtKernelInfo* info);
4559
4560 // Returns the name of the op
4561 const char*(ORT_API_CALL* GetName)(_In_ const struct OrtCustomOp* op);
4562
4563 // Returns the type of the execution provider, return nullptr to use CPU execution provider
4564 const char*(ORT_API_CALL* GetExecutionProviderType)(_In_ const struct OrtCustomOp* op);
4565
4566 // Returns the count and types of the input & output tensors
4567 ONNXTensorElementDataType(ORT_API_CALL* GetInputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
4568 size_t(ORT_API_CALL* GetInputTypeCount)(_In_ const struct OrtCustomOp* op);
4569 ONNXTensorElementDataType(ORT_API_CALL* GetOutputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
4570 size_t(ORT_API_CALL* GetOutputTypeCount)(_In_ const struct OrtCustomOp* op);
4571
4572 // Perform a computation step. It is recommended to use
4573 // KernelComputeV2 which allows for a safe error propagation by
4574 // returning an OrtStatusPtr.
4575 void(ORT_API_CALL* KernelCompute)(_In_ void* op_kernel, _In_ OrtKernelContext* context);
4576 void(ORT_API_CALL* KernelDestroy)(_In_ void* op_kernel);
4577
4578 // Returns the characteristics of the input & output tensors
4579 OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetInputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
4580 OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
4581
4582 // Returns the memory type of the input tensors. This API allows the custom op
4583 // to place the inputs on specific devices. By default, it returns
4584 // OrtMemTypeDefault, which means the input is placed on the default device for
4585 // the execution provider. If the inputs need to be with different memory tyeps,
4586 // this function can be overridden to return the specific memory types.
4587 OrtMemType(ORT_API_CALL* GetInputMemoryType)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
4588
4589 // Returns the minimum number of input arguments expected for the variadic input.
4590 // Applicable only for custom ops that have a variadic input.
4591 int(ORT_API_CALL* GetVariadicInputMinArity)(_In_ const struct OrtCustomOp* op);
4592
4593 // Returns true (non-zero) if all arguments of a variadic input have to be of the same type (homogeneous),
4594 // and false (zero) otherwise.
4595 // Applicable only for custom ops that have a variadic input.
4596 int(ORT_API_CALL* GetVariadicInputHomogeneity)(_In_ const struct OrtCustomOp* op);
4597
4598 // Returns the minimum number of output values expected for the variadic output.
4599 // Applicable only for custom ops that have a variadic output.
4600 int(ORT_API_CALL* GetVariadicOutputMinArity)(_In_ const struct OrtCustomOp* op);
4601
4602 // Returns true (non-zero) if all outputs values of a variadic output have to be of the same type (homogeneous),
4603 // and false (zero) otherwise.
4604 // Applicable only for custom ops that have a variadic output.
4605 int(ORT_API_CALL* GetVariadicOutputHomogeneity)(_In_ const struct OrtCustomOp* op);
4606
4607 // Create the kernel state which is passed to each compute call.
4608 OrtStatusPtr(ORT_API_CALL* CreateKernelV2)(_In_ const struct OrtCustomOp* op, _In_ const OrtApi* api,
4609 _In_ const OrtKernelInfo* info,
4610 _Out_ void** kernel);
4611
4612 // Perform the computation step.
4613 OrtStatusPtr(ORT_API_CALL* KernelComputeV2)(_In_ void* op_kernel, _In_ OrtKernelContext* context);
4614
4615 OrtStatusPtr(ORT_API_CALL* InferOutputShapeFn)(_In_ const struct OrtCustomOp* op, _In_ OrtShapeInferContext*);
4616
4617 // Get start range
4618 int(ORT_API_CALL* GetStartVersion)(_In_ const struct OrtCustomOp* op);
4619 int(ORT_API_CALL* GetEndVersion)(_In_ const struct OrtCustomOp* op);
4620};
4621
4622/*
4623 * This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality
4624 * This function always exists, but will only succeed if Onnxruntime was built with CUDA support and the CUDA provider shared library exists
4625 *
4626 * \param device_id CUDA device id, starts from zero.
4627 */
4628ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id);
4629
4630/*
4631 * This is the old way to add the ROCm provider to the session, please use
4632 * SessionOptionsAppendExecutionProvider_ROCM above to access the latest functionality
4633 * This function always exists, but will only succeed if Onnxruntime was built with
4634 * HIP support and the ROCm provider shared library exists
4635 *
4636 * \param device_id HIP device id, starts from zero.
4637 */
4638ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_ROCM, _In_ OrtSessionOptions* options, int device_id);
4639
4640/*
4641 * This is the old way to add the MIGraphX provider to the session, please use
4642 * SessionOptionsAppendExecutionProvider_MIGraphX above to access the latest functionality
4643 * This function always exists, but will only succeed if Onnxruntime was built with
4644 * HIP support and the MIGraphX provider shared library exists
4645 *
4646 * \param device_id HIP device id, starts from zero.
4647 */
4648ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_MIGraphX, _In_ OrtSessionOptions* options, int device_id);
4649
4650/*
4651 * This is the old way to add the oneDNN provider to the session, please use
4652 * SessionOptionsAppendExecutionProvider_oneDNN above to access the latest functionality
4653 * This function always exists, but will only succeed if Onnxruntime was built with
4654 * oneDNN support and the oneDNN provider shared library exists
4655 *
4656 * \param use_arena zero: false. non-zero: true.
4657 */
4658ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Dnnl, _In_ OrtSessionOptions* options, int use_arena);
4659
4660/*
4661 * This is the old way to add the TensorRT provider to the session, please use SessionOptionsAppendExecutionProvider_TensorRT_V2 above to access the latest functionality
4662 * This function always exists, but will only succeed if Onnxruntime was built with TensorRT support and the TensorRT provider shared library exists
4663 *
4664 * \param device_id CUDA device id, starts from zero.
4665 */
4666ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Tensorrt, _In_ OrtSessionOptions* options, int device_id);
4667
4668#ifdef __cplusplus
4669}
4670#endif
OrtStatus * OrtSessionOptionsAppendExecutionProvider_MIGraphX(OrtSessionOptions *options, int device_id)
struct OrtMemoryInfo OrtMemoryInfo
Definition onnxruntime_c_api.h:278
struct OrtKernelInfo OrtKernelInfo
Definition onnxruntime_c_api.h:358
OrtStatus * OrtSessionOptionsAppendExecutionProvider_Tensorrt(OrtSessionOptions *options, int device_id)
OrtLoggingLevel
Logging severity levels.
Definition onnxruntime_c_api.h:233
const struct OrtCustomHandleType * OrtCustomThreadHandle
OrtMemoryInfoDeviceType
This mimics OrtDevice type constants so they can be returned in the API.
Definition onnxruntime_c_api.h:382
struct OrtShapeInferContext OrtShapeInferContext
Definition onnxruntime_c_api.h:302
void(* OrtLoggingFunction)(void *param, OrtLoggingLevel severity, const char *category, const char *logid, const char *code_location, const char *message)
Definition onnxruntime_c_api.h:323
void(* OrtCustomJoinThreadFn)(OrtCustomThreadHandle ort_custom_thread_handle)
Custom thread join function.
Definition onnxruntime_c_api.h:698
OrtStatus *(* RegisterCustomOpsFn)(OrtSessionOptions *options, const OrtApiBase *api)
Definition onnxruntime_c_api.h:700
OrtCustomOpInputOutputCharacteristic
Definition onnxruntime_c_api.h:4540
struct OrtTensorRTProviderOptionsV2 OrtTensorRTProviderOptionsV2
Definition onnxruntime_c_api.h:295
struct OrtOpAttr OrtOpAttr
Definition onnxruntime_c_api.h:300
struct OrtThreadingOptions OrtThreadingOptions
Definition onnxruntime_c_api.h:292
struct OrtSequenceTypeInfo OrtSequenceTypeInfo
Definition onnxruntime_c_api.h:286
OrtLanguageProjection
Language projection identifiers /see OrtApi::SetLanguageProjection.
Definition onnxruntime_c_api.h:347
struct OrtDnnlProviderOptions OrtDnnlProviderOptions
Definition onnxruntime_c_api.h:298
OrtSparseIndicesFormat
Definition onnxruntime_c_api.h:222
struct OrtPrepackedWeightsContainer OrtPrepackedWeightsContainer
Definition onnxruntime_c_api.h:294
struct OrtSession OrtSession
Definition onnxruntime_c_api.h:280
struct OrtCustomOpDomain OrtCustomOpDomain
Definition onnxruntime_c_api.h:289
struct OrtIoBinding OrtIoBinding
Definition onnxruntime_c_api.h:279
OrtAllocatorType
Definition onnxruntime_c_api.h:364
struct OrtOp OrtOp
Definition onnxruntime_c_api.h:299
struct OrtModelMetadata OrtModelMetadata
Definition onnxruntime_c_api.h:290
struct OrtTypeInfo OrtTypeInfo
Definition onnxruntime_c_api.h:283
struct OrtTensorTypeAndShapeInfo OrtTensorTypeAndShapeInfo
Definition onnxruntime_c_api.h:284
struct OrtCUDAProviderOptionsV2 OrtCUDAProviderOptionsV2
Definition onnxruntime_c_api.h:296
struct OrtKernelContext OrtKernelContext
Definition onnxruntime_c_api.h:360
OrtStatus * OrtSessionOptionsAppendExecutionProvider_Dnnl(OrtSessionOptions *options, int use_arena)
OrtCudnnConvAlgoSearch
Algorithm to use for cuDNN Convolution Op.
Definition onnxruntime_c_api.h:390
struct OrtCANNProviderOptions OrtCANNProviderOptions
Definition onnxruntime_c_api.h:297
void(* RunAsyncCallbackFn)(void *user_data, OrtValue **outputs, size_t num_outputs, OrtStatusPtr status)
Callback function for RunAsync.
Definition onnxruntime_c_api.h:709
struct OrtRunOptions OrtRunOptions
Definition onnxruntime_c_api.h:282
void(* OrtThreadWorkerFn)(void *ort_worker_fn_param)
Thread work loop function.
Definition onnxruntime_c_api.h:680
OrtStatus * OrtSessionOptionsAppendExecutionProvider_ROCM(OrtSessionOptions *options, int device_id)
struct OrtOptionalTypeInfo OrtOptionalTypeInfo
Definition onnxruntime_c_api.h:287
struct OrtSessionOptions OrtSessionOptions
Definition onnxruntime_c_api.h:288
struct OrtValue OrtValue
Definition onnxruntime_c_api.h:281
GraphOptimizationLevel
Graph optimization level.
Definition onnxruntime_c_api.h:332
OrtStatus * OrtStatusPtr
Definition onnxruntime_c_api.h:307
OrtMemType
Memory types for allocated memory, execution provider specific types should be extended in each provi...
Definition onnxruntime_c_api.h:373
OrtSparseFormat
Definition onnxruntime_c_api.h:214
ONNXType
Definition onnxruntime_c_api.h:202
struct OrtEnv OrtEnv
Definition onnxruntime_c_api.h:276
OrtErrorCode
Definition onnxruntime_c_api.h:241
struct OrtStatus OrtStatus
Definition onnxruntime_c_api.h:277
struct OrtLogger OrtLogger
Definition onnxruntime_c_api.h:301
struct OrtMapTypeInfo OrtMapTypeInfo
Definition onnxruntime_c_api.h:285
struct OrtArenaCfg OrtArenaCfg
Definition onnxruntime_c_api.h:293
ExecutionMode
Definition onnxruntime_c_api.h:339
OrtStatus * OrtSessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions *options, int device_id)
OrtOpAttrType
Definition onnxruntime_c_api.h:256
OrtCustomThreadHandle(* OrtCustomCreateThreadFn)(void *ort_custom_thread_creation_options, OrtThreadWorkerFn ort_thread_worker_fn, void *ort_worker_fn_param)
Ort custom thread creation function.
Definition onnxruntime_c_api.h:691
ONNXTensorElementDataType
Definition onnxruntime_c_api.h:176
const OrtApiBase * OrtGetApiBase(void)
The Onnxruntime library's entry point to access the C API.
@ ORT_LOGGING_LEVEL_VERBOSE
Verbose informational messages (least severe).
Definition onnxruntime_c_api.h:234
@ ORT_LOGGING_LEVEL_INFO
Informational messages.
Definition onnxruntime_c_api.h:235
@ ORT_LOGGING_LEVEL_ERROR
Error messages.
Definition onnxruntime_c_api.h:237
@ ORT_LOGGING_LEVEL_WARNING
Warning messages.
Definition onnxruntime_c_api.h:236
@ ORT_LOGGING_LEVEL_FATAL
Fatal error messages (most severe).
Definition onnxruntime_c_api.h:238
@ OrtMemoryInfoDeviceType_GPU
Definition onnxruntime_c_api.h:384
@ OrtMemoryInfoDeviceType_FPGA
Definition onnxruntime_c_api.h:385
@ OrtMemoryInfoDeviceType_CPU
Definition onnxruntime_c_api.h:383
@ INPUT_OUTPUT_VARIADIC
Definition onnxruntime_c_api.h:4543
@ INPUT_OUTPUT_REQUIRED
Definition onnxruntime_c_api.h:4541
@ INPUT_OUTPUT_OPTIONAL
Definition onnxruntime_c_api.h:4542
@ ORT_PROJECTION_C
Definition onnxruntime_c_api.h:348
@ ORT_PROJECTION_PYTHON
Definition onnxruntime_c_api.h:351
@ ORT_PROJECTION_CPLUSPLUS
Definition onnxruntime_c_api.h:349
@ ORT_PROJECTION_WINML
Definition onnxruntime_c_api.h:353
@ ORT_PROJECTION_CSHARP
Definition onnxruntime_c_api.h:350
@ ORT_PROJECTION_JAVA
Definition onnxruntime_c_api.h:352
@ ORT_PROJECTION_NODEJS
Definition onnxruntime_c_api.h:354
@ ORT_SPARSE_COO_INDICES
Definition onnxruntime_c_api.h:223
@ ORT_SPARSE_BLOCK_SPARSE_INDICES
Definition onnxruntime_c_api.h:226
@ ORT_SPARSE_CSR_OUTER_INDICES
Definition onnxruntime_c_api.h:225
@ ORT_SPARSE_CSR_INNER_INDICES
Definition onnxruntime_c_api.h:224
@ OrtDeviceAllocator
Definition onnxruntime_c_api.h:366
@ OrtArenaAllocator
Definition onnxruntime_c_api.h:367
@ OrtInvalidAllocator
Definition onnxruntime_c_api.h:365
@ OrtCudnnConvAlgoSearchDefault
Definition onnxruntime_c_api.h:393
@ OrtCudnnConvAlgoSearchExhaustive
Definition onnxruntime_c_api.h:391
@ OrtCudnnConvAlgoSearchHeuristic
Definition onnxruntime_c_api.h:392
@ ORT_ENABLE_BASIC
Definition onnxruntime_c_api.h:334
@ ORT_ENABLE_ALL
Definition onnxruntime_c_api.h:336
@ ORT_DISABLE_ALL
Definition onnxruntime_c_api.h:333
@ ORT_ENABLE_EXTENDED
Definition onnxruntime_c_api.h:335
@ OrtMemTypeCPUInput
Any CPU memory used by non-CPU execution provider.
Definition onnxruntime_c_api.h:374
@ OrtMemTypeCPU
Temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED.
Definition onnxruntime_c_api.h:376
@ OrtMemTypeDefault
The default allocator for execution provider.
Definition onnxruntime_c_api.h:377
@ OrtMemTypeCPUOutput
CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED.
Definition onnxruntime_c_api.h:375
@ ORT_SPARSE_CSRC
Definition onnxruntime_c_api.h:217
@ ORT_SPARSE_COO
Definition onnxruntime_c_api.h:216
@ ORT_SPARSE_BLOCK_SPARSE
Definition onnxruntime_c_api.h:218
@ ORT_SPARSE_UNDEFINED
Definition onnxruntime_c_api.h:215
@ ONNX_TYPE_SEQUENCE
Definition onnxruntime_c_api.h:205
@ ONNX_TYPE_MAP
Definition onnxruntime_c_api.h:206
@ ONNX_TYPE_OPAQUE
Definition onnxruntime_c_api.h:207
@ ONNX_TYPE_UNKNOWN
Definition onnxruntime_c_api.h:203
@ ONNX_TYPE_TENSOR
Definition onnxruntime_c_api.h:204
@ ONNX_TYPE_SPARSETENSOR
Definition onnxruntime_c_api.h:208
@ ONNX_TYPE_OPTIONAL
Definition onnxruntime_c_api.h:209
@ ORT_NO_SUCHFILE
Definition onnxruntime_c_api.h:245
@ ORT_OK
Definition onnxruntime_c_api.h:242
@ ORT_INVALID_ARGUMENT
Definition onnxruntime_c_api.h:244
@ ORT_EP_FAIL
Definition onnxruntime_c_api.h:253
@ ORT_NOT_IMPLEMENTED
Definition onnxruntime_c_api.h:251
@ ORT_RUNTIME_EXCEPTION
Definition onnxruntime_c_api.h:248
@ ORT_ENGINE_ERROR
Definition onnxruntime_c_api.h:247
@ ORT_FAIL
Definition onnxruntime_c_api.h:243
@ ORT_INVALID_PROTOBUF
Definition onnxruntime_c_api.h:249
@ ORT_NO_MODEL
Definition onnxruntime_c_api.h:246
@ ORT_INVALID_GRAPH
Definition onnxruntime_c_api.h:252
@ ORT_MODEL_LOADED
Definition onnxruntime_c_api.h:250
@ ORT_PARALLEL
Definition onnxruntime_c_api.h:341
@ ORT_SEQUENTIAL
Definition onnxruntime_c_api.h:340
@ ORT_OP_ATTR_INT
Definition onnxruntime_c_api.h:258
@ ORT_OP_ATTR_FLOATS
Definition onnxruntime_c_api.h:261
@ ORT_OP_ATTR_STRINGS
Definition onnxruntime_c_api.h:263
@ ORT_OP_ATTR_UNDEFINED
Definition onnxruntime_c_api.h:257
@ ORT_OP_ATTR_INTS
Definition onnxruntime_c_api.h:259
@ ORT_OP_ATTR_STRING
Definition onnxruntime_c_api.h:262
@ ORT_OP_ATTR_FLOAT
Definition onnxruntime_c_api.h:260
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING
Definition onnxruntime_c_api.h:185
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32
Definition onnxruntime_c_api.h:183
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32
Definition onnxruntime_c_api.h:189
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16
Definition onnxruntime_c_api.h:181
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED
Definition onnxruntime_c_api.h:177
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128
Definition onnxruntime_c_api.h:192
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2FNUZ
Definition onnxruntime_c_api.h:198
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64
Definition onnxruntime_c_api.h:190
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64
Definition onnxruntime_c_api.h:184
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2
Definition onnxruntime_c_api.h:197
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL
Definition onnxruntime_c_api.h:186
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16
Definition onnxruntime_c_api.h:187
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8
Definition onnxruntime_c_api.h:179
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16
Definition onnxruntime_c_api.h:182
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE
Definition onnxruntime_c_api.h:188
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8
Definition onnxruntime_c_api.h:180
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT
Definition onnxruntime_c_api.h:178
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FN
Definition onnxruntime_c_api.h:195
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16
Definition onnxruntime_c_api.h:193
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64
Definition onnxruntime_c_api.h:191
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FNUZ
Definition onnxruntime_c_api.h:196
Memory allocation interface.
Definition onnxruntime_c_api.h:316
void(* Free)(struct OrtAllocator *this_, void *p)
Free a block of memory previously allocated with OrtAllocator::Alloc.
Definition onnxruntime_c_api.h:319
const struct OrtMemoryInfo *(* Info)(const struct OrtAllocator *this_)
Return a pointer to an OrtMemoryInfo that describes this allocator.
Definition onnxruntime_c_api.h:320
uint32_t version
Must be initialized to ORT_API_VERSION.
Definition onnxruntime_c_api.h:317
void *(* Alloc)(struct OrtAllocator *this_, size_t size)
Returns a pointer to an allocated block of size bytes.
Definition onnxruntime_c_api.h:318
The helper interface to get the right version of OrtApi.
Definition onnxruntime_c_api.h:648
const char *(* GetVersionString)(void)
Returns a null terminated string of the version of the Onnxruntime library (eg: "1....
Definition onnxruntime_c_api.h:664
const OrtApi *(* GetApi)(uint32_t version)
Get a pointer to the requested version of the OrtApi.
Definition onnxruntime_c_api.h:658
The C API.
Definition onnxruntime_c_api.h:718
OrtStatus * SetGlobalIntraOpThreadAffinity(OrtThreadingOptions *tp_options, const char *affinity_string)
OrtStatus * ShapeInferContext_SetOutputTypeShape(const OrtShapeInferContext *context, size_t index, const OrtTensorTypeAndShapeInfo *info)
OrtStatus * SessionGetOverridableInitializerTypeInfo(const OrtSession *session, size_t index, OrtTypeInfo **type_info)
Get overridable initializer type information.
OrtStatus * SessionOptionsSetCustomJoinThreadFn(OrtSessionOptions *options, OrtCustomJoinThreadFn ort_custom_join_thread_fn)
Set custom thread join function.
OrtStatus * KernelInfoGetAttributeArray_int64(const OrtKernelInfo *info, const char *name, int64_t *out, size_t *size)
Fetch an array of int64_t values stored as an attribute in the graph node.
OrtStatus * CreateSessionOptions(OrtSessionOptions **options)
Create an OrtSessionOptions object.
void(* ReleaseDnnlProviderOptions)(OrtDnnlProviderOptions *input)
Release an OrtDnnlProviderOptions.
Definition onnxruntime_c_api.h:4080
OrtStatus * TensorAt(OrtValue *value, const int64_t *location_values, size_t location_values_count, void **out)
Direct memory access to a specified tensor element.
OrtStatus * KernelInfoGetAttribute_float(const OrtKernelInfo *info, const char *name, float *out)
Get a float stored as an attribute in the graph node.
OrtStatus * GetCANNProviderOptionsAsString(const OrtCANNProviderOptions *cann_options, OrtAllocator *allocator, char **ptr)
Get serialized CANN provider options string.
OrtStatus * InvokeOp(const OrtKernelContext *context, const OrtOp *ort_op, const OrtValue *const *input_values, int input_count, OrtValue *const *output_values, int output_count)
: Invoke the operator created by OrtApi::CreateOp The inputs must follow the order as specified in on...
OrtStatus * HasSessionConfigEntry(const OrtSessionOptions *options, const char *config_key, int *out)
Checks if the given session configuration entry exists.
const char *(* GetBuildInfoString)(void)
Returns a null terminated string of the build info including git info and cxx flags.
Definition onnxruntime_c_api.h:4270
OrtStatus * GetTensorMemoryInfo(const OrtValue *value, const OrtMemoryInfo **mem_info)
Returns a pointer to the OrtMemoryInfo of a Tensor.
OrtStatus * EnableCpuMemArena(OrtSessionOptions *options)
Enable the memory arena on CPU.
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 * GetValueCount(const OrtValue *value, size_t *out)
Get non tensor value count from an OrtValue.
OrtStatus * SetGlobalCustomJoinThreadFn(OrtThreadingOptions *tp_options, OrtCustomJoinThreadFn ort_custom_join_thread_fn)
Set custom thread join function for global thread pools.
OrtStatus * CreateCUDAProviderOptions(OrtCUDAProviderOptionsV2 **out)
Create an OrtCUDAProviderOptionsV2.
OrtStatus * DisableProfiling(OrtSessionOptions *options)
Disable profiling for a session.
OrtStatus * KernelInfoGetAttributeArray_float(const OrtKernelInfo *info, const char *name, float *out, size_t *size)
Fetch an array of int64_t values stored as an attribute in the graph node.
OrtStatus * CreatePrepackedWeightsContainer(OrtPrepackedWeightsContainer **out)
Create an OrtPrepackedWeightsContainer.
OrtStatus * UpdateTensorRTProviderOptionsWithValue(OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *key, void *value)
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.
OrtStatus * AddFreeDimensionOverrideByName(OrtSessionOptions *options, const char *dim_name, int64_t dim_value)
OrtStatus * KernelInfo_GetInputCount(const OrtKernelInfo *info, size_t *out)
Get the number of inputs from OrtKernelInfo.
OrtStatus * GetSparseTensorFormat(const OrtValue *ort_value, enum OrtSparseFormat *out)
Returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor.
OrtStatus * KernelContext_GetGPUComputeStream(const OrtKernelContext *context, void **out)
Used for custom operators, gets the GPU compute stream to use to launch the custom a GPU kernel.
OrtStatus * UpdateCANNProviderOptions(OrtCANNProviderOptions *cann_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Set options in a CANN Execution Provider.
OrtStatus * CreateAndRegisterAllocatorV2(OrtEnv *env, const char *provider_type, const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Create an allocator with specific type and register it with the OrtEnv This API enhance CreateAndRegi...
OrtStatus * SessionGetOutputName(const OrtSession *session, size_t index, OrtAllocator *allocator, char **value)
Get output name.
OrtStatus * SessionOptionsAppendExecutionProvider_TensorRT(OrtSessionOptions *options, const OrtTensorRTProviderOptions *tensorrt_options)
Append TensorRT provider to session options.
const OrtTrainingApi *(* GetTrainingApi)(uint32_t version)
Gets the Training C Api struct.
Definition onnxruntime_c_api.h:3678
OrtStatus * SetIntraOpNumThreads(OrtSessionOptions *options, int intra_op_num_threads)
Sets the number of threads used to parallelize the execution within nodes.
OrtStatus * GetTypeInfo(const OrtValue *value, OrtTypeInfo **out)
Get type information of an OrtValue.
OrtStatus * CastTypeInfoToMapTypeInfo(const OrtTypeInfo *type_info, const OrtMapTypeInfo **out)
Get detailed map information from an OrtTypeInfo.
OrtStatus * KernelContext_GetLogger(const OrtKernelContext *context, const OrtLogger **logger)
Get the runtime logger from OrtKernelContext.
OrtStatus * SetGlobalCustomThreadCreationOptions(OrtThreadingOptions *tp_options, void *ort_custom_thread_creation_options)
Set custom thread creation options for global thread pools.
OrtStatus * AddSessionConfigEntry(OrtSessionOptions *options, const char *config_key, const char *config_value)
Set a session configuration entry as a pair of strings.
OrtStatus * SetGlobalDenormalAsZero(OrtThreadingOptions *tp_options)
Set threading flush-to-zero and denormal-as-zero.
void(* ClearBoundInputs)(OrtIoBinding *binding_ptr) __attribute__((nonnull))
Clears any previously set Inputs for an OrtIoBinding.
Definition onnxruntime_c_api.h:2390
OrtStatus * KernelInfo_GetInputTypeInfo(const OrtKernelInfo *info, size_t index, OrtTypeInfo **type_info)
Get the type information for a OrtKernelInfo's input.
OrtStatus * KernelInfoGetAttribute_string(const OrtKernelInfo *info, const char *name, char *out, size_t *size)
Fetch a string stored as an attribute in the graph node.
OrtStatus * GetSparseTensorIndicesTypeShape(const OrtValue *ort_value, enum OrtSparseIndicesFormat indices_format, OrtTensorTypeAndShapeInfo **out)
Returns data type, shape for the type of indices specified by indices_format.
OrtStatus * SessionOptionsAppendExecutionProvider_MIGraphX(OrtSessionOptions *options, const OrtMIGraphXProviderOptions *migraphx_options)
Append MIGraphX provider to session options.
OrtStatus * RunOptionsSetRunLogVerbosityLevel(OrtRunOptions *options, int log_verbosity_level)
Set per-run log verbosity level.
OrtStatus * AddInitializer(OrtSessionOptions *options, const char *name, const OrtValue *val)
Add a pre-allocated initializer to a session.
OrtStatus * CreateEnv(OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out)
Create an OrtEnv.
OrtStatus * UseCooIndices(OrtValue *ort_value, int64_t *indices_data, size_t indices_num)
OrtStatus * GetTensorMutableData(OrtValue *value, void **out)
Get a pointer to the raw data inside a tensor.
OrtStatus * SessionOptionsAppendExecutionProvider_OpenVINO(OrtSessionOptions *options, const OrtOpenVINOProviderOptions *provider_options)
Append OpenVINO execution provider to the session options.
OrtStatus * IsSparseTensor(const OrtValue *value, int *out)
Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise.
OrtStatus * GetTensorElementType(const OrtTensorTypeAndShapeInfo *info, enum ONNXTensorElementDataType *out)
Get element type in OrtTensorTypeAndShapeInfo.
OrtStatus * CreateSparseTensorAsOrtValue(OrtAllocator *allocator, const int64_t *dense_shape, size_t dense_shape_len, ONNXTensorElementDataType type, OrtValue **out)
Create an OrtValue with a sparse tensor that is empty.
OrtStatus * FillStringTensorElement(OrtValue *value, const char *s, size_t index)
Set a single string in a string tensor.
OrtStatus * CreateTensorWithDataAsOrtValue(const OrtMemoryInfo *info, void *p_data, size_t p_data_len, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out)
Create a tensor backed by a user supplied buffer.
OrtStatus * ModelMetadataGetGraphDescription(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
OrtStatus * UpdateDnnlProviderOptions(OrtDnnlProviderOptions *dnnl_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Set options in a oneDNN Execution Provider.
OrtStatus * GetStringTensorElementLength(const OrtValue *value, size_t index, size_t *out)
Get the length of a single string in a string tensor.
void(* MemoryInfoGetDeviceType)(const OrtMemoryInfo *ptr, OrtMemoryInfoDeviceType *out)
Definition onnxruntime_c_api.h:3750
OrtStatus * AddRunConfigEntry(OrtRunOptions *options, const char *config_key, const char *config_value)
Set a single run configuration entry as a pair of strings.
OrtStatus * GetBoundOutputValues(const OrtIoBinding *binding_ptr, OrtAllocator *allocator, OrtValue ***output, size_t *output_count)
Get the output OrtValue objects from an OrtIoBinding.
OrtStatus * ModelMetadataGetDomain(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
Get domain from an OrtModelMetadata.
OrtStatus * SetLanguageProjection(const OrtEnv *ort_env, OrtLanguageProjection projection)
Set language projection.
OrtStatus * FillStringTensor(OrtValue *value, const char *const *s, size_t s_len)
Set all strings at once in a string tensor.
OrtStatus * SetSessionLogId(OrtSessionOptions *options, const char *logid)
Set session log id.
OrtStatus * SessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions *options, const OrtCUDAProviderOptions *cuda_options)
Append CUDA provider to session options.
OrtStatus * AddExternalInitializers(OrtSessionOptions *options, const char *const *initializer_names, const OrtValue *const *initializers, size_t initializers_num)
Replace initialized Tensors with external data with the data provided in initializers.
OrtStatus * RegisterAllocator(OrtEnv *env, OrtAllocator *allocator)
Register a custom allocator.
OrtStatus * SetGlobalSpinControl(OrtThreadingOptions *tp_options, int allow_spinning)
Set global spin control options.
OrtStatus * MemoryInfoGetId(const OrtMemoryInfo *ptr, int *out)
Get the id from OrtMemoryInfo.
OrtStatus * KernelInfo_GetOutputName(const OrtKernelInfo *info, size_t index, char *out, size_t *size)
Get the name of a OrtKernelInfo's output.
OrtStatus * Logger_LogMessage(const OrtLogger *logger, OrtLoggingLevel log_severity_level, const char *message, const char *file_path, int line_number, const char *func_name)
Logs a message at the given severity level using the provided OrtLogger.
OrtStatus * CreateEnvWithCustomLogger(OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out)
Create an OrtEnv.
OrtStatus * UpdateCUDAProviderOptionsWithValue(OrtCUDAProviderOptionsV2 *cuda_options, const char *key, void *value)
OrtStatus * MemoryInfoGetName(const OrtMemoryInfo *ptr, const char **out)
Get name from OrtMemoryInfo.
OrtStatus * Logger_GetLoggingSeverityLevel(const OrtLogger *logger, OrtLoggingLevel *out)
Get the logging severity level of the OrtLogger.
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 OrtAp...
OrtStatus * KernelContext_GetOutputCount(const OrtKernelContext *context, size_t *out)
Used for custom operators, get the output count of a kernel.
OrtStatus * GetTensorShapeElementCount(const OrtTensorTypeAndShapeInfo *info, size_t *out)
Get total number of elements in a tensor shape from an OrtTensorTypeAndShapeInfo.
OrtStatus * CastTypeInfoToTensorInfo(const OrtTypeInfo *type_info, const OrtTensorTypeAndShapeInfo **out)
Get OrtTensorTypeAndShapeInfo from an OrtTypeInfo.
OrtStatus * GetOptionalContainedTypeInfo(const OrtOptionalTypeInfo *optional_type_info, OrtTypeInfo **out)
Get OrtTypeInfo for the allowed contained type from an OrtOptionalTypeInfo.
OrtStatus * CreateOp(const OrtKernelInfo *info, const char *op_name, const char *domain, int version, const char **type_constraint_names, const ONNXTensorElementDataType *type_constraint_values, int type_constraint_count, const OrtOpAttr *const *attr_values, int attr_count, int input_count, int output_count, OrtOp **ort_op)
: Create onnxruntime native operator
OrtStatus * MemoryInfoGetType(const OrtMemoryInfo *ptr, OrtAllocatorType *out)
Get the OrtAllocatorType from OrtMemoryInfo.
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 A...
OrtStatus * CreateEnvWithGlobalThreadPools(OrtLoggingLevel log_severity_level, const char *logid, const OrtThreadingOptions *tp_options, OrtEnv **out)
Create an OrtEnv.
OrtStatus * KernelContext_GetAllocator(const OrtKernelContext *context, const OrtMemoryInfo *mem_info, OrtAllocator **out)
Get Allocator from KernelContext for a specific memoryInfo. Please use C API ReleaseAllocator to rele...
OrtStatus * KernelInfoGetConstantInput_tensor(const OrtKernelInfo *info, size_t index, int *is_constant, const OrtValue **out)
Get a OrtValue tensor stored as a constant initializer in the graph node.
OrtStatus * GetCUDAProviderOptionsAsString(const OrtCUDAProviderOptionsV2 *cuda_options, OrtAllocator *allocator, char **ptr)
OrtStatus * UpdateCUDAProviderOptions(OrtCUDAProviderOptionsV2 *cuda_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Set options in a CUDA Execution Provider.
OrtStatus * CopyKernelInfo(const OrtKernelInfo *info, OrtKernelInfo **info_copy)
OrtStatus * GetTensorRTProviderOptionsAsString(const OrtTensorRTProviderOptionsV2 *tensorrt_options, OrtAllocator *allocator, char **ptr)
Get serialized TensorRT provider options string.
OrtStatus * SessionOptionsSetCustomThreadCreationOptions(OrtSessionOptions *options, void *ort_custom_thread_creation_options)
Set creation options for custom thread.
OrtStatus * GetDimensionsCount(const OrtTensorTypeAndShapeInfo *info, size_t *out)
Get dimension count in OrtTensorTypeAndShapeInfo.
void(* ReleaseROCMProviderOptions)(OrtROCMProviderOptions *input)
Release an OrtROCMProviderOptions.
Definition onnxruntime_c_api.h:4329
OrtStatus * UpdateROCMProviderOptions(OrtROCMProviderOptions *rocm_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Set options in a ROCm Execution Provider.
OrtStatus * KernelInfo_GetInputName(const OrtKernelInfo *info, size_t index, char *out, size_t *size)
Get the name of a OrtKernelInfo's input.
OrtStatus * RegisterCustomOpsLibrary(OrtSessionOptions *options, const char *library_path, void **library_handle)
OrtStatus * SetCurrentGpuDeviceId(int device_id)
Set current GPU device ID.
OrtStatus * GetOnnxTypeFromTypeInfo(const OrtTypeInfo *type_info, enum ONNXType *out)
Get ONNXType from OrtTypeInfo.
OrtStatus * GetDenotationFromTypeInfo(const OrtTypeInfo *type_info, const char **const denotation, size_t *len)
Get denotation from type information.
void(* ReleaseCANNProviderOptions)(OrtCANNProviderOptions *input)
Release an OrtCANNProviderOptions.
Definition onnxruntime_c_api.h:3744
OrtStatus * SetGlobalInterOpNumThreads(OrtThreadingOptions *tp_options, int inter_op_num_threads)
Set global inter-op thread count.
OrtStatus * CloneSessionOptions(const OrtSessionOptions *in_options, OrtSessionOptions **out_options)
Create a copy of an existing OrtSessionOptions.
OrtStatus * GetSessionConfigEntry(const OrtSessionOptions *options, const char *config_key, char *config_value, size_t *size)
Get a session configuration value.
OrtStatus * SessionOptionsAppendExecutionProvider_TensorRT_V2(OrtSessionOptions *options, const OrtTensorRTProviderOptionsV2 *tensorrt_options)
Append TensorRT execution provider to the session options.
OrtStatus * AddFreeDimensionOverride(OrtSessionOptions *options, const char *dim_denotation, int64_t dim_value)
Override session symbolic dimensions.
OrtStatus * KernelContext_GetOutput(OrtKernelContext *context, size_t index, const int64_t *dim_values, size_t dim_count, OrtValue **out)
Used for custom operators, get an output of a kernel.
OrtStatus * EnableTelemetryEvents(const OrtEnv *env)
Enable Telemetry.
OrtStatus * CreateMemoryInfo(const char *name, enum OrtAllocatorType type, int id, enum OrtMemType mem_type, OrtMemoryInfo **out)
Create an OrtMemoryInfo.
OrtStatus * SessionOptionsAppendExecutionProvider_ROCM(OrtSessionOptions *options, const OrtROCMProviderOptions *rocm_options)
Append ROCM execution provider to the session options.
OrtStatus * SessionGetInputTypeInfo(const OrtSession *session, size_t index, OrtTypeInfo **type_info)
Get input type information.
OrtStatus * GetSymbolicDimensions(const OrtTensorTypeAndShapeInfo *info, const char *dim_params[], size_t dim_params_length)
Get symbolic dimension names in OrtTensorTypeAndShapeInfo.
OrtStatus * GetStringTensorDataLength(const OrtValue *value, size_t *len)
Get total byte length for all strings in a string tensor.
OrtStatus * KernelContext_GetInputCount(const OrtKernelContext *context, size_t *out)
Used for custom operators, get the input count of a kernel.
OrtStatus * BindOutputToDevice(OrtIoBinding *binding_ptr, const char *name, const OrtMemoryInfo *mem_info_ptr)
Bind an OrtIoBinding output to a device.
OrtStatus * SessionOptionsAppendExecutionProvider(OrtSessionOptions *options, const char *provider_name, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
: Append execution provider to the session options.
OrtStatus * SetSessionGraphOptimizationLevel(OrtSessionOptions *options, GraphOptimizationLevel graph_optimization_level)
Set the optimization level to apply when loading a graph.
OrtStatus * ModelMetadataGetDescription(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
Get description from an OrtModelMetadata.
OrtStatus * CreateCANNProviderOptions(OrtCANNProviderOptions **out)
Create an OrtCANNProviderOptions.
OrtStatus * ReadOpAttr(const OrtOpAttr *op_attr, OrtOpAttrType type, void *data, size_t len, size_t *out)
OrtStatus * DisablePerSessionThreads(OrtSessionOptions *options)
Use global thread pool on a session.
OrtStatus * SetDimensions(OrtTensorTypeAndShapeInfo *info, const int64_t *dim_values, size_t dim_count)
Set shape information in OrtTensorTypeAndShapeInfo.
OrtStatus * SetInterOpNumThreads(OrtSessionOptions *options, int inter_op_num_threads)
Sets the number of threads used to parallelize the execution of the graph.
OrtStatus * CustomOpDomain_Add(OrtCustomOpDomain *custom_op_domain, const OrtCustomOp *op)
Add a custom op to a custom op domain.
OrtStatus * GetSequenceElementType(const OrtSequenceTypeInfo *sequence_type_info, OrtTypeInfo **type_info)
Get element type from an OrtSequenceTypeInfo.
OrtStatus * RunOptionsGetRunLogVerbosityLevel(const OrtRunOptions *options, int *log_verbosity_level)
Get per-run log verbosity level.
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 * CreateAndRegisterAllocator(OrtEnv *env, const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg)
Create an allocator and register it with the OrtEnv.
OrtStatus * CreateCpuMemoryInfo(enum OrtAllocatorType type, enum OrtMemType mem_type, OrtMemoryInfo **out)
Create an OrtMemoryInfo for CPU memory.
OrtStatus * AddCustomOpDomain(OrtSessionOptions *options, OrtCustomOpDomain *custom_op_domain)
Add custom op domain to a session options.
OrtStatus * KernelInfo_GetOutputTypeInfo(const OrtKernelInfo *info, size_t index, OrtTypeInfo **type_info)
Get the type information for a OrtKernelInfo's output.
OrtStatus * KernelContext_GetInput(const OrtKernelContext *context, size_t index, const OrtValue **out)
Used for custom operators, get an input of a kernel.
OrtStatus * CreateEnvWithCustomLoggerAndGlobalThreadPools(OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, const struct OrtThreadingOptions *tp_options, OrtEnv **out)
OrtStatus * DisableTelemetryEvents(const OrtEnv *env)
Disable Telemetry.
OrtStatus * KernelInfo_GetOutputCount(const OrtKernelInfo *info, size_t *out)
Get the number of outputs from OrtKernelInfo.
OrtStatus * ShapeInferContext_GetInputCount(const OrtShapeInferContext *context, size_t *out)
OrtStatus * ModelMetadataGetGraphName(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
Get graph name from an OrtModelMetadata.
OrtStatus * CreateROCMProviderOptions(OrtROCMProviderOptions **out)
Create an OrtROCMProviderOptions.
OrtStatus * ModelMetadataLookupCustomMetadataMap(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, const char *key, char **value)
Return data for a key in the custom metadata map in an OrtModelMetadata.
OrtStatus * RunOptionsSetRunLogSeverityLevel(OrtRunOptions *options, int log_severity_level)
Set per-run log severity level.
OrtStatus * GetCUDAProviderOptionsByName(const OrtCUDAProviderOptionsV2 *cuda_options, const char *key, void **ptr)
OrtStatus * SetSessionExecutionMode(OrtSessionOptions *options, ExecutionMode execution_mode)
Set execution mode.
OrtStatus * SessionGetInputName(const OrtSession *session, size_t index, OrtAllocator *allocator, char **value)
Get input name.
OrtStatus * GetDnnlProviderOptionsAsString(const OrtDnnlProviderOptions *dnnl_options, OrtAllocator *allocator, char **ptr)
OrtStatus * CreateRunOptions(OrtRunOptions **out)
Create an OrtRunOptions.
OrtStatus * RunOptionsGetRunTag(const OrtRunOptions *options, const char **run_tag)
Get per-run tag.
OrtStatus * CreateCustomOpDomain(const char *domain, OrtCustomOpDomain **out)
Create a custom op domain.
OrtStatus * ModelMetadataGetCustomMetadataMapKeys(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char ***keys, int64_t *num_keys)
const char *(* GetErrorMessage)(const OrtStatus *status) __attribute__((nonnull))
Get error string from OrtStatus.
Definition onnxruntime_c_api.h:743
OrtStatus * IsTensor(const OrtValue *value, int *out)
Return if an OrtValue is a tensor type.
OrtStatus * AllocatorFree(OrtAllocator *ort_allocator, void *p)
Calls OrtAllocator::Free function.
OrtStatus * GetMapValueType(const OrtMapTypeInfo *map_type_info, OrtTypeInfo **type_info)
Get the value type from an OrtMapTypeInfo.
OrtStatus * CreateSessionFromArray(const OrtEnv *env, const void *model_data, size_t model_data_length, const OrtSessionOptions *options, OrtSession **out)
Create an OrtSession from memory.
OrtStatus * CreateArenaCfgV2(const char *const *arena_config_keys, const size_t *arena_config_values, size_t num_keys, OrtArenaCfg **out)
Create an OrtArenaCfg.
OrtStatus * GetAllocatorWithDefaultOptions(OrtAllocator **out)
Get the default allocator.
OrtStatus * CreateSession(const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtSession **out)
Create an OrtSession from a model file.
OrtStatus * SessionOptionsAppendExecutionProvider_Dnnl(OrtSessionOptions *options, const OrtDnnlProviderOptions *dnnl_options)
Append dnnl provider to session options.
OrtStatus * CreateArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk, OrtArenaCfg **out)
OrtStatus * SessionGetInputCount(const OrtSession *session, size_t *out)
Get input count for a session.
OrtStatus * GetValue(const OrtValue *value, int index, OrtAllocator *allocator, OrtValue **out)
Get non tensor data from an OrtValue.
OrtStatus * ShapeInferContext_GetAttribute(const OrtShapeInferContext *context, const char *attr_name, const OrtOpAttr **attr)
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.
OrtStatus * EnableProfiling(OrtSessionOptions *options, const char *profile_file_prefix)
Enable profiling for a session.
OrtStatus * SetUserLoggingFunction(OrtSessionOptions *options, OrtLoggingFunction user_logging_function, void *user_logging_param)
Set user logging function.
OrtStatus * GetStringTensorElement(const OrtValue *value, size_t s_len, size_t index, void *s)
Get a single string from a string tensor.
OrtStatus * GetTensorTypeAndShape(const OrtValue *value, OrtTensorTypeAndShapeInfo **out)
Get type and shape information from a tensor OrtValue.
OrtStatus * BindInput(OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr)
Bind an OrtValue to an OrtIoBinding input.
OrtStatus * GetResizedStringTensorElementBuffer(OrtValue *value, size_t index, size_t length_in_bytes, char **buffer)
Set a single string in a string tensor Do not zero terminate the string data.
OrtStatus * DisableCpuMemArena(OrtSessionOptions *options)
Disable the memory arena on CPU.
void(* ClearBoundOutputs)(OrtIoBinding *binding_ptr) __attribute__((nonnull))
Clears any previously set Outputs for an OrtIoBinding.
Definition onnxruntime_c_api.h:2394
OrtStatus * SetSymbolicDimensions(OrtTensorTypeAndShapeInfo *info, const char *dim_params[], size_t dim_params_length)
OrtStatus * SessionOptionsAppendExecutionProvider_CANN(OrtSessionOptions *options, const OrtCANNProviderOptions *cann_options)
Append CANN provider to session options.
OrtStatus * MemoryInfoGetMemType(const OrtMemoryInfo *ptr, OrtMemType *out)
Get the OrtMemType from OrtMemoryInfo.
OrtStatus * AllocatorGetInfo(const OrtAllocator *ort_allocator, const struct OrtMemoryInfo **out)
Calls OrtAllocator::Info function.
OrtStatus * CompareMemoryInfo(const OrtMemoryInfo *info1, const OrtMemoryInfo *info2, int *out)
Compare OrtMemoryInfo objects for equality.
OrtStatus * GetAvailableProviders(char ***out_ptr, int *provider_length)
Get the names of all available providers.
OrtStatus * SynchronizeBoundInputs(OrtIoBinding *binding_ptr)
Synchronize bound inputs. The call may be necessary for some providers, such as cuda,...
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.
OrtStatus * AllocatorAlloc(OrtAllocator *ort_allocator, size_t size, void **out)
Calls OrtAllocator::Alloc function.
OrtStatus * RunAsync(OrtSession *session, const OrtRunOptions *run_options, const char *const *input_names, const OrtValue *const *input, size_t input_len, const char *const *output_names, size_t output_names_len, OrtValue **output, RunAsyncCallbackFn run_async_callback, void *user_data)
Run the model asynchronously in a thread owned by intra op thread pool.
OrtStatus * GetTensorRTProviderOptionsByName(const OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *key, void **ptr)
OrtStatus * RegisterCustomOpsLibrary_V2(OrtSessionOptions *options, const char *library_name)
Register custom ops from a shared library.
OrtStatus * SessionGetOverridableInitializerName(const OrtSession *session, size_t index, OrtAllocator *allocator, char **value)
Get overridable initializer name.
OrtStatus * GetROCMProviderOptionsAsString(const OrtROCMProviderOptions *rocm_options, OrtAllocator *allocator, char **ptr)
OrtStatus * UnregisterAllocator(OrtEnv *env, const OrtMemoryInfo *mem_info)
Unregister a custom allocator.
OrtStatus * DisableMemPattern(OrtSessionOptions *options)
Disable the memory pattern optimization.
OrtStatus * UseBlockSparseIndices(OrtValue *ort_value, const int64_t *indices_shape, size_t indices_shape_len, int32_t *indices_data)
OrtStatus *(* CreateStatus)(OrtErrorCode code, const char *msg) __attribute__((nonnull))
Create an OrtStatus from a null terminated string.
Definition onnxruntime_c_api.h:729
OrtStatus * RunWithBinding(OrtSession *session, const OrtRunOptions *run_options, const OrtIoBinding *binding_ptr)
Run a model using Io Bindings for the inputs & outputs.
OrtStatus * CreateDnnlProviderOptions(OrtDnnlProviderOptions **out)
Create an OrtDnnlProviderOptions.
OrtStatus * GetMapKeyType(const OrtMapTypeInfo *map_type_info, enum ONNXTensorElementDataType *out)
Get key type from an OrtMapTypeInfo.
OrtStatus * RunOptionsGetRunLogSeverityLevel(const OrtRunOptions *options, int *log_severity_level)
Get per-run log severity level.
OrtStatus * CastTypeInfoToOptionalTypeInfo(const OrtTypeInfo *type_info, const OrtOptionalTypeInfo **out)
Get Optional Type information from an OrtTypeInfo.
OrtStatus * SessionGetModelMetadata(const OrtSession *session, OrtModelMetadata **out)
Get OrtModelMetadata from an OrtSession.
OrtStatus * GetCurrentGpuDeviceId(int *device_id)
Get current GPU device ID.
OrtStatus * SessionGetOutputTypeInfo(const OrtSession *session, size_t index, OrtTypeInfo **type_info)
Get output type information.
OrtStatus * EnableOrtCustomOps(OrtSessionOptions *options)
Enable custom operators.
OrtStatus * UpdateEnvWithCustomLogLevel(OrtEnv *ort_env, OrtLoggingLevel log_severity_level)
OrtStatus * CreateValue(const OrtValue *const *in, size_t num_values, enum ONNXType value_type, OrtValue **out)
Create a map or sequence OrtValue.
OrtStatus * RegisterCustomOpsUsingFunction(OrtSessionOptions *options, const char *registration_func_name)
Register custom ops by calling a RegisterCustomOpsFn function.
OrtStatus * RunOptionsSetTerminate(OrtRunOptions *options)
Set terminate flag.
OrtStatus * SetSessionLogVerbosityLevel(OrtSessionOptions *options, int session_log_verbosity_level)
Set session log verbosity level.
OrtStatus * SetSessionLogSeverityLevel(OrtSessionOptions *options, int session_log_severity_level)
Set session log severity level.
OrtStatus * CreateThreadingOptions(OrtThreadingOptions **out)
Create an OrtThreadingOptions.
OrtStatus * UseCsrIndices(OrtValue *ort_value, int64_t *inner_data, size_t inner_num, int64_t *outer_data, size_t outer_num)
OrtStatus * SessionGetOverridableInitializerCount(const OrtSession *session, size_t *out)
Get overridable initializer count.
OrtStatus * KernelContext_GetResource(const OrtKernelContext *context, int resouce_version, int resource_id, void **resource)
OrtStatus * CreateSessionWithPrepackedWeightsContainer(const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtPrepackedWeightsContainer *prepacked_weights_container, OrtSession **out)
Create session with prepacked weights container.
OrtStatus * KernelInfo_GetLogger(const OrtKernelInfo *info, const OrtLogger **logger)
Get the session logger from OrtKernelInfo.
OrtStatus * UpdateTensorRTProviderOptions(OrtTensorRTProviderOptionsV2 *tensorrt_options, const char *const *provider_options_keys, const char *const *provider_options_values, size_t num_keys)
Set options in a TensorRT Execution Provider.
OrtStatus * KernelInfoGetAttribute_tensor(const OrtKernelInfo *info, const char *name, OrtAllocator *allocator, OrtValue **out)
Get a OrtValue tensor stored as an attribute in the graph node.
OrtStatus * EnableMemPattern(OrtSessionOptions *options)
Enable the memory pattern optimization.
OrtStatus * SetOptimizedModelFilePath(OrtSessionOptions *options, const char *optimized_model_filepath)
Set filepath to save optimized model after graph level transformations.
OrtStatus * CreateAllocator(const OrtSession *session, const OrtMemoryInfo *mem_info, OrtAllocator **out)
Create an allocator for an OrtSession following an OrtMemoryInfo.
OrtStatus * SynchronizeBoundOutputs(OrtIoBinding *binding_ptr)
Synchronize bound outputs. The call may be necessary for some providers, such as cuda,...
OrtStatus * SessionGetOutputCount(const OrtSession *session, size_t *out)
Get output count for a session.
OrtStatus * CastTypeInfoToSequenceTypeInfo(const OrtTypeInfo *type_info, const OrtSequenceTypeInfo **out)
Cast OrtTypeInfo to an OrtSequenceTypeInfo.
OrtStatus * Run(OrtSession *session, const OrtRunOptions *run_options, const char *const *input_names, const OrtValue *const *inputs, size_t input_len, const char *const *output_names, size_t output_names_len, OrtValue **outputs)
Run the model in an OrtSession.
OrtStatus * GetValueType(const OrtValue *value, enum ONNXType *out)
Get ONNXType of an OrtValue.
OrtStatus * ShapeInferContext_GetInputTypeShape(const OrtShapeInferContext *context, size_t index, OrtTensorTypeAndShapeInfo **info)
OrtStatus * KernelInfo_GetNodeName(const OrtKernelInfo *info, char *out, size_t *size)
Get the graph node name from OrtKernelInfo.
OrtStatus * CreateTensorRTProviderOptions(OrtTensorRTProviderOptionsV2 **out)
Create an OrtTensorRTProviderOptionsV2.
OrtStatus * GetDimensions(const OrtTensorTypeAndShapeInfo *info, int64_t *dim_values, size_t dim_values_length)
Get dimensions in OrtTensorTypeAndShapeInfo.
OrtStatus * SessionGetProfilingStartTimeNs(const OrtSession *session, uint64_t *out)
Return the time that profiling was started.
OrtStatus * RunOptionsUnsetTerminate(OrtRunOptions *options)
Clears the terminate flag.
OrtStatus * CreateOpaqueValue(const char *domain_name, const char *type_name, const void *data_container, size_t data_container_size, OrtValue **out)
Create an opaque (custom user defined type) OrtValue.
OrtStatus * GetSparseTensorValuesTypeAndShape(const OrtValue *ort_value, OrtTensorTypeAndShapeInfo **out)
Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor.
void(* ReleaseTensorRTProviderOptions)(OrtTensorRTProviderOptionsV2 *input)
Release an OrtTensorRTProviderOptionsV2.
Definition onnxruntime_c_api.h:2949
OrtStatus * ReleaseAvailableProviders(char **ptr, int providers_length)
Release data from OrtApi::GetAvailableProviders. This API will never fail so you can rely on it in a ...
OrtStatus * RunOptionsSetRunTag(OrtRunOptions *options, const char *run_tag)
Set per-run tag.
OrtStatus * CreateIoBinding(OrtSession *session, OrtIoBinding **out)
Create an OrtIoBinding instance.
OrtStatus * SetGlobalIntraOpNumThreads(OrtThreadingOptions *tp_options, int intra_op_num_threads)
Set global intra-op thread count.
OrtStatus * CreateOpAttr(const char *name, const void *data, int len, OrtOpAttrType type, OrtOpAttr **op_attr)
: Create attribute of onnxruntime operator
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 * ModelMetadataGetVersion(const OrtModelMetadata *model_metadata, int64_t *value)
Get version number from an OrtModelMetadata.
OrtStatus * GetStringTensorContent(const OrtValue *value, void *s, size_t s_len, size_t *offsets, size_t offsets_len)
Get all strings from a string tensor.
OrtStatus * GetBoundOutputNames(const OrtIoBinding *binding_ptr, OrtAllocator *allocator, char **buffer, size_t **lengths, size_t *count)
Get the names of an OrtIoBinding's outputs.
OrtStatus * CreateTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo **out)
Create an OrtTensorTypeAndShapeInfo object.
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 * SessionEndProfiling(OrtSession *session, OrtAllocator *allocator, char **out)
End profiling and return filename of the profile data.
OrtStatus * ModelMetadataGetProducerName(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
Get producer name from an OrtModelMetadata.
OrtStatus * SessionOptionsSetCustomCreateThreadFn(OrtSessionOptions *options, OrtCustomCreateThreadFn ort_custom_create_thread_fn)
Set custom thread creation function.
OrtStatus * SetGlobalCustomCreateThreadFn(OrtThreadingOptions *tp_options, OrtCustomCreateThreadFn ort_custom_create_thread_fn)
Set custom thread creation function for global thread pools.
OrtStatus * SessionOptionsAppendExecutionProvider_CUDA_V2(OrtSessionOptions *options, const OrtCUDAProviderOptionsV2 *cuda_options)
Append CUDA execution provider to the session options.
OrtStatus * CreateTensorAsOrtValue(OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out)
Create a tensor.
void(* ReleaseCUDAProviderOptions)(OrtCUDAProviderOptionsV2 *input)
Release an OrtCUDAProviderOptionsV2.
Definition onnxruntime_c_api.h:3452
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.
OrtErrorCode(* GetErrorCode)(const OrtStatus *status) __attribute__((nonnull))
Get OrtErrorCode from OrtStatus.
Definition onnxruntime_c_api.h:736
OrtStatus * SetTensorElementType(OrtTensorTypeAndShapeInfo *info, enum ONNXTensorElementDataType type)
Set element type in OrtTensorTypeAndShapeInfo.
OrtStatus * BindOutput(OrtIoBinding *binding_ptr, const char *name, const OrtValue *val_ptr)
Bind an OrtValue to an OrtIoBinding output.
OrtStatus * GetSparseTensorValues(const OrtValue *ort_value, const void **out)
Returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*().
CUDA Provider Options.
Definition onnxruntime_c_api.h:400
int tunable_op_max_tuning_duration_ms
Max tuning duration time limit for each instance of TunableOp. Defaults to 0 to disable the limit.
Definition onnxruntime_c_api.h:479
int has_user_compute_stream
Flag indicating if there is a user provided compute stream Defaults to 0.
Definition onnxruntime_c_api.h:453
int do_copy_in_default_stream
Flag indicating if copying needs to take place on the same stream as the compute stream in the CUDA E...
Definition onnxruntime_c_api.h:448
void * user_compute_stream
User provided compute stream. If provided, please set has_user_compute_stream to 1.
Definition onnxruntime_c_api.h:458
int tunable_op_enable
Enable TunableOp for using. Set it to 1/0 to enable/disable TunableOp. Otherwise, it is disabled by d...
Definition onnxruntime_c_api.h:468
size_t gpu_mem_limit
CUDA memory limit (To use all possible memory pass in maximum size_t) Defaults to SIZE_MAX.
Definition onnxruntime_c_api.h:431
int arena_extend_strategy
Strategy used to grow the memory arena 0 = kNextPowerOfTwo 1 = kSameAsRequested Defaults to 0.
Definition onnxruntime_c_api.h:439
OrtCUDAProviderOptions()
Definition onnxruntime_c_api.h:402
OrtArenaCfg * default_memory_arena_cfg
CUDA memory arena configuration parameters.
Definition onnxruntime_c_api.h:462
int tunable_op_tuning_enable
Enable TunableOp for tuning. Set it to 1/0 to enable/disable TunableOp tuning. Otherwise,...
Definition onnxruntime_c_api.h:474
OrtCudnnConvAlgoSearch cudnn_conv_algo_search
CUDA Convolution algorithm search configuration. See enum OrtCudnnConvAlgoSearch for more details....
Definition onnxruntime_c_api.h:425
int device_id
CUDA device Id Defaults to 0.
Definition onnxruntime_c_api.h:419
Definition onnxruntime_c_api.h:682
char __place_holder
Definition onnxruntime_c_api.h:683
Definition onnxruntime_c_api.h:4550
int(* GetVariadicInputHomogeneity)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4596
OrtCustomOpInputOutputCharacteristic(* GetOutputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition onnxruntime_c_api.h:4580
size_t(* GetInputTypeCount)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4568
int(* GetVariadicOutputMinArity)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4600
int(* GetStartVersion)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4618
const char *(* GetName)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4561
size_t(* GetOutputTypeCount)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4570
void(* KernelDestroy)(void *op_kernel)
Definition onnxruntime_c_api.h:4576
int(* GetVariadicOutputHomogeneity)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4605
OrtMemType(* GetInputMemoryType)(const struct OrtCustomOp *op, size_t index)
Definition onnxruntime_c_api.h:4587
void *(* CreateKernel)(const struct OrtCustomOp *op, const OrtApi *api, const OrtKernelInfo *info)
Definition onnxruntime_c_api.h:4557
uint32_t version
Definition onnxruntime_c_api.h:4551
ONNXTensorElementDataType(* GetInputType)(const struct OrtCustomOp *op, size_t index)
Definition onnxruntime_c_api.h:4567
OrtCustomOpInputOutputCharacteristic(* GetInputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition onnxruntime_c_api.h:4579
const char *(* GetExecutionProviderType)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4564
ONNXTensorElementDataType(* GetOutputType)(const struct OrtCustomOp *op, size_t index)
Definition onnxruntime_c_api.h:4569
int(* GetVariadicInputMinArity)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4591
OrtStatusPtr(* InferOutputShapeFn)(const struct OrtCustomOp *op, OrtShapeInferContext *)
Definition onnxruntime_c_api.h:4615
int(* GetEndVersion)(const struct OrtCustomOp *op)
Definition onnxruntime_c_api.h:4619
OrtStatusPtr(* CreateKernelV2)(const struct OrtCustomOp *op, const OrtApi *api, const OrtKernelInfo *info, void **kernel)
Definition onnxruntime_c_api.h:4608
OrtStatusPtr(* KernelComputeV2)(void *op_kernel, OrtKernelContext *context)
Definition onnxruntime_c_api.h:4613
void(* KernelCompute)(void *op_kernel, OrtKernelContext *context)
Definition onnxruntime_c_api.h:4575
MIGraphX Provider Options.
Definition onnxruntime_c_api.h:601
int migraphx_int8_enable
Definition onnxruntime_c_api.h:604
int migraphx_fp16_enable
Definition onnxruntime_c_api.h:603
int device_id
Definition onnxruntime_c_api.h:602
int migraphx_use_native_calibration_table
Definition onnxruntime_c_api.h:605
const char * migraphx_int8_calibration_table_name
Definition onnxruntime_c_api.h:606
OpenVINO Provider Options.
Definition onnxruntime_c_api.h:613
unsigned char enable_opencl_throttling
0 = disabled, nonzero = enabled
Definition onnxruntime_c_api.h:634
size_t num_of_threads
0 = Use default number of threads
Definition onnxruntime_c_api.h:631
void * context
Definition onnxruntime_c_api.h:633
const char * cache_dir
Definition onnxruntime_c_api.h:632
const char * device_type
Device type string.
Definition onnxruntime_c_api.h:628
const char * device_id
Definition onnxruntime_c_api.h:630
unsigned char enable_npu_fast_compile
0 = disabled, nonzero = enabled
Definition onnxruntime_c_api.h:629
OrtOpenVINOProviderOptions()
Definition onnxruntime_c_api.h:615
unsigned char enable_dynamic_shapes
0 = disabled, nonzero = enabled
Definition onnxruntime_c_api.h:635
ROCM Provider Options.
Definition onnxruntime_c_api.h:487
int device_id
ROCM device Id Defaults to 0.
Definition onnxruntime_c_api.h:506
int tunable_op_max_tuning_duration_ms
Max tuning duration time limit for each instance of TunableOp. Defaults to 0 to disable the limit.
Definition onnxruntime_c_api.h:565
int do_copy_in_default_stream
Flag indicating if copying needs to take place on the same stream as the compute stream in the ROCM E...
Definition onnxruntime_c_api.h:534
OrtArenaCfg * default_memory_arena_cfg
ROCM memory arena configuration parameters.
Definition onnxruntime_c_api.h:548
size_t gpu_mem_limit
ROCM memory limit (To use all possible memory pass in maximum size_t) Defaults to SIZE_MAX.
Definition onnxruntime_c_api.h:517
OrtROCMProviderOptions()
Definition onnxruntime_c_api.h:489
int tunable_op_enable
Enable TunableOp for using. Set it to 1/0 to enable/disable TunableOp. Otherwise, it is disabled by d...
Definition onnxruntime_c_api.h:554
void * user_compute_stream
User provided compute stream. If provided, please set has_user_compute_stream to 1.
Definition onnxruntime_c_api.h:544
int arena_extend_strategy
Strategy used to grow the memory arena 0 = kNextPowerOfTwo 1 = kSameAsRequested Defaults to 0.
Definition onnxruntime_c_api.h:525
int tunable_op_tuning_enable
Enable TunableOp for tuning. Set it to 1/0 to enable/disable TunableOp tuning. Otherwise,...
Definition onnxruntime_c_api.h:560
int has_user_compute_stream
Flag indicating if there is a user provided compute stream Defaults to 0.
Definition onnxruntime_c_api.h:539
int miopen_conv_exhaustive_search
ROCM MIOpen Convolution algorithm exaustive search option. Defaults to 0 (false).
Definition onnxruntime_c_api.h:511
TensorRT Provider Options.
Definition onnxruntime_c_api.h:573
int trt_engine_cache_enable
Definition onnxruntime_c_api.h:587
void * user_compute_stream
Definition onnxruntime_c_api.h:576
int device_id
CUDA device id (0 = default device)
Definition onnxruntime_c_api.h:574
const char * trt_engine_cache_path
Definition onnxruntime_c_api.h:588
int trt_engine_decryption_enable
Definition onnxruntime_c_api.h:589
int trt_max_partition_iterations
Definition onnxruntime_c_api.h:577
size_t trt_max_workspace_size
Definition onnxruntime_c_api.h:579
int trt_dla_enable
Definition onnxruntime_c_api.h:584
const char * trt_int8_calibration_table_name
Definition onnxruntime_c_api.h:582
int has_user_compute_stream
Definition onnxruntime_c_api.h:575
int trt_dla_core
Definition onnxruntime_c_api.h:585
int trt_int8_use_native_calibration_table
Definition onnxruntime_c_api.h:583
int trt_min_subgraph_size
Definition onnxruntime_c_api.h:578
int trt_force_sequential_engine_build
Definition onnxruntime_c_api.h:591
int trt_dump_subgraphs
Definition onnxruntime_c_api.h:586
int trt_fp16_enable
Definition onnxruntime_c_api.h:580
const char * trt_engine_decryption_lib_path
Definition onnxruntime_c_api.h:590
int trt_int8_enable
Definition onnxruntime_c_api.h:581
The Training C API that holds onnxruntime training function pointers.
Definition onnxruntime_training_c_api.h:122