OnnxRuntime
onnxruntime_c_api.h
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
22#pragma once
23#include <stdlib.h>
24#include <stdint.h>
25#include <string.h>
26
31#define ORT_API_VERSION 9
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
38// SAL2 Definitions
39#ifndef _WIN32
40#define _In_
41#define _In_z_
42#define _In_opt_
43#define _In_opt_z_
44#define _Out_
45#define _Outptr_
46#define _Out_opt_
47#define _Inout_
48#define _Inout_opt_
49#define _Frees_ptr_opt_
50#define _Ret_maybenull_
51#define _Ret_notnull_
52#define _Check_return_
53#define _Outptr_result_maybenull_
54#define _In_reads_(X)
55#define _Inout_updates_all_(X)
56#define _Out_writes_bytes_all_(X)
57#define _Out_writes_all_(X)
58#define _Success_(X)
59#define _Outptr_result_buffer_maybenull_(X)
60#define ORT_ALL_ARGS_NONNULL __attribute__((nonnull))
61#else
62#include <specstrings.h>
63#define ORT_ALL_ARGS_NONNULL
64#endif
65
66#ifdef _WIN32
67// Define ORT_DLL_IMPORT if your program is dynamically linked to Ort.
68// dllexport is not used, we use a .def file.
69#ifdef ORT_DLL_IMPORT
70#define ORT_EXPORT __declspec(dllimport)
71#else
72#define ORT_EXPORT
73#endif
74#define ORT_API_CALL _stdcall
75#define ORT_MUST_USE_RESULT
76#define ORTCHAR_T wchar_t
77#else
78// To make symbols visible on macOS/iOS
79#ifdef __APPLE__
80#define ORT_EXPORT __attribute__((visibility("default")))
81#else
82#define ORT_EXPORT
83#endif
84#define ORT_API_CALL
85#define ORT_MUST_USE_RESULT __attribute__((warn_unused_result))
86#define ORTCHAR_T char
87#endif
88
89#ifndef ORT_TSTR
90#ifdef _WIN32
91#define ORT_TSTR(X) L##X
92#else
93#define ORT_TSTR(X) X
94#endif
95#endif
96
97// Any pointer marked with _In_ or _Out_, cannot be NULL.
98
99// Windows users should use unicode paths when possible to bypass the MAX_PATH limitation
100// Every pointer marked with _In_ or _Out_, cannot be NULL. Caller should ensure that.
101// for ReleaseXXX(...) functions, they can accept NULL pointer.
102
103#ifdef __cplusplus
104// For any compiler with C++11 support, MSVC 2015 and greater, or Clang version supporting noexcept.
105// Such complex condition is needed because compilers set __cplusplus value differently.
106#ifndef __has_feature
107#define __has_feature(x) 0
108#endif
109#if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || (defined(__has_feature) && __has_feature(cxx_noexcept)))
110#define NO_EXCEPTION noexcept
111#else
112#define NO_EXCEPTION throw()
113#endif
114#else
115#define NO_EXCEPTION
116#endif
117
118// __VA_ARGS__ on Windows and Linux are different
119#define ORT_API(RETURN_TYPE, NAME, ...) RETURN_TYPE ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION
120
121#define ORT_API_STATUS(NAME, ...) \
122 _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT
123
124// XXX: Unfortunately, SAL annotations are known to not work with function pointers
125#define ORT_API2_STATUS(NAME, ...) \
126 _Check_return_ _Ret_maybenull_ OrtStatusPtr(ORT_API_CALL* NAME)(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT
127
128// Used in *.cc files. Almost as same as ORT_API_STATUS, except without ORT_MUST_USE_RESULT and ORT_EXPORT
129#define ORT_API_STATUS_IMPL(NAME, ...) \
130 _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION
131
132#define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
133
134#ifdef __DOXYGEN__
135#undef ORT_API_STATUS
136#define ORT_API_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
137#undef ORT_API2_STATUS
138#define ORT_API2_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
139#undef ORT_CLASS_RELEASE
140#define ORT_CLASS_RELEASE(X) void Release##X(Ort##X* input)
141#undef NO_EXCEPTION
142#define NO_EXCEPTION
143#endif
154 ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, // maps to c type float
155 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8, // maps to c type uint8_t
156 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8, // maps to c type int8_t
157 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16, // maps to c type uint16_t
158 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16, // maps to c type int16_t
159 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32, // maps to c type int32_t
160 ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64, // maps to c type int64_t
161 ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING, // maps to c++ type std::string
164 ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE, // maps to c type double
165 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32, // maps to c type uint32_t
166 ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64, // maps to c type uint64_t
167 ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64, // complex with float32 real and imaginary components
168 ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128, // complex with float64 real and imaginary components
169 ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16 // Non-IEEE floating-point format based on IEEE754 single-precision
171
172// Synced with onnx TypeProto oneof
173typedef enum ONNXType {
180} ONNXType;
181
182// These types are synced with internal
183// SparseFormatFlags
184typedef enum OrtSparseFormat {
190
191// Enum allows to query sparse tensor indices
198
203typedef enum OrtLoggingLevel {
210
211typedef enum OrtErrorCode {
225
227#define ORT_RUNTIME_CLASS(X) \
228 struct Ort##X; \
229 typedef struct Ort##X Ort##X;
230
235// The actual types defined have an Ort prefix
236ORT_RUNTIME_CLASS(Env);
237ORT_RUNTIME_CLASS(Status); // nullptr for Status* indicates success
238ORT_RUNTIME_CLASS(MemoryInfo);
239ORT_RUNTIME_CLASS(IoBinding);
240ORT_RUNTIME_CLASS(Session); //Don't call ReleaseSession from Dllmain (because session owns a thread pool)
241ORT_RUNTIME_CLASS(Value);
242ORT_RUNTIME_CLASS(RunOptions);
243ORT_RUNTIME_CLASS(TypeInfo);
244ORT_RUNTIME_CLASS(TensorTypeAndShapeInfo);
245ORT_RUNTIME_CLASS(SessionOptions);
246ORT_RUNTIME_CLASS(CustomOpDomain);
247ORT_RUNTIME_CLASS(MapTypeInfo);
248ORT_RUNTIME_CLASS(SequenceTypeInfo);
249ORT_RUNTIME_CLASS(ModelMetadata);
250ORT_RUNTIME_CLASS(ThreadPoolParams);
251ORT_RUNTIME_CLASS(ThreadingOptions);
252ORT_RUNTIME_CLASS(ArenaCfg);
253ORT_RUNTIME_CLASS(PrepackedWeightsContainer);
254ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2);
255
256#ifdef _WIN32
257typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr;
258#else
260#endif
261
268typedef struct OrtAllocator {
269 uint32_t version;
270 void*(ORT_API_CALL* Alloc)(struct OrtAllocator* this_, size_t size);
271 void(ORT_API_CALL* Free)(struct OrtAllocator* this_, void* p);
272 const struct OrtMemoryInfo*(ORT_API_CALL* Info)(const struct OrtAllocator* this_);
274
275typedef void(ORT_API_CALL* OrtLoggingFunction)(
276 void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location,
277 const char* message);
278
288 ORT_ENABLE_ALL = 99
290
291typedef enum ExecutionMode {
295
308
309struct OrtKernelInfo;
311struct OrtKernelContext;
313struct OrtCustomOp;
314typedef struct OrtCustomOp OrtCustomOp;
315
316typedef enum OrtAllocatorType {
321
324// Whenever this struct is updated, please also update the MakeKey function in onnxruntime / core / framework / execution_provider.cc
325typedef enum OrtMemType {
330} OrtMemType;
331
335 EXHAUSTIVE, // expensive exhaustive benchmarking using cudnnFindConvolutionForwardAlgorithmEx
336 HEURISTIC, // lightweight heuristic based search using cudnnGetConvolutionForwardAlgorithm_v7
337 DEFAULT, // default algorithm using CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM
339
347
353
366
373 int miopen_conv_exhaustive_search; // miopen conv algo exhaustive search option
374 size_t gpu_mem_limit; // default hip memory limitation to maximum finite value of size_t.
375 int arena_extend_strategy; // default area extend strategy to KNextPowerOfTwo.
377
384 int has_user_compute_stream; // indicator of user specified CUDA compute stream.
385 void* user_compute_stream; // user specified CUDA compute stream.
386 int trt_max_partition_iterations; // maximum iterations for TensorRT parser to get capability
387 int trt_min_subgraph_size; // minimum size of TensorRT subgraphs
388 size_t trt_max_workspace_size; // maximum workspace size for TensorRT.
389 int trt_fp16_enable; // enable TensorRT FP16 precision. Default 0 = false, nonzero = true
390 int trt_int8_enable; // enable TensorRT INT8 precision. Default 0 = false, nonzero = true
391 const char* trt_int8_calibration_table_name; // TensorRT INT8 calibration table name.
392 int trt_int8_use_native_calibration_table; // use native TensorRT generated calibration table. Default 0 = false, nonzero = true
393 int trt_dla_enable; // enable DLA. Default 0 = false, nonzero = true
394 int trt_dla_core; // DLA core number. Default 0
395 int trt_dump_subgraphs; // dump TRT subgraph. Default 0 = false, nonzero = true
396 int trt_engine_cache_enable; // enable engine caching. Default 0 = false, nonzero = true
397 const char* trt_engine_cache_path; // specify engine cache path
398 int trt_engine_decryption_enable; // enable engine decryption. Default 0 = false, nonzero = true
399 const char* trt_engine_decryption_lib_path; // specify engine decryption library path
400 int trt_force_sequential_engine_build; // force building TensorRT engine sequentially. Default 0 = false, nonzero = true
402
408#ifdef __cplusplus
410#endif
415 const char* device_type;
417 const char* device_id;
419 unsigned char use_compiled_network;
420 const char* blob_dump_path; // path is set to empty by default
422
423struct OrtApi;
424typedef struct OrtApi OrtApi;
425
437 const OrtApi*(ORT_API_CALL* GetApi)(uint32_t version)NO_EXCEPTION;
438 const char*(ORT_API_CALL* GetVersionString)(void)NO_EXCEPTION;
439};
440typedef struct OrtApiBase OrtApiBase;
441
446ORT_EXPORT const OrtApiBase* ORT_API_CALL OrtGetApiBase(void) NO_EXCEPTION;
447
455struct OrtApi {
458
466 OrtStatus*(ORT_API_CALL* CreateStatus)(OrtErrorCode code, _In_ const char* msg)NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
467
473 OrtErrorCode(ORT_API_CALL* GetErrorCode)(_In_ const OrtStatus* status) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
474
480 const char*(ORT_API_CALL* GetErrorMessage)(_In_ const OrtStatus* status)NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
481
485
494 ORT_API2_STATUS(CreateEnv, OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out);
495
507 ORT_API2_STATUS(CreateEnvWithCustomLogger, OrtLoggingFunction logging_function, _In_opt_ void* logger_param,
508 OrtLoggingLevel log_severity_level, _In_ const char* logid, _Outptr_ OrtEnv** out);
509
517 ORT_API2_STATUS(EnableTelemetryEvents, _In_ const OrtEnv* env);
525 ORT_API2_STATUS(DisableTelemetryEvents, _In_ const OrtEnv* env);
526
530
540 // TODO: document the path separator convention? '/' vs '\'
541 // TODO: should specify the access characteristics of model_path. Is this read only during the
542 // execution of CreateSession, or does the OrtSession retain a handle to the file/directory
543 // and continue to access throughout the OrtSession lifetime?
544 // What sort of access is needed to model_path : read or read/write?
545 ORT_API2_STATUS(CreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
546 _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
547
558 ORT_API2_STATUS(CreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length,
559 _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out);
560
579 ORT_API2_STATUS(Run, _Inout_ OrtSession* session, _In_opt_ const OrtRunOptions* run_options,
580 _In_reads_(input_len) const char* const* input_names,
581 _In_reads_(input_len) const OrtValue* const* inputs, size_t input_len,
582 _In_reads_(output_names_len) const char* const* output_names, size_t output_names_len,
583 _Inout_updates_all_(output_names_len) OrtValue** outputs);
584
588
604 ORT_API2_STATUS(CreateSessionOptions, _Outptr_ OrtSessionOptions** options);
605
613 ORT_API2_STATUS(SetOptimizedModelFilePath, _Inout_ OrtSessionOptions* options,
614 _In_ const ORTCHAR_T* optimized_model_filepath);
615
623 ORT_API2_STATUS(CloneSessionOptions, _In_ const OrtSessionOptions* in_options,
624 _Outptr_ OrtSessionOptions** out_options);
625
637 ORT_API2_STATUS(SetSessionExecutionMode, _Inout_ OrtSessionOptions* options, ExecutionMode execution_mode);
638
646 ORT_API2_STATUS(EnableProfiling, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix);
647
654 ORT_API2_STATUS(DisableProfiling, _Inout_ OrtSessionOptions* options);
655
669 ORT_API2_STATUS(EnableMemPattern, _Inout_ OrtSessionOptions* options);
670
679 ORT_API2_STATUS(DisableMemPattern, _Inout_ OrtSessionOptions* options);
680
689 ORT_API2_STATUS(EnableCpuMemArena, _Inout_ OrtSessionOptions* options);
690
697 ORT_API2_STATUS(DisableCpuMemArena, _Inout_ OrtSessionOptions* options);
698
706 ORT_API2_STATUS(SetSessionLogId, _Inout_ OrtSessionOptions* options, const char* logid);
707
717 ORT_API2_STATUS(SetSessionLogVerbosityLevel, _Inout_ OrtSessionOptions* options, int session_log_verbosity_level);
718
726 ORT_API2_STATUS(SetSessionLogSeverityLevel, _Inout_ OrtSessionOptions* options, int session_log_severity_level);
727
736 ORT_API2_STATUS(SetSessionGraphOptimizationLevel, _Inout_ OrtSessionOptions* options,
737 GraphOptimizationLevel graph_optimization_level);
738
752 ORT_API2_STATUS(SetIntraOpNumThreads, _Inout_ OrtSessionOptions* options, int intra_op_num_threads);
753
766 ORT_API2_STATUS(SetInterOpNumThreads, _Inout_ OrtSessionOptions* options, int inter_op_num_threads);
767
771
779 ORT_API2_STATUS(CreateCustomOpDomain, _In_ const char* domain, _Outptr_ OrtCustomOpDomain** out);
780
790 ORT_API2_STATUS(CustomOpDomain_Add, _Inout_ OrtCustomOpDomain* custom_op_domain, _In_ const OrtCustomOp* op);
791
795
805 ORT_API2_STATUS(AddCustomOpDomain, _Inout_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain);
806
821 ORT_API2_STATUS(RegisterCustomOpsLibrary, _Inout_ OrtSessionOptions* options, _In_ const char* library_path, void** library_handle);
822
826
838 ORT_API2_STATUS(SessionGetInputCount, _In_ const OrtSession* session, _Out_ size_t* out);
839
851 ORT_API2_STATUS(SessionGetOutputCount, _In_ const OrtSession* session, _Out_ size_t* out);
852
862 ORT_API2_STATUS(SessionGetOverridableInitializerCount, _In_ const OrtSession* session, _Out_ size_t* out);
863
872 ORT_API2_STATUS(SessionGetInputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
873
882 ORT_API2_STATUS(SessionGetOutputTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
883
892 ORT_API2_STATUS(SessionGetOverridableInitializerTypeInfo, _In_ const OrtSession* session, size_t index, _Outptr_ OrtTypeInfo** type_info);
893
903 ORT_API2_STATUS(SessionGetInputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
904
914 ORT_API2_STATUS(SessionGetOutputName, _In_ const OrtSession* session, size_t index, _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
915
925 ORT_API2_STATUS(SessionGetOverridableInitializerName, _In_ const OrtSession* session, size_t index,
926 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
927
931
938 ORT_API2_STATUS(CreateRunOptions, _Outptr_ OrtRunOptions** out);
939
949 ORT_API2_STATUS(RunOptionsSetRunLogVerbosityLevel, _Inout_ OrtRunOptions* options, int log_verbosity_level);
950
958 ORT_API2_STATUS(RunOptionsSetRunLogSeverityLevel, _Inout_ OrtRunOptions* options, int log_severity_level);
959
969 ORT_API2_STATUS(RunOptionsSetRunTag, _Inout_ OrtRunOptions* options, _In_ const char* run_tag);
970
980 ORT_API2_STATUS(RunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* options,
981 _Out_ int* log_verbosity_level);
982
990 ORT_API2_STATUS(RunOptionsGetRunLogSeverityLevel, _In_ const OrtRunOptions* options, _Out_ int* log_severity_level);
991
1003 ORT_API2_STATUS(RunOptionsGetRunTag, _In_ const OrtRunOptions* options, _Out_ const char** run_tag);
1004
1013 ORT_API2_STATUS(RunOptionsSetTerminate, _Inout_ OrtRunOptions* options);
1014
1023 ORT_API2_STATUS(RunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options);
1024
1028
1041 ORT_API2_STATUS(CreateTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* shape, size_t shape_len,
1043
1059 ORT_API2_STATUS(CreateTensorWithDataAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
1060 size_t p_data_len, _In_ const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type,
1061 _Outptr_ OrtValue** out);
1062
1070 ORT_API2_STATUS(IsTensor, _In_ const OrtValue* value, _Out_ int* out);
1071
1082 ORT_API2_STATUS(GetTensorMutableData, _In_ OrtValue* value, _Outptr_ void** out);
1083
1092 ORT_API2_STATUS(FillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len);
1093
1103 ORT_API2_STATUS(GetStringTensorDataLength, _In_ const OrtValue* value, _Out_ size_t* len);
1104
1124 ORT_API2_STATUS(GetStringTensorContent, _In_ const OrtValue* value, _Out_writes_bytes_all_(s_len) void* s,
1125 size_t s_len, _Out_writes_all_(offsets_len) size_t* offsets, size_t offsets_len);
1126
1130
1138 ORT_API2_STATUS(CastTypeInfoToTensorInfo, _In_ const OrtTypeInfo* type_info,
1139 _Outptr_result_maybenull_ const OrtTensorTypeAndShapeInfo** out);
1140
1148 ORT_API2_STATUS(GetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ enum ONNXType* out);
1149
1153
1161
1170
1179 ORT_API2_STATUS(SetDimensions, OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count);
1180
1190 ORT_API2_STATUS(GetTensorElementType, _In_ const OrtTensorTypeAndShapeInfo* info,
1192
1202 ORT_API2_STATUS(GetDimensionsCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out);
1203
1212 ORT_API2_STATUS(GetDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values,
1213 size_t dim_values_length);
1214
1223 ORT_API2_STATUS(GetSymbolicDimensions, _In_ const OrtTensorTypeAndShapeInfo* info,
1224 _Out_writes_all_(dim_params_length) const char* dim_params[], size_t dim_params_length);
1225
1242 ORT_API2_STATUS(GetTensorShapeElementCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out);
1243
1247
1255 ORT_API2_STATUS(GetTensorTypeAndShape, _In_ const OrtValue* value, _Outptr_ OrtTensorTypeAndShapeInfo** out);
1256
1264 ORT_API2_STATUS(GetTypeInfo, _In_ const OrtValue* value, _Outptr_result_maybenull_ OrtTypeInfo** out);
1265
1273 ORT_API2_STATUS(GetValueType, _In_ const OrtValue* value, _Out_ enum ONNXType* out);
1274
1278
1289 ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name, enum OrtAllocatorType type, int id,
1290 enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out);
1291
1302 ORT_API2_STATUS(CreateCpuMemoryInfo, enum OrtAllocatorType type, enum OrtMemType mem_type,
1303 _Outptr_ OrtMemoryInfo** out);
1304
1315 ORT_API2_STATUS(CompareMemoryInfo, _In_ const OrtMemoryInfo* info1, _In_ const OrtMemoryInfo* info2, _Out_ int* out);
1316
1324 ORT_API2_STATUS(MemoryInfoGetName, _In_ const OrtMemoryInfo* ptr, _Out_ const char** out);
1325
1328 ORT_API2_STATUS(MemoryInfoGetId, _In_ const OrtMemoryInfo* ptr, _Out_ int* out);
1329
1332 ORT_API2_STATUS(MemoryInfoGetMemType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtMemType* out);
1333
1336 ORT_API2_STATUS(MemoryInfoGetType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtAllocatorType* out);
1337
1341
1343 ORT_API2_STATUS(AllocatorAlloc, _Inout_ OrtAllocator* ort_allocator, size_t size, _Outptr_ void** out);
1345 ORT_API2_STATUS(AllocatorFree, _Inout_ OrtAllocator* ort_allocator, void* p);
1347 ORT_API2_STATUS(AllocatorGetInfo, _In_ const OrtAllocator* ort_allocator, _Outptr_ const struct OrtMemoryInfo** out);
1348
1357 ORT_API2_STATUS(GetAllocatorWithDefaultOptions, _Outptr_ OrtAllocator** out);
1358
1362
1374 ORT_API2_STATUS(AddFreeDimensionOverride, _Inout_ OrtSessionOptions* options, _In_ const char* dim_denotation,
1375 _In_ int64_t dim_value);
1376
1380
1381 /* Internal information (not seen in Doxygen)
1382 *
1383 * APIs to support non-tensor types - map and sequence.
1384 * Currently only the following types are supported
1385 * Note: the following types should be kept in sync with data_types.h
1386 * Map types
1387 * =========
1388 * std::map<std::string, std::string>
1389 * std::map<std::string, int64_t>
1390 * std::map<std::string, float>
1391 * std::map<std::string, double>
1392 * std::map<int64_t, std::string>
1393 * std::map<int64_t, int64_t>
1394 * std::map<int64_t, float>
1395 * std::map<int64_t, double>
1396 *
1397 * Sequence types
1398 * ==============
1399 * std::vector<std::string>
1400 * std::vector<int64_t>
1401 * std::vector<float>
1402 * std::vector<double>
1403 * std::vector<std::map<std::string, float>>
1404 * std::vector<std::map<int64_t, float>
1405 */
1406
1421 ORT_API2_STATUS(GetValue, _In_ const OrtValue* value, int index, _Inout_ OrtAllocator* allocator,
1422 _Outptr_ OrtValue** out);
1423
1434 ORT_API2_STATUS(GetValueCount, _In_ const OrtValue* value, _Out_ size_t* out);
1435
1451 ORT_API2_STATUS(CreateValue, _In_reads_(num_values) const OrtValue* const* in, size_t num_values,
1452 enum ONNXType value_type, _Outptr_ OrtValue** out);
1453
1476 ORT_API2_STATUS(CreateOpaqueValue, _In_z_ const char* domain_name, _In_z_ const char* type_name,
1477 _In_ const void* data_container, size_t data_container_size, _Outptr_ OrtValue** out);
1478
1493 ORT_API2_STATUS(GetOpaqueValue, _In_ const char* domain_name, _In_ const char* type_name, _In_ const OrtValue* in,
1494 _Out_ void* data_container, size_t data_container_size);
1495
1499
1508 ORT_API2_STATUS(KernelInfoGetAttribute_float, _In_ const OrtKernelInfo* info, _In_ const char* name,
1509 _Out_ float* out);
1510
1519 ORT_API2_STATUS(KernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* info, _In_ const char* name,
1520 _Out_ int64_t* out);
1521
1542 ORT_API2_STATUS(KernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out,
1543 _Inout_ size_t* size);
1544
1548
1553 ORT_API2_STATUS(KernelContext_GetInputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out);
1554
1559 ORT_API2_STATUS(KernelContext_GetOutputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out);
1560
1565 ORT_API2_STATUS(KernelContext_GetInput, _In_ const OrtKernelContext* context, _In_ size_t index,
1566 _Out_ const OrtValue** out);
1567
1572 ORT_API2_STATUS(KernelContext_GetOutput, _Inout_ OrtKernelContext* context, _In_ size_t index,
1573 _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out);
1574
1578 ORT_CLASS_RELEASE(Env);
1582 ORT_CLASS_RELEASE(Status);
1586 ORT_CLASS_RELEASE(MemoryInfo);
1590 ORT_CLASS_RELEASE(Session); //Don't call ReleaseSession from Dllmain (because session owns a thread pool)
1594 ORT_CLASS_RELEASE(Value);
1598 ORT_CLASS_RELEASE(RunOptions);
1602 ORT_CLASS_RELEASE(TypeInfo);
1606 ORT_CLASS_RELEASE(TensorTypeAndShapeInfo);
1610 ORT_CLASS_RELEASE(SessionOptions);
1614 ORT_CLASS_RELEASE(CustomOpDomain);
1615
1619
1632 ORT_API2_STATUS(GetDenotationFromTypeInfo, _In_ const OrtTypeInfo* type_info, _Out_ const char** const denotation,
1633 _Out_ size_t* len);
1634
1647 ORT_API2_STATUS(CastTypeInfoToMapTypeInfo, _In_ const OrtTypeInfo* type_info,
1648 _Outptr_result_maybenull_ const OrtMapTypeInfo** out);
1649
1662 ORT_API2_STATUS(CastTypeInfoToSequenceTypeInfo, _In_ const OrtTypeInfo* type_info,
1663 _Outptr_result_maybenull_ const OrtSequenceTypeInfo** out);
1664
1668
1680 ORT_API2_STATUS(GetMapKeyType, _In_ const OrtMapTypeInfo* map_type_info, _Out_ enum ONNXTensorElementDataType* out);
1681
1689 ORT_API2_STATUS(GetMapValueType, _In_ const OrtMapTypeInfo* map_type_info, _Outptr_ OrtTypeInfo** type_info);
1690
1694
1704 ORT_API2_STATUS(GetSequenceElementType, _In_ const OrtSequenceTypeInfo* sequence_type_info,
1705 _Outptr_ OrtTypeInfo** type_info);
1706
1710 ORT_CLASS_RELEASE(MapTypeInfo);
1714 ORT_CLASS_RELEASE(SequenceTypeInfo);
1715
1719
1730 ORT_API2_STATUS(SessionEndProfiling, _In_ OrtSession* session, _Inout_ OrtAllocator* allocator, _Outptr_ char** out);
1731
1739 ORT_API2_STATUS(SessionGetModelMetadata, _In_ const OrtSession* session, _Outptr_ OrtModelMetadata** out);
1740
1744
1753 ORT_API2_STATUS(ModelMetadataGetProducerName, _In_ const OrtModelMetadata* model_metadata,
1754 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1755
1764 ORT_API2_STATUS(ModelMetadataGetGraphName, _In_ const OrtModelMetadata* model_metadata,
1765 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1766
1775 ORT_API2_STATUS(ModelMetadataGetDomain, _In_ const OrtModelMetadata* model_metadata, _Inout_ OrtAllocator* allocator,
1776 _Outptr_ char** value);
1777
1786 ORT_API2_STATUS(ModelMetadataGetDescription, _In_ const OrtModelMetadata* model_metadata,
1787 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
1788
1799 ORT_API2_STATUS(ModelMetadataLookupCustomMetadataMap, _In_ const OrtModelMetadata* model_metadata,
1800 _Inout_ OrtAllocator* allocator, _In_ const char* key, _Outptr_result_maybenull_ char** value);
1801
1809 ORT_API2_STATUS(ModelMetadataGetVersion, _In_ const OrtModelMetadata* model_metadata, _Out_ int64_t* value);
1810
1811 ORT_CLASS_RELEASE(ModelMetadata);
1812
1816
1830 ORT_API2_STATUS(CreateEnvWithGlobalThreadPools, OrtLoggingLevel log_severity_level, _In_ const char* logid,
1831 _In_ const OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out);
1832
1836
1846 ORT_API2_STATUS(DisablePerSessionThreads, _Inout_ OrtSessionOptions* options);
1847
1851
1857 ORT_API2_STATUS(CreateThreadingOptions, _Outptr_ OrtThreadingOptions** out);
1858
1859 ORT_CLASS_RELEASE(ThreadingOptions);
1860
1864
1876 ORT_API2_STATUS(ModelMetadataGetCustomMetadataMapKeys, _In_ const OrtModelMetadata* model_metadata,
1877 _Inout_ OrtAllocator* allocator, _Outptr_result_buffer_maybenull_(*num_keys) char*** keys, _Out_ int64_t* num_keys);
1878
1882
1890 ORT_API2_STATUS(AddFreeDimensionOverrideByName,
1891 _Inout_ OrtSessionOptions* options, _In_ const char* dim_name,
1892 _In_ int64_t dim_value);
1893
1897
1909 ORT_API2_STATUS(GetAvailableProviders, _Outptr_ char*** out_ptr, _Out_ int* provider_length);
1910
1918 ORT_API2_STATUS(ReleaseAvailableProviders, _In_ char** ptr,
1919 _In_ int providers_length);
1920
1924
1933 ORT_API2_STATUS(GetStringTensorElementLength, _In_ const OrtValue* value, size_t index, _Out_ size_t* out);
1934
1944 ORT_API2_STATUS(GetStringTensorElement, _In_ const OrtValue* value, size_t s_len, size_t index, _Out_writes_bytes_all_(s_len) void* s);
1945
1954 ORT_API2_STATUS(FillStringTensorElement, _Inout_ OrtValue* value, _In_ const char* s, size_t index);
1955
1959
1972 ORT_API2_STATUS(AddSessionConfigEntry, _Inout_ OrtSessionOptions* options,
1973 _In_z_ const char* config_key, _In_z_ const char* config_value);
1974
1978
1987 ORT_API2_STATUS(CreateAllocator, _In_ const OrtSession* session, _In_ const OrtMemoryInfo* mem_info,
1988 _Outptr_ OrtAllocator** out);
1989
1992 ORT_CLASS_RELEASE(Allocator);
1993
1997
2008 ORT_API2_STATUS(RunWithBinding, _Inout_ OrtSession* session, _In_ const OrtRunOptions* run_options, _In_ const OrtIoBinding* binding_ptr);
2009
2021 ORT_API2_STATUS(CreateIoBinding, _Inout_ OrtSession* session, _Outptr_ OrtIoBinding** out);
2022
2026
2029 ORT_CLASS_RELEASE(IoBinding);
2030
2041 ORT_API2_STATUS(BindInput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr);
2042
2053 ORT_API2_STATUS(BindOutput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr);
2054
2070 ORT_API2_STATUS(BindOutputToDevice, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtMemoryInfo* mem_info_ptr);
2071
2089 ORT_API2_STATUS(GetBoundOutputNames, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator,
2090 _Out_ char** buffer, _Out_writes_all_(count) size_t** lengths, _Out_ size_t* count);
2091
2109 ORT_API2_STATUS(GetBoundOutputValues, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator,
2110 _Out_writes_all_(output_count) OrtValue*** output, _Out_ size_t* output_count);
2111
2114 void(ORT_API_CALL* ClearBoundInputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
2115
2118 void(ORT_API_CALL* ClearBoundOutputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
2119
2123
2138 ORT_API2_STATUS(TensorAt, _Inout_ OrtValue* value, const int64_t* location_values, size_t location_values_count, _Outptr_ void** out);
2139
2143
2158 ORT_API2_STATUS(CreateAndRegisterAllocator, _Inout_ OrtEnv* env, _In_ const OrtMemoryInfo* mem_info,
2159 _In_ const OrtArenaCfg* arena_cfg);
2160
2172 ORT_API2_STATUS(SetLanguageProjection, _In_ const OrtEnv* ort_env, _In_ OrtLanguageProjection projection);
2173
2177
2187 ORT_API2_STATUS(SessionGetProfilingStartTimeNs, _In_ const OrtSession* session, _Outptr_ uint64_t* out);
2188
2192
2204 ORT_API2_STATUS(SetGlobalIntraOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int intra_op_num_threads);
2205
2217 ORT_API2_STATUS(SetGlobalInterOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int inter_op_num_threads);
2218
2232 ORT_API2_STATUS(SetGlobalSpinControl, _Inout_ OrtThreadingOptions* tp_options, int allow_spinning);
2233
2237
2252 ORT_API2_STATUS(AddInitializer, _Inout_ OrtSessionOptions* options, _In_z_ const char* name,
2253 _In_ const OrtValue* val);
2254
2258
2274 ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel log_severity_level,
2275 _In_ const char* logid, _In_ const struct OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out);
2276
2280
2291 _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptions* cuda_options);
2292
2303 _In_ OrtSessionOptions* options, _In_ const OrtROCMProviderOptions* rocm_options);
2304
2315 _In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options);
2316
2320
2331 ORT_API2_STATUS(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* tp_options);
2332
2336
2349 ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes,
2350 int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out);
2351
2352 ORT_CLASS_RELEASE(ArenaCfg);
2353
2357
2369 ORT_API2_STATUS(ModelMetadataGetGraphDescription, _In_ const OrtModelMetadata* model_metadata,
2370 _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
2371
2375
2386 _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options);
2387
2391
2402 ORT_API2_STATUS(SetCurrentGpuDeviceId, _In_ int device_id);
2403
2414 ORT_API2_STATUS(GetCurrentGpuDeviceId, _In_ int* device_id);
2415
2419
2442 ORT_API2_STATUS(KernelInfoGetAttributeArray_float, _In_ const OrtKernelInfo* info, _In_ const char* name,
2443 _Out_ float* out, _Inout_ size_t* size);
2444
2466 ORT_API2_STATUS(KernelInfoGetAttributeArray_int64, _In_ const OrtKernelInfo* info, _In_ const char* name,
2467 _Out_ int64_t* out, _Inout_ size_t* size);
2468
2472
2500 ORT_API2_STATUS(CreateArenaCfgV2, _In_reads_(num_keys) const char* const* arena_config_keys,
2501 _In_reads_(num_keys) const size_t* arena_config_values, _In_ size_t num_keys,
2502 _Outptr_ OrtArenaCfg** out);
2503
2507
2520 ORT_API2_STATUS(AddRunConfigEntry, _Inout_ OrtRunOptions* options,
2521 _In_z_ const char* config_key, _In_z_ const char* config_value);
2522
2526
2540
2545 ORT_CLASS_RELEASE(PrepackedWeightsContainer);
2546
2550
2568 ORT_API2_STATUS(CreateSessionWithPrepackedWeightsContainer, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path,
2569 _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
2570 _Outptr_ OrtSession** out);
2571
2590 ORT_API2_STATUS(CreateSessionFromArrayWithPrepackedWeightsContainer, _In_ const OrtEnv* env,
2591 _In_ const void* model_data, size_t model_data_length,
2592 _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
2593 _Outptr_ OrtSession** out);
2594
2598
2617 _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options);
2618
2622
2630
2646 ORT_API2_STATUS(UpdateTensorRTProviderOptions, _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options,
2647 _In_reads_(num_keys) const char* const* provider_options_keys,
2648 _In_reads_(num_keys) const char* const* provider_options_values,
2649 _In_ size_t num_keys);
2650
2662 ORT_API2_STATUS(GetTensorRTProviderOptionsAsString, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
2663
2668 void(ORT_API_CALL* ReleaseTensorRTProviderOptions)(_Frees_ptr_opt_ OrtTensorRTProviderOptionsV2* input);
2669
2673
2680 ORT_API2_STATUS(EnableOrtCustomOps, _Inout_ OrtSessionOptions* options);
2681
2685
2701 ORT_API2_STATUS(RegisterAllocator, _Inout_ OrtEnv* env, _In_ OrtAllocator* allocator);
2702
2713 ORT_API2_STATUS(UnregisterAllocator, _Inout_ OrtEnv* env,
2714 _In_ const OrtMemoryInfo* mem_info);
2715
2719
2728 ORT_API2_STATUS(IsSparseTensor, _In_ const OrtValue* value, _Out_ int* out);
2729
2746 ORT_API2_STATUS(CreateSparseTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* dense_shape,
2747 size_t dense_shape_len, ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
2748
2766 ORT_API2_STATUS(FillSparseTensorCoo, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
2767 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
2768 _In_ const int64_t* indices_data, size_t indices_num);
2769
2789 ORT_API2_STATUS(FillSparseTensorCsr, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
2790 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
2791 _In_ const int64_t* inner_indices_data, size_t inner_indices_num,
2792 _In_ const int64_t* outer_indices_data, size_t outer_indices_num);
2793
2812 ORT_API2_STATUS(FillSparseTensorBlockSparse, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info,
2813 _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values,
2814 _In_ const int64_t* indices_shape_data, size_t indices_shape_len,
2815 _In_ const int32_t* indices_data);
2816
2841 ORT_API2_STATUS(CreateSparseTensorWithValuesAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
2842 _In_ const int64_t* dense_shape, size_t dense_shape_len,
2843 _In_ const int64_t* values_shape, size_t values_shape_len,
2845
2860 ORT_API2_STATUS(UseCooIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* indices_data, size_t indices_num);
2861
2878 ORT_API2_STATUS(UseCsrIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* inner_data, size_t inner_num,
2879 _Inout_ int64_t* outer_data, size_t outer_num);
2880
2894 ORT_API2_STATUS(UseBlockSparseIndices, _Inout_ OrtValue* ort_value, const int64_t* indices_shape, size_t indices_shape_len, _Inout_ int32_t* indices_data);
2895
2903 ORT_API2_STATUS(GetSparseTensorFormat, _In_ const OrtValue* ort_value, _Out_ enum OrtSparseFormat* out);
2904
2912 ORT_API2_STATUS(GetSparseTensorValuesTypeAndShape, _In_ const OrtValue* ort_value, _Outptr_ OrtTensorTypeAndShapeInfo** out);
2913
2921 ORT_API2_STATUS(GetSparseTensorValues, _In_ const OrtValue* ort_value, _Outptr_ const void** out);
2922
2932 ORT_API2_STATUS(GetSparseTensorIndicesTypeShape, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Outptr_ OrtTensorTypeAndShapeInfo** out);
2933
2943 ORT_API2_STATUS(GetSparseTensorIndices, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Out_ size_t* num_indices, _Outptr_ const void** indices);
2944
2946};
2947
2948/*
2949 * Steps to use a custom op:
2950 * 1 Create an OrtCustomOpDomain with the domain name used by the custom ops
2951 * 2 Create an OrtCustomOp structure for each op and add them to the domain
2952 * 3 Call OrtAddCustomOpDomain to add the custom domain of ops to the session options
2953*/
2954#define OrtCustomOpApi OrtApi
2955
2956// Specifies some characteristics of inputs/outputs of custom ops:
2957// Specify if the inputs/outputs are one of:
2958// 1) Non-optional (input/output must be present in the node)
2959// 2) Optional (input/output may be absent in the node)
2961 // TODO: Support 'Variadic' inputs/outputs
2965
2966/*
2967 * The OrtCustomOp structure defines a custom op's schema and its kernel callbacks. The callbacks are filled in by
2968 * the implementor of the custom op.
2969*/
2971 uint32_t version; // Must be initialized to ORT_API_VERSION
2972
2973 // This callback creates the kernel, which is a user defined parameter that is passed to the Kernel* callbacks below.
2974 void*(ORT_API_CALL* CreateKernel)(_In_ const struct OrtCustomOp* op, _In_ const OrtApi* api,
2975 _In_ const OrtKernelInfo* info);
2976
2977 // Returns the name of the op
2978 const char*(ORT_API_CALL* GetName)(_In_ const struct OrtCustomOp* op);
2979
2980 // Returns the type of the execution provider, return nullptr to use CPU execution provider
2981 const char*(ORT_API_CALL* GetExecutionProviderType)(_In_ const struct OrtCustomOp* op);
2982
2983 // Returns the count and types of the input & output tensors
2984 ONNXTensorElementDataType(ORT_API_CALL* GetInputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
2985 size_t(ORT_API_CALL* GetInputTypeCount)(_In_ const struct OrtCustomOp* op);
2986 ONNXTensorElementDataType(ORT_API_CALL* GetOutputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
2987 size_t(ORT_API_CALL* GetOutputTypeCount)(_In_ const struct OrtCustomOp* op);
2988
2989 // Op kernel callbacks
2990 void(ORT_API_CALL* KernelCompute)(_In_ void* op_kernel, _In_ OrtKernelContext* context);
2991 void(ORT_API_CALL* KernelDestroy)(_In_ void* op_kernel);
2992
2993 // Returns the characteristics of the input & output tensors
2994 OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetInputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
2995 OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index);
2996};
2997
2998/*
2999 * This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality
3000 * This function always exists, but will only succeed if Onnxruntime was built with CUDA support and the CUDA provider shared library exists
3001 *
3002 * \param device_id CUDA device id, starts from zero.
3003*/
3004ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id);
3005
3006#ifdef __cplusplus
3007}
3008#endif
3009
struct OrtMemoryInfo OrtMemoryInfo
Definition: onnxruntime_c_api.h:238
struct OrtKernelInfo OrtKernelInfo
Definition: onnxruntime_c_api.h:310
OrtLoggingLevel
Logging severity levels.
Definition: onnxruntime_c_api.h:203
void(* OrtLoggingFunction)(void *param, OrtLoggingLevel severity, const char *category, const char *logid, const char *code_location, const char *message)
Definition: onnxruntime_c_api.h:275
OrtCustomOpInputOutputCharacteristic
Definition: onnxruntime_c_api.h:2960
struct OrtTensorRTProviderOptionsV2 OrtTensorRTProviderOptionsV2
Definition: onnxruntime_c_api.h:254
struct OrtThreadingOptions OrtThreadingOptions
Definition: onnxruntime_c_api.h:251
struct OrtSequenceTypeInfo OrtSequenceTypeInfo
Definition: onnxruntime_c_api.h:248
OrtLanguageProjection
Language projection identifiers /see OrtApi::SetLanguageProjection.
Definition: onnxruntime_c_api.h:299
OrtSparseIndicesFormat
Definition: onnxruntime_c_api.h:192
struct OrtPrepackedWeightsContainer OrtPrepackedWeightsContainer
Definition: onnxruntime_c_api.h:253
struct OrtSession OrtSession
Definition: onnxruntime_c_api.h:240
struct OrtCustomOpDomain OrtCustomOpDomain
Definition: onnxruntime_c_api.h:246
struct OrtIoBinding OrtIoBinding
Definition: onnxruntime_c_api.h:239
OrtAllocatorType
Definition: onnxruntime_c_api.h:316
struct OrtModelMetadata OrtModelMetadata
Definition: onnxruntime_c_api.h:249
struct OrtTypeInfo OrtTypeInfo
Definition: onnxruntime_c_api.h:243
struct OrtTensorTypeAndShapeInfo OrtTensorTypeAndShapeInfo
Definition: onnxruntime_c_api.h:244
struct OrtKernelContext OrtKernelContext
Definition: onnxruntime_c_api.h:312
OrtCudnnConvAlgoSearch
Algorithm to use for cuDNN Convolution Op.
Definition: onnxruntime_c_api.h:334
struct OrtRunOptions OrtRunOptions
Definition: onnxruntime_c_api.h:242
struct OrtSessionOptions OrtSessionOptions
Definition: onnxruntime_c_api.h:245
struct OrtValue OrtValue
Definition: onnxruntime_c_api.h:241
GraphOptimizationLevel
Graph optimization level.
Definition: onnxruntime_c_api.h:284
OrtStatus * OrtStatusPtr
Definition: onnxruntime_c_api.h:254
OrtMemType
Memory types for allocated memory, execution provider specific types should be extended in each provi...
Definition: onnxruntime_c_api.h:325
OrtSparseFormat
Definition: onnxruntime_c_api.h:184
ONNXType
Definition: onnxruntime_c_api.h:173
struct OrtEnv OrtEnv
Definition: onnxruntime_c_api.h:236
OrtErrorCode
Definition: onnxruntime_c_api.h:211
struct OrtStatus OrtStatus
Definition: onnxruntime_c_api.h:237
struct OrtMapTypeInfo OrtMapTypeInfo
Definition: onnxruntime_c_api.h:247
struct OrtArenaCfg OrtArenaCfg
Definition: onnxruntime_c_api.h:252
ExecutionMode
Definition: onnxruntime_c_api.h:291
OrtStatus * OrtSessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions *options, int device_id)
ONNXTensorElementDataType
Definition: onnxruntime_c_api.h:152
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:204
@ ORT_LOGGING_LEVEL_INFO
Informational messages.
Definition: onnxruntime_c_api.h:205
@ ORT_LOGGING_LEVEL_ERROR
Error messages.
Definition: onnxruntime_c_api.h:207
@ ORT_LOGGING_LEVEL_WARNING
Warning messages.
Definition: onnxruntime_c_api.h:206
@ ORT_LOGGING_LEVEL_FATAL
Fatal error messages (most severe).
Definition: onnxruntime_c_api.h:208
@ INPUT_OUTPUT_REQUIRED
Definition: onnxruntime_c_api.h:2962
@ INPUT_OUTPUT_OPTIONAL
Definition: onnxruntime_c_api.h:2963
@ ORT_PROJECTION_C
Definition: onnxruntime_c_api.h:300
@ ORT_PROJECTION_PYTHON
Definition: onnxruntime_c_api.h:303
@ ORT_PROJECTION_CPLUSPLUS
Definition: onnxruntime_c_api.h:301
@ ORT_PROJECTION_WINML
Definition: onnxruntime_c_api.h:305
@ ORT_PROJECTION_CSHARP
Definition: onnxruntime_c_api.h:302
@ ORT_PROJECTION_JAVA
Definition: onnxruntime_c_api.h:304
@ ORT_PROJECTION_NODEJS
Definition: onnxruntime_c_api.h:306
@ ORT_SPARSE_COO_INDICES
Definition: onnxruntime_c_api.h:193
@ ORT_SPARSE_BLOCK_SPARSE_INDICES
Definition: onnxruntime_c_api.h:196
@ ORT_SPARSE_CSR_OUTER_INDICES
Definition: onnxruntime_c_api.h:195
@ ORT_SPARSE_CSR_INNER_INDICES
Definition: onnxruntime_c_api.h:194
@ OrtDeviceAllocator
Definition: onnxruntime_c_api.h:318
@ OrtArenaAllocator
Definition: onnxruntime_c_api.h:319
@ Invalid
Definition: onnxruntime_c_api.h:317
@ HEURISTIC
Definition: onnxruntime_c_api.h:336
@ EXHAUSTIVE
Definition: onnxruntime_c_api.h:335
@ DEFAULT
Definition: onnxruntime_c_api.h:337
@ ORT_ENABLE_BASIC
Definition: onnxruntime_c_api.h:286
@ ORT_ENABLE_ALL
Definition: onnxruntime_c_api.h:288
@ ORT_DISABLE_ALL
Definition: onnxruntime_c_api.h:285
@ ORT_ENABLE_EXTENDED
Definition: onnxruntime_c_api.h:287
@ OrtMemTypeCPUInput
Any CPU memory used by non-CPU execution provider.
Definition: onnxruntime_c_api.h:326
@ OrtMemTypeCPU
Temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED.
Definition: onnxruntime_c_api.h:328
@ OrtMemTypeDefault
The default allocator for execution provider.
Definition: onnxruntime_c_api.h:329
@ OrtMemTypeCPUOutput
CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED.
Definition: onnxruntime_c_api.h:327
@ ORT_SPARSE_CSRC
Definition: onnxruntime_c_api.h:187
@ ORT_SPARSE_COO
Definition: onnxruntime_c_api.h:186
@ ORT_SPARSE_BLOCK_SPARSE
Definition: onnxruntime_c_api.h:188
@ ORT_SPARSE_UNDEFINED
Definition: onnxruntime_c_api.h:185
@ ONNX_TYPE_SEQUENCE
Definition: onnxruntime_c_api.h:176
@ ONNX_TYPE_MAP
Definition: onnxruntime_c_api.h:177
@ ONNX_TYPE_OPAQUE
Definition: onnxruntime_c_api.h:178
@ ONNX_TYPE_UNKNOWN
Definition: onnxruntime_c_api.h:174
@ ONNX_TYPE_TENSOR
Definition: onnxruntime_c_api.h:175
@ ONNX_TYPE_SPARSETENSOR
Definition: onnxruntime_c_api.h:179
@ ORT_NO_SUCHFILE
Definition: onnxruntime_c_api.h:215
@ ORT_OK
Definition: onnxruntime_c_api.h:212
@ ORT_INVALID_ARGUMENT
Definition: onnxruntime_c_api.h:214
@ ORT_EP_FAIL
Definition: onnxruntime_c_api.h:223
@ ORT_NOT_IMPLEMENTED
Definition: onnxruntime_c_api.h:221
@ ORT_RUNTIME_EXCEPTION
Definition: onnxruntime_c_api.h:218
@ ORT_ENGINE_ERROR
Definition: onnxruntime_c_api.h:217
@ ORT_FAIL
Definition: onnxruntime_c_api.h:213
@ ORT_INVALID_PROTOBUF
Definition: onnxruntime_c_api.h:219
@ ORT_NO_MODEL
Definition: onnxruntime_c_api.h:216
@ ORT_INVALID_GRAPH
Definition: onnxruntime_c_api.h:222
@ ORT_MODEL_LOADED
Definition: onnxruntime_c_api.h:220
@ ORT_PARALLEL
Definition: onnxruntime_c_api.h:293
@ ORT_SEQUENTIAL
Definition: onnxruntime_c_api.h:292
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING
Definition: onnxruntime_c_api.h:161
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32
Definition: onnxruntime_c_api.h:159
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32
Definition: onnxruntime_c_api.h:165
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16
Definition: onnxruntime_c_api.h:157
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED
Definition: onnxruntime_c_api.h:153
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128
Definition: onnxruntime_c_api.h:168
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64
Definition: onnxruntime_c_api.h:166
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64
Definition: onnxruntime_c_api.h:160
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL
Definition: onnxruntime_c_api.h:162
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16
Definition: onnxruntime_c_api.h:163
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8
Definition: onnxruntime_c_api.h:155
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16
Definition: onnxruntime_c_api.h:158
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE
Definition: onnxruntime_c_api.h:164
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8
Definition: onnxruntime_c_api.h:156
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT
Definition: onnxruntime_c_api.h:154
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16
Definition: onnxruntime_c_api.h:169
@ ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64
Definition: onnxruntime_c_api.h:167
Memory allocation interface.
Definition: onnxruntime_c_api.h:268
void(* Free)(struct OrtAllocator *this_, void *p)
Free a block of memory previously allocated with OrtAllocator::Alloc.
Definition: onnxruntime_c_api.h:271
const struct OrtMemoryInfo *(* Info)(const struct OrtAllocator *this_)
Return a pointer to an OrtMemoryInfo that describes this allocator.
Definition: onnxruntime_c_api.h:272
uint32_t version
Must be initialized to ORT_API_VERSION.
Definition: onnxruntime_c_api.h:269
void *(* Alloc)(struct OrtAllocator *this_, size_t size)
Returns a pointer to an allocated block of size bytes.
Definition: onnxruntime_c_api.h:270
The helper interface to get the right version of OrtApi.
Definition: onnxruntime_c_api.h:430
const char *(* GetVersionString)(void)
Returns a null terminated string of the version of the Onnxruntime library (eg: "1....
Definition: onnxruntime_c_api.h:438
const OrtApi *(* GetApi)(uint32_t version)
Get a pointer to the requested version of the OrtApi.
Definition: onnxruntime_c_api.h:437
The C API.
Definition: onnxruntime_c_api.h:455
OrtStatus * SessionGetOverridableInitializerTypeInfo(const OrtSession *session, size_t index, OrtTypeInfo **type_info)
Get overridable initializer type information.
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.
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 * 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 * 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 * 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 * 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 * 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.
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 * 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:2114
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 * 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 * GetStringTensorElementLength(const OrtValue *value, size_t index, size_t *out)
Get the length of a single string in a string tensor.
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 * 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 * CreateEnvWithCustomLogger(OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel log_severity_level, const char *logid, OrtEnv **out)
Create an OrtEnv.
OrtStatus * MemoryInfoGetName(const OrtMemoryInfo *ptr, const char **out)
Get name from OrtMemoryInfo.
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 * MemoryInfoGetType(const OrtMemoryInfo *ptr, OrtAllocatorType *out)
Get the OrtAllocatorType from OrtMemoryInfo.
OrtStatus * CreateEnvWithGlobalThreadPools(OrtLoggingLevel log_severity_level, const char *logid, const OrtThreadingOptions *tp_options, OrtEnv **out)
Create an OrtEnv.
OrtStatus * GetTensorRTProviderOptionsAsString(const OrtTensorRTProviderOptionsV2 *tensorrt_options, OrtAllocator *allocator, char **ptr)
Get serialized TensorRT provider options string.
OrtStatus * GetDimensionsCount(const OrtTensorTypeAndShapeInfo *info, size_t *out)
Get dimension count in OrtTensorTypeAndShapeInfo.
OrtStatus * RegisterCustomOpsLibrary(OrtSessionOptions *options, const char *library_path, void **library_handle)
Register custom ops from a shared library.
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.
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 * 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 * 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 * 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 * 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 * ModelMetadataGetGraphName(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, char **value)
Get graph name from an OrtModelMetadata.
OrtStatus * ModelMetadataLookupCustomMetadataMap(const OrtModelMetadata *model_metadata, OrtAllocator *allocator, const char *key, char **value)
Return data for a key in the custom metadata map in an OrtModelMetadata.
OrtStatus * RunOptionsSetRunLogSeverityLevel(OrtRunOptions *options, int log_severity_level)
Set per-run log severity level.
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 * 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:480
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 * 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 * 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 * 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 * 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:2118
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 * 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 * SessionGetOverridableInitializerName(const OrtSession *session, size_t index, OrtAllocator *allocator, char **value)
Get overridable initializer name.
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:466
OrtStatus * RunWithBinding(OrtSession *session, const OrtRunOptions *run_options, const OrtIoBinding *binding_ptr)
Run a model using Io Bindings for the inputs & outputs.
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 * 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 * CreateValue(const OrtValue *const *in, size_t num_values, enum ONNXType value_type, OrtValue **out)
Create a map or sequence OrtValue.
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 * CreateSessionWithPrepackedWeightsContainer(const OrtEnv *env, const char *model_path, const OrtSessionOptions *options, OrtPrepackedWeightsContainer *prepacked_weights_container, OrtSession **out)
Create session with prepacked weights container.
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 * 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 * 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 * 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:2668
OrtStatus * ReleaseAvailableProviders(char **ptr, int providers_length)
Release data from OrtApi::GetAvailableProviders.
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 * 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 * CreateTensorAsOrtValue(OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type, OrtValue **out)
Create a tensor.
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:473
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:344
int has_user_compute_stream
Definition: onnxruntime_c_api.h:362
int do_copy_in_default_stream
Definition: onnxruntime_c_api.h:361
void * user_compute_stream
Definition: onnxruntime_c_api.h:363
size_t gpu_mem_limit
CUDA memory limit (To use all possible memory pass in maximum size_t)
Definition: onnxruntime_c_api.h:352
int arena_extend_strategy
Strategy used to grow the memory arena.
Definition: onnxruntime_c_api.h:360
OrtArenaCfg * default_memory_arena_cfg
Definition: onnxruntime_c_api.h:364
OrtCudnnConvAlgoSearch cudnn_conv_algo_search
Definition: onnxruntime_c_api.h:346
int device_id
CUDA device id (0 = default device)
Definition: onnxruntime_c_api.h:345
Definition: onnxruntime_c_api.h:2970
OrtCustomOpInputOutputCharacteristic(* GetOutputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:2995
size_t(* GetInputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:2985
const char *(* GetName)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:2978
size_t(* GetOutputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:2987
void(* KernelDestroy)(void *op_kernel)
Definition: onnxruntime_c_api.h:2991
void *(* CreateKernel)(const struct OrtCustomOp *op, const OrtApi *api, const OrtKernelInfo *info)
Definition: onnxruntime_c_api.h:2974
uint32_t version
Definition: onnxruntime_c_api.h:2971
ONNXTensorElementDataType(* GetInputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:2984
OrtCustomOpInputOutputCharacteristic(* GetInputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:2994
const char *(* GetExecutionProviderType)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:2981
ONNXTensorElementDataType(* GetOutputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:2986
void(* KernelCompute)(void *op_kernel, OrtKernelContext *context)
Definition: onnxruntime_c_api.h:2990
OpenVINO Provider Options.
Definition: onnxruntime_c_api.h:407
size_t num_of_threads
0 = Use default number of threads
Definition: onnxruntime_c_api.h:418
const char * blob_dump_path
Definition: onnxruntime_c_api.h:420
unsigned char enable_vpu_fast_compile
0 = disabled, nonzero = enabled
Definition: onnxruntime_c_api.h:416
const char * device_type
Device type string.
Definition: onnxruntime_c_api.h:415
const char * device_id
Definition: onnxruntime_c_api.h:417
unsigned char use_compiled_network
0 = disabled, nonzero = enabled
Definition: onnxruntime_c_api.h:419
OrtOpenVINOProviderOptions()
Definition: onnxruntime_c_api.h:409
ROCM Provider Options.
Definition: onnxruntime_c_api.h:371
int device_id
hip device id (0 = default device)
Definition: onnxruntime_c_api.h:372
size_t gpu_mem_limit
Definition: onnxruntime_c_api.h:374
int arena_extend_strategy
Definition: onnxruntime_c_api.h:375
int miopen_conv_exhaustive_search
Definition: onnxruntime_c_api.h:373
TensorRT Provider Options.
Definition: onnxruntime_c_api.h:382
int trt_engine_cache_enable
Definition: onnxruntime_c_api.h:396
void * user_compute_stream
Definition: onnxruntime_c_api.h:385
int device_id
CUDA device id (0 = default device)
Definition: onnxruntime_c_api.h:383
const char * trt_engine_cache_path
Definition: onnxruntime_c_api.h:397
int trt_engine_decryption_enable
Definition: onnxruntime_c_api.h:398
int trt_max_partition_iterations
Definition: onnxruntime_c_api.h:386
size_t trt_max_workspace_size
Definition: onnxruntime_c_api.h:388
int trt_dla_enable
Definition: onnxruntime_c_api.h:393
const char * trt_int8_calibration_table_name
Definition: onnxruntime_c_api.h:391
int has_user_compute_stream
Definition: onnxruntime_c_api.h:384
int trt_dla_core
Definition: onnxruntime_c_api.h:394
int trt_int8_use_native_calibration_table
Definition: onnxruntime_c_api.h:392
int trt_min_subgraph_size
Definition: onnxruntime_c_api.h:387
int trt_force_sequential_engine_build
Definition: onnxruntime_c_api.h:400
int trt_dump_subgraphs
Definition: onnxruntime_c_api.h:395
int trt_fp16_enable
Definition: onnxruntime_c_api.h:389
const char * trt_engine_decryption_lib_path
Definition: onnxruntime_c_api.h:399
int trt_int8_enable
Definition: onnxruntime_c_api.h:390