microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
includes/onnxruntime/onnxruntime_c_api.h
1842lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | /** @file onnxruntime_c_api.h |
| 5 | |
| 6 | @brief ONNX Runtime C API. |
| 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | #include <stdlib.h> |
| 11 | #include <stdint.h> |
| 12 | #include <string.h> |
| 13 | |
| 14 | // This value is used in structures passed to ORT so that a newer version of ORT will still work with them |
| 15 | #define ORT_API_VERSION 9 |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | // SAL2 Definitions |
| 22 | #ifndef _WIN32 |
| 23 | #define _In_ |
| 24 | #define _In_z_ |
| 25 | #define _In_opt_ |
| 26 | #define _In_opt_z_ |
| 27 | #define _Out_ |
| 28 | #define _Outptr_ |
| 29 | #define _Out_opt_ |
| 30 | #define _Inout_ |
| 31 | #define _Inout_opt_ |
| 32 | #define _Frees_ptr_opt_ |
| 33 | #define _Ret_maybenull_ |
| 34 | #define _Ret_notnull_ |
| 35 | #define _Check_return_ |
| 36 | #define _Outptr_result_maybenull_ |
| 37 | #define _In_reads_(X) |
| 38 | #define _Inout_updates_all_(X) |
| 39 | #define _Out_writes_bytes_all_(X) |
| 40 | #define _Out_writes_all_(X) |
| 41 | #define _Success_(X) |
| 42 | #define _Outptr_result_buffer_maybenull_(X) |
| 43 | #define ORT_ALL_ARGS_NONNULL __attribute__((nonnull)) |
| 44 | #else |
| 45 | #include <specstrings.h> |
| 46 | #define ORT_ALL_ARGS_NONNULL |
| 47 | #endif |
| 48 | |
| 49 | #ifdef _WIN32 |
| 50 | // Define ORT_DLL_IMPORT if your program is dynamically linked to Ort. |
| 51 | // dllexport is not used, we use a .def file. |
| 52 | #ifdef ORT_DLL_IMPORT |
| 53 | #define ORT_EXPORT __declspec(dllimport) |
| 54 | #else |
| 55 | #define ORT_EXPORT |
| 56 | #endif |
| 57 | #define ORT_API_CALL _stdcall |
| 58 | #define ORT_MUST_USE_RESULT |
| 59 | #define ORTCHAR_T wchar_t |
| 60 | #else |
| 61 | // To make symbols visible on macOS/iOS |
| 62 | #ifdef __APPLE__ |
| 63 | #define ORT_EXPORT __attribute__((visibility("default"))) |
| 64 | #else |
| 65 | #define ORT_EXPORT |
| 66 | #endif |
| 67 | #define ORT_API_CALL |
| 68 | #define ORT_MUST_USE_RESULT __attribute__((warn_unused_result)) |
| 69 | #define ORTCHAR_T char |
| 70 | #endif |
| 71 | |
| 72 | #ifndef ORT_TSTR |
| 73 | #ifdef _WIN32 |
| 74 | #define ORT_TSTR(X) L##X |
| 75 | #else |
| 76 | #define ORT_TSTR(X) X |
| 77 | #endif |
| 78 | #endif |
| 79 | |
| 80 | // Any pointer marked with _In_ or _Out_, cannot be NULL. |
| 81 | |
| 82 | // Windows users should use unicode paths when possible to bypass the MAX_PATH limitation |
| 83 | // Every pointer marked with _In_ or _Out_, cannot be NULL. Caller should ensure that. |
| 84 | // for ReleaseXXX(...) functions, they can accept NULL pointer. |
| 85 | |
| 86 | #ifdef __cplusplus |
| 87 | // For any compiler with C++11 support, MSVC 2015 and greater, or Clang version supporting noexcept. |
| 88 | // Such complex condition is needed because compilers set __cplusplus value differently. |
| 89 | #ifndef __has_feature |
| 90 | #define __has_feature(x) 0 |
| 91 | #endif |
| 92 | #if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || (defined(__has_feature) && __has_feature(cxx_noexcept))) |
| 93 | #define NO_EXCEPTION noexcept |
| 94 | #else |
| 95 | #define NO_EXCEPTION throw() |
| 96 | #endif |
| 97 | #else |
| 98 | #define NO_EXCEPTION |
| 99 | #endif |
| 100 | |
| 101 | // Copied from TensorProto::DataType |
| 102 | // Currently, Ort doesn't support complex64, complex128 |
| 103 | typedef enum ONNXTensorElementDataType { |
| 104 | ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED, |
| 105 | ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, // maps to c type float |
| 106 | ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8, // maps to c type uint8_t |
| 107 | ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8, // maps to c type int8_t |
| 108 | ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16, // maps to c type uint16_t |
| 109 | ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16, // maps to c type int16_t |
| 110 | ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32, // maps to c type int32_t |
| 111 | ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64, // maps to c type int64_t |
| 112 | ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING, // maps to c++ type std::string |
| 113 | ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL, |
| 114 | ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16, |
| 115 | ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE, // maps to c type double |
| 116 | ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32, // maps to c type uint32_t |
| 117 | ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64, // maps to c type uint64_t |
| 118 | ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64, // complex with float32 real and imaginary components |
| 119 | ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128, // complex with float64 real and imaginary components |
| 120 | ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16 // Non-IEEE floating-point format based on IEEE754 single-precision |
| 121 | } ONNXTensorElementDataType; |
| 122 | |
| 123 | // Synced with onnx TypeProto oneof |
| 124 | typedef enum ONNXType { |
| 125 | ONNX_TYPE_UNKNOWN, |
| 126 | ONNX_TYPE_TENSOR, |
| 127 | ONNX_TYPE_SEQUENCE, |
| 128 | ONNX_TYPE_MAP, |
| 129 | ONNX_TYPE_OPAQUE, |
| 130 | ONNX_TYPE_SPARSETENSOR, |
| 131 | } ONNXType; |
| 132 | |
| 133 | // These types are synced with internal |
| 134 | // SparseFormatFlags |
| 135 | typedef enum OrtSparseFormat { |
| 136 | ORT_SPARSE_UNDEFINED = 0, |
| 137 | ORT_SPARSE_COO = 0x1, |
| 138 | ORT_SPARSE_CSRC = 0x2, |
| 139 | ORT_SPARSE_BLOCK_SPARSE = 0x4 |
| 140 | } OrtSparseFormat; |
| 141 | |
| 142 | // Enum allows to query sparse tensor indices |
| 143 | enum OrtSparseIndicesFormat { |
| 144 | ORT_SPARSE_COO_INDICES, |
| 145 | ORT_SPARSE_CSR_INNER_INDICES, |
| 146 | ORT_SPARSE_CSR_OUTER_INDICES, |
| 147 | ORT_SPARSE_BLOCK_SPARSE_INDICES |
| 148 | }; |
| 149 | |
| 150 | typedef enum OrtLoggingLevel { |
| 151 | ORT_LOGGING_LEVEL_VERBOSE, |
| 152 | ORT_LOGGING_LEVEL_INFO, |
| 153 | ORT_LOGGING_LEVEL_WARNING, |
| 154 | ORT_LOGGING_LEVEL_ERROR, |
| 155 | ORT_LOGGING_LEVEL_FATAL, |
| 156 | } OrtLoggingLevel; |
| 157 | |
| 158 | typedef enum OrtErrorCode { |
| 159 | ORT_OK, |
| 160 | ORT_FAIL, |
| 161 | ORT_INVALID_ARGUMENT, |
| 162 | ORT_NO_SUCHFILE, |
| 163 | ORT_NO_MODEL, |
| 164 | ORT_ENGINE_ERROR, |
| 165 | ORT_RUNTIME_EXCEPTION, |
| 166 | ORT_INVALID_PROTOBUF, |
| 167 | ORT_MODEL_LOADED, |
| 168 | ORT_NOT_IMPLEMENTED, |
| 169 | ORT_INVALID_GRAPH, |
| 170 | ORT_EP_FAIL, |
| 171 | } OrtErrorCode; |
| 172 | |
| 173 | #define ORT_RUNTIME_CLASS(X) \ |
| 174 | struct Ort##X; \ |
| 175 | typedef struct Ort##X Ort##X; |
| 176 | |
| 177 | // The actual types defined have an Ort prefix |
| 178 | ORT_RUNTIME_CLASS(Env); |
| 179 | ORT_RUNTIME_CLASS(Status); // nullptr for Status* indicates success |
| 180 | ORT_RUNTIME_CLASS(MemoryInfo); |
| 181 | ORT_RUNTIME_CLASS(IoBinding); |
| 182 | ORT_RUNTIME_CLASS(Session); //Don't call ReleaseSession from Dllmain (because session owns a thread pool) |
| 183 | ORT_RUNTIME_CLASS(Value); |
| 184 | ORT_RUNTIME_CLASS(RunOptions); |
| 185 | ORT_RUNTIME_CLASS(TypeInfo); |
| 186 | ORT_RUNTIME_CLASS(TensorTypeAndShapeInfo); |
| 187 | ORT_RUNTIME_CLASS(SessionOptions); |
| 188 | ORT_RUNTIME_CLASS(CustomOpDomain); |
| 189 | ORT_RUNTIME_CLASS(MapTypeInfo); |
| 190 | ORT_RUNTIME_CLASS(SequenceTypeInfo); |
| 191 | ORT_RUNTIME_CLASS(ModelMetadata); |
| 192 | ORT_RUNTIME_CLASS(ThreadPoolParams); |
| 193 | ORT_RUNTIME_CLASS(ThreadingOptions); |
| 194 | ORT_RUNTIME_CLASS(ArenaCfg); |
| 195 | ORT_RUNTIME_CLASS(PrepackedWeightsContainer); |
| 196 | ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2); |
| 197 | |
| 198 | #ifdef _WIN32 |
| 199 | typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr; |
| 200 | #else |
| 201 | typedef OrtStatus* OrtStatusPtr; |
| 202 | #endif |
| 203 | |
| 204 | // __VA_ARGS__ on Windows and Linux are different |
| 205 | #define ORT_API(RETURN_TYPE, NAME, ...) RETURN_TYPE ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION |
| 206 | |
| 207 | #define ORT_API_STATUS(NAME, ...) \ |
| 208 | _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT |
| 209 | |
| 210 | // XXX: Unfortunately, SAL annotations are known to not work with function pointers |
| 211 | #define ORT_API2_STATUS(NAME, ...) \ |
| 212 | _Check_return_ _Ret_maybenull_ OrtStatusPtr(ORT_API_CALL* NAME)(__VA_ARGS__) NO_EXCEPTION ORT_MUST_USE_RESULT |
| 213 | |
| 214 | // Used in *.cc files. Almost as same as ORT_API_STATUS, except without ORT_MUST_USE_RESULT and ORT_EXPORT |
| 215 | #define ORT_API_STATUS_IMPL(NAME, ...) \ |
| 216 | _Success_(return == 0) _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION |
| 217 | |
| 218 | #define ORT_CLASS_RELEASE(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input) |
| 219 | #define ORT_CLASS_RELEASE2(X) void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X##V2 * input) |
| 220 | |
| 221 | // When passing in an allocator to any ORT function, be sure that the allocator object |
| 222 | // is not destroyed until the last allocated object using it is freed. |
| 223 | typedef struct OrtAllocator { |
| 224 | uint32_t version; ///< Must be initialized to ORT_API_VERSION |
| 225 | void*(ORT_API_CALL* Alloc)(struct OrtAllocator* this_, size_t size); ///< Returns a pointer to an allocated block of `size` bytes |
| 226 | void(ORT_API_CALL* Free)(struct OrtAllocator* this_, void* p); ///< Free a block of memory previously allocated with OrtAllocator::Alloc |
| 227 | const struct OrtMemoryInfo*(ORT_API_CALL* Info)(const struct OrtAllocator* this_); ///< Return a pointer to an ::OrtMemoryInfo that describes this allocator |
| 228 | } OrtAllocator; |
| 229 | |
| 230 | typedef void(ORT_API_CALL* OrtLoggingFunction)( |
| 231 | void* param, OrtLoggingLevel severity, const char* category, const char* logid, const char* code_location, |
| 232 | const char* message); |
| 233 | |
| 234 | // Graph optimization level. |
| 235 | // Refer to https://www.onnxruntime.ai/docs/resources/graph-optimizations.html |
| 236 | // for an in-depth understanding of Graph Optimizations in ORT |
| 237 | typedef enum GraphOptimizationLevel { |
| 238 | ORT_DISABLE_ALL = 0, |
| 239 | ORT_ENABLE_BASIC = 1, |
| 240 | ORT_ENABLE_EXTENDED = 2, |
| 241 | ORT_ENABLE_ALL = 99 |
| 242 | } GraphOptimizationLevel; |
| 243 | |
| 244 | typedef enum ExecutionMode { |
| 245 | ORT_SEQUENTIAL = 0, |
| 246 | ORT_PARALLEL = 1, |
| 247 | } ExecutionMode; |
| 248 | |
| 249 | // Set the language projection, default is C, which means it will classify the language not in the list to C also. |
| 250 | typedef enum OrtLanguageProjection { |
| 251 | ORT_PROJECTION_C = 0, // default |
| 252 | ORT_PROJECTION_CPLUSPLUS = 1, |
| 253 | ORT_PROJECTION_CSHARP = 2, |
| 254 | ORT_PROJECTION_PYTHON = 3, |
| 255 | ORT_PROJECTION_JAVA = 4, |
| 256 | ORT_PROJECTION_WINML = 5, |
| 257 | ORT_PROJECTION_NODEJS = 6, |
| 258 | } OrtLanguageProjection; |
| 259 | |
| 260 | struct OrtKernelInfo; |
| 261 | typedef struct OrtKernelInfo OrtKernelInfo; |
| 262 | struct OrtKernelContext; |
| 263 | typedef struct OrtKernelContext OrtKernelContext; |
| 264 | struct OrtCustomOp; |
| 265 | typedef struct OrtCustomOp OrtCustomOp; |
| 266 | |
| 267 | typedef enum OrtAllocatorType { |
| 268 | Invalid = -1, |
| 269 | OrtDeviceAllocator = 0, |
| 270 | OrtArenaAllocator = 1 |
| 271 | } OrtAllocatorType; |
| 272 | |
| 273 | /** |
| 274 | * memory types for allocator, exec provider specific types should be extended in each provider |
| 275 | * Whenever this struct is updated, please also update the MakeKey function in onnxruntime/core/framework/execution_provider.cc |
| 276 | */ |
| 277 | typedef enum OrtMemType { |
| 278 | OrtMemTypeCPUInput = -2, // Any CPU memory used by non-CPU execution provider |
| 279 | OrtMemTypeCPUOutput = -1, // CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED |
| 280 | OrtMemTypeCPU = OrtMemTypeCPUOutput, // temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED |
| 281 | OrtMemTypeDefault = 0, // the default allocator for execution provider |
| 282 | } OrtMemType; |
| 283 | |
| 284 | typedef enum OrtCudnnConvAlgoSearch { |
| 285 | EXHAUSTIVE, // expensive exhaustive benchmarking using cudnnFindConvolutionForwardAlgorithmEx |
| 286 | HEURISTIC, // lightweight heuristic based search using cudnnGetConvolutionForwardAlgorithm_v7 |
| 287 | DEFAULT, // default algorithm using CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM |
| 288 | } OrtCudnnConvAlgoSearch; |
| 289 | |
| 290 | /// <summary> |
| 291 | /// Options for the CUDA provider that are passed to SessionOptionsAppendExecutionProvider_CUDA |
| 292 | /// </summary> |
| 293 | typedef struct OrtCUDAProviderOptions { |
| 294 | #ifdef __cplusplus |
| 295 | OrtCUDAProviderOptions() : device_id{}, cudnn_conv_algo_search{EXHAUSTIVE}, gpu_mem_limit{SIZE_MAX}, arena_extend_strategy{}, do_copy_in_default_stream{1}, has_user_compute_stream{}, user_compute_stream{}, default_memory_arena_cfg{} {} |
| 296 | #endif |
| 297 | |
| 298 | /** \brief CUDA device Id |
| 299 | * Defaults to 0. |
| 300 | */ |
| 301 | int device_id; |
| 302 | |
| 303 | /** \brief CUDA Convolution algorithm search configuration. |
| 304 | * See enum OrtCudnnConvAlgoSearch for more details. |
| 305 | * Defaults to OrtCudnnConvAlgoSearchExhaustive. |
| 306 | */ |
| 307 | OrtCudnnConvAlgoSearch cudnn_conv_algo_search; |
| 308 | |
| 309 | /** \brief CUDA memory limit (To use all possible memory pass in maximum size_t) |
| 310 | * Defaults to SIZE_MAX. |
| 311 | * \note If a ::OrtArenaCfg has been applied, it will override this field |
| 312 | */ |
| 313 | size_t gpu_mem_limit; |
| 314 | |
| 315 | /** \brief Strategy used to grow the memory arena |
| 316 | * 0 = kNextPowerOfTwo<br> |
| 317 | * 1 = kSameAsRequested<br> |
| 318 | * Defaults to 0. |
| 319 | * \note If a ::OrtArenaCfg has been applied, it will override this field |
| 320 | */ |
| 321 | int arena_extend_strategy; |
| 322 | |
| 323 | /** \brief Flag indicating if copying needs to take place on the same stream as the compute stream in the CUDA EP |
| 324 | * 0 = Use separate streams for copying and compute. |
| 325 | * 1 = Use the same stream for copying and compute. |
| 326 | * Defaults to 1. |
| 327 | * WARNING: Setting this to 0 may result in data races for some models. |
| 328 | * Please see issue #4829 for more details. |
| 329 | */ |
| 330 | int do_copy_in_default_stream; |
| 331 | |
| 332 | /** \brief Flag indicating if there is a user provided compute stream |
| 333 | * Defaults to 0. |
| 334 | */ |
| 335 | int has_user_compute_stream; |
| 336 | |
| 337 | /** \brief User provided compute stream. |
| 338 | * If provided, please set `has_user_compute_stream` to 1. |
| 339 | */ |
| 340 | void* user_compute_stream; |
| 341 | |
| 342 | /** \brief CUDA memory arena configuration parameters |
| 343 | */ |
| 344 | OrtArenaCfg* default_memory_arena_cfg; |
| 345 | |
| 346 | } OrtCUDAProviderOptions; |
| 347 | |
| 348 | /// <summary> |
| 349 | /// Options for the ROCM provider that are passed to SessionOptionsAppendExecutionProvider_ROCM |
| 350 | /// </summary> |
| 351 | typedef struct OrtROCMProviderOptions { |
| 352 | int device_id; // hip device with id=0 as default device. |
| 353 | int miopen_conv_exhaustive_search; // miopen conv algo exhaustive search option |
| 354 | size_t gpu_mem_limit; // default hip memory limitation to maximum finite value of size_t. |
| 355 | int arena_extend_strategy; // default area extend strategy to KNextPowerOfTwo. |
| 356 | } OrtROCMProviderOptions; |
| 357 | |
| 358 | /// <summary> |
| 359 | /// Options for the TensorRT provider that are passed to SessionOptionsAppendExecutionProvider_TensorRT |
| 360 | /// </summary> |
| 361 | typedef struct OrtTensorRTProviderOptions { |
| 362 | int device_id; // cuda device id. |
| 363 | int has_user_compute_stream; // indicator of user specified CUDA compute stream. |
| 364 | void* user_compute_stream; // user specified CUDA compute stream. |
| 365 | int trt_max_partition_iterations; // maximum iterations for TensorRT parser to get capability |
| 366 | int trt_min_subgraph_size; // minimum size of TensorRT subgraphs |
| 367 | size_t trt_max_workspace_size; // maximum workspace size for TensorRT. |
| 368 | int trt_fp16_enable; // enable TensorRT FP16 precision. Default 0 = false, nonzero = true |
| 369 | int trt_int8_enable; // enable TensorRT INT8 precision. Default 0 = false, nonzero = true |
| 370 | const char* trt_int8_calibration_table_name; // TensorRT INT8 calibration table name. |
| 371 | int trt_int8_use_native_calibration_table; // use native TensorRT generated calibration table. Default 0 = false, nonzero = true |
| 372 | int trt_dla_enable; // enable DLA. Default 0 = false, nonzero = true |
| 373 | int trt_dla_core; // DLA core number. Default 0 |
| 374 | int trt_dump_subgraphs; // dump TRT subgraph. Default 0 = false, nonzero = true |
| 375 | int trt_engine_cache_enable; // enable engine caching. Default 0 = false, nonzero = true |
| 376 | const char* trt_engine_cache_path; // specify engine cache path |
| 377 | int trt_engine_decryption_enable; // enable engine decryption. Default 0 = false, nonzero = true |
| 378 | const char* trt_engine_decryption_lib_path; // specify engine decryption library path |
| 379 | int trt_force_sequential_engine_build; // force building TensorRT engine sequentially. Default 0 = false, nonzero = true |
| 380 | } OrtTensorRTProviderOptions; |
| 381 | |
| 382 | /// <summary> |
| 383 | /// Options for the OpenVINO provider that are passed to SessionOptionsAppendExecutionProvider_OpenVINO |
| 384 | /// </summary> |
| 385 | typedef struct OrtOpenVINOProviderOptions { |
| 386 | #ifdef __cplusplus |
| 387 | OrtOpenVINOProviderOptions() : device_type{}, enable_vpu_fast_compile{}, device_id{}, num_of_threads{}, use_compiled_network{}, blob_dump_path{} {} |
| 388 | #endif |
| 389 | const char* device_type; // CPU_FP32, GPU_FP32, GPU_FP16, MYRIAD_FP16, VAD-M_FP16 or VAD-F_FP32 |
| 390 | unsigned char enable_vpu_fast_compile; // 0 = false, nonzero = true |
| 391 | const char* device_id; |
| 392 | size_t num_of_threads; // 0 uses default number of threads |
| 393 | unsigned char use_compiled_network; // 0 = false, nonzero = true |
| 394 | const char* blob_dump_path; // path is set to empty by default |
| 395 | } OrtOpenVINOProviderOptions; |
| 396 | |
| 397 | struct OrtApi; |
| 398 | typedef struct OrtApi OrtApi; |
| 399 | |
| 400 | struct OrtApiBase { |
| 401 | const OrtApi*(ORT_API_CALL* GetApi)(uint32_t version)NO_EXCEPTION; // Pass in ORT_API_VERSION |
| 402 | // nullptr will be returned if the version is unsupported, for example when using a runtime older than this header file |
| 403 | |
| 404 | const char*(ORT_API_CALL* GetVersionString)(void)NO_EXCEPTION; |
| 405 | }; |
| 406 | typedef struct OrtApiBase OrtApiBase; |
| 407 | |
| 408 | ORT_EXPORT const OrtApiBase* ORT_API_CALL OrtGetApiBase(void) NO_EXCEPTION; |
| 409 | |
| 410 | struct OrtApi { |
| 411 | /** |
| 412 | * \param msg A null-terminated string. Its content will be copied into the newly created OrtStatus |
| 413 | */ |
| 414 | OrtStatus*(ORT_API_CALL* CreateStatus)(OrtErrorCode code, _In_ const char* msg)NO_EXCEPTION ORT_ALL_ARGS_NONNULL; |
| 415 | |
| 416 | OrtErrorCode(ORT_API_CALL* GetErrorCode)(_In_ const OrtStatus* status) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; |
| 417 | |
| 418 | /** |
| 419 | * \param status must not be NULL |
| 420 | * \return The error message inside the `status`. Do not free the returned value. |
| 421 | */ |
| 422 | const char*(ORT_API_CALL* GetErrorMessage)(_In_ const OrtStatus* status)NO_EXCEPTION ORT_ALL_ARGS_NONNULL; |
| 423 | |
| 424 | /** |
| 425 | * \param out Should be freed by `ReleaseEnv` after use |
| 426 | */ |
| 427 | ORT_API2_STATUS(CreateEnv, OrtLoggingLevel logging_level, _In_ const char* logid, _Outptr_ OrtEnv** out); |
| 428 | |
| 429 | /** |
| 430 | * \param out Should be freed by `ReleaseEnv` after use |
| 431 | */ |
| 432 | ORT_API2_STATUS(CreateEnvWithCustomLogger, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, |
| 433 | OrtLoggingLevel logging_level, _In_ const char* logid, _Outptr_ OrtEnv** out); |
| 434 | |
| 435 | // Platform telemetry events are on by default since they are lightweight. You can manually turn them off. |
| 436 | ORT_API2_STATUS(EnableTelemetryEvents, _In_ const OrtEnv* env); |
| 437 | ORT_API2_STATUS(DisableTelemetryEvents, _In_ const OrtEnv* env); |
| 438 | |
| 439 | // TODO: document the path separator convention? '/' vs '\' |
| 440 | // TODO: should specify the access characteristics of model_path. Is this read only during the |
| 441 | // execution of CreateSession, or does the OrtSession retain a handle to the file/directory |
| 442 | // and continue to access throughout the OrtSession lifetime? |
| 443 | // What sort of access is needed to model_path : read or read/write? |
| 444 | ORT_API2_STATUS(CreateSession, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, |
| 445 | _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out); |
| 446 | |
| 447 | ORT_API2_STATUS(CreateSessionFromArray, _In_ const OrtEnv* env, _In_ const void* model_data, size_t model_data_length, |
| 448 | _In_ const OrtSessionOptions* options, _Outptr_ OrtSession** out); |
| 449 | |
| 450 | ORT_API2_STATUS(Run, _Inout_ OrtSession* sess, _In_opt_ const OrtRunOptions* run_options, |
| 451 | _In_reads_(input_len) const char* const* input_names, |
| 452 | _In_reads_(input_len) const OrtValue* const* input, size_t input_len, |
| 453 | _In_reads_(output_names_len) const char* const* output_names1, size_t output_names_len, |
| 454 | _Inout_updates_all_(output_names_len) OrtValue** output); |
| 455 | |
| 456 | /** |
| 457 | * \return A pointer of the newly created object. The pointer should be freed by ReleaseSessionOptions after use |
| 458 | */ |
| 459 | ORT_API2_STATUS(CreateSessionOptions, _Outptr_ OrtSessionOptions** options); |
| 460 | |
| 461 | // Set filepath to save optimized model after graph level transformations. |
| 462 | ORT_API2_STATUS(SetOptimizedModelFilePath, _Inout_ OrtSessionOptions* options, |
| 463 | _In_ const ORTCHAR_T* optimized_model_filepath); |
| 464 | |
| 465 | // create a copy of an existing OrtSessionOptions |
| 466 | ORT_API2_STATUS(CloneSessionOptions, _In_ const OrtSessionOptions* in_options, |
| 467 | _Outptr_ OrtSessionOptions** out_options); |
| 468 | |
| 469 | // Controls whether you want to execute operators in your graph sequentially or in parallel. Usually when the model |
| 470 | // has many branches, setting this option to ExecutionMode.ORT_PARALLEL will give you better performance. |
| 471 | // See [docs/ONNX_Runtime_Perf_Tuning.md] for more details. |
| 472 | ORT_API2_STATUS(SetSessionExecutionMode, _Inout_ OrtSessionOptions* options, ExecutionMode execution_mode); |
| 473 | |
| 474 | // Enable profiling for this session. |
| 475 | ORT_API2_STATUS(EnableProfiling, _Inout_ OrtSessionOptions* options, _In_ const ORTCHAR_T* profile_file_prefix); |
| 476 | ORT_API2_STATUS(DisableProfiling, _Inout_ OrtSessionOptions* options); |
| 477 | |
| 478 | // Enable the memory pattern optimization. |
| 479 | // The idea is if the input shapes are the same, we could trace the internal memory allocation |
| 480 | // and generate a memory pattern for future request. So next time we could just do one allocation |
| 481 | // with a big chunk for all the internal memory allocation. |
| 482 | // Note: memory pattern optimization is only available when SequentialExecution enabled. |
| 483 | ORT_API2_STATUS(EnableMemPattern, _Inout_ OrtSessionOptions* options); |
| 484 | ORT_API2_STATUS(DisableMemPattern, _Inout_ OrtSessionOptions* options); |
| 485 | |
| 486 | // Enable the memory arena on CPU |
| 487 | // Arena may pre-allocate memory for future usage. |
| 488 | // set this option to false if you don't want it. |
| 489 | ORT_API2_STATUS(EnableCpuMemArena, _Inout_ OrtSessionOptions* options); |
| 490 | ORT_API2_STATUS(DisableCpuMemArena, _Inout_ OrtSessionOptions* options); |
| 491 | |
| 492 | // < logger id to use for session output |
| 493 | ORT_API2_STATUS(SetSessionLogId, _Inout_ OrtSessionOptions* options, const char* logid); |
| 494 | |
| 495 | // < applies to session load, initialization, etc |
| 496 | ORT_API2_STATUS(SetSessionLogVerbosityLevel, _Inout_ OrtSessionOptions* options, int session_log_verbosity_level); |
| 497 | ORT_API2_STATUS(SetSessionLogSeverityLevel, _Inout_ OrtSessionOptions* options, int session_log_severity_level); |
| 498 | |
| 499 | ORT_API2_STATUS(SetSessionGraphOptimizationLevel, _Inout_ OrtSessionOptions* options, |
| 500 | GraphOptimizationLevel graph_optimization_level); |
| 501 | |
| 502 | // Sets the number of threads used to parallelize the execution within nodes |
| 503 | // A value of 0 means ORT will pick a default |
| 504 | // Note: If you've built ORT with OpenMP, this API has no effect on the number of threads used. In this case |
| 505 | // use the OpenMP env variables to configure the number of intra op num threads. |
| 506 | ORT_API2_STATUS(SetIntraOpNumThreads, _Inout_ OrtSessionOptions* options, int intra_op_num_threads); |
| 507 | |
| 508 | // Sets the number of threads used to parallelize the execution of the graph (across nodes) |
| 509 | // If sequential execution is enabled this value is ignored |
| 510 | // A value of 0 means ORT will pick a default |
| 511 | ORT_API2_STATUS(SetInterOpNumThreads, _Inout_ OrtSessionOptions* options, int inter_op_num_threads); |
| 512 | |
| 513 | /* |
| 514 | Create a custom op domain. After all sessions using it are released, call ReleaseCustomOpDomain |
| 515 | */ |
| 516 | ORT_API2_STATUS(CreateCustomOpDomain, _In_ const char* domain, _Outptr_ OrtCustomOpDomain** out); |
| 517 | |
| 518 | /* |
| 519 | * Add custom ops to the OrtCustomOpDomain |
| 520 | * Note: The OrtCustomOp* pointer must remain valid until the OrtCustomOpDomain using it is released |
| 521 | */ |
| 522 | ORT_API2_STATUS(CustomOpDomain_Add, _Inout_ OrtCustomOpDomain* custom_op_domain, _In_ const OrtCustomOp* op); |
| 523 | |
| 524 | /* |
| 525 | * Add a custom op domain to the OrtSessionOptions |
| 526 | * Note: The OrtCustomOpDomain* must not be deleted until the sessions using it are released |
| 527 | */ |
| 528 | ORT_API2_STATUS(AddCustomOpDomain, _Inout_ OrtSessionOptions* options, _In_ OrtCustomOpDomain* custom_op_domain); |
| 529 | |
| 530 | /* |
| 531 | * Loads a DLL named 'library_path' and looks for this entry point: |
| 532 | * OrtStatus* RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); |
| 533 | * It then passes in the provided session options to this function along with the api base. |
| 534 | * The handle to the loaded library is returned in library_handle. It can be freed by the caller after all sessions using the passed in |
| 535 | * session options are destroyed, or if an error occurs and it is non null. |
| 536 | */ |
| 537 | ORT_API2_STATUS(RegisterCustomOpsLibrary, _Inout_ OrtSessionOptions* options, _In_ const char* library_path, |
| 538 | void** library_handle); |
| 539 | |
| 540 | /** |
| 541 | * To use additional providers, you must build ORT with the extra providers enabled. Then call one of these |
| 542 | * functions to enable them in the session: |
| 543 | * OrtSessionOptionsAppendExecutionProvider_CPU |
| 544 | * OrtSessionOptionsAppendExecutionProvider_CUDA |
| 545 | * OrtSessionOptionsAppendExecutionProvider_<remaining providers...> |
| 546 | * The order they are called indicates the preference order as well. In other words call this method |
| 547 | * on your most preferred execution provider first followed by the less preferred ones. |
| 548 | * If none are called Ort will use its internal CPU execution provider. |
| 549 | */ |
| 550 | |
| 551 | ORT_API2_STATUS(SessionGetInputCount, _In_ const OrtSession* sess, _Out_ size_t* out); |
| 552 | ORT_API2_STATUS(SessionGetOutputCount, _In_ const OrtSession* sess, _Out_ size_t* out); |
| 553 | ORT_API2_STATUS(SessionGetOverridableInitializerCount, _In_ const OrtSession* sess, _Out_ size_t* out); |
| 554 | |
| 555 | /** |
| 556 | * \param out should be freed by ReleaseTypeInfo after use |
| 557 | */ |
| 558 | ORT_API2_STATUS(SessionGetInputTypeInfo, _In_ const OrtSession* sess, size_t index, _Outptr_ OrtTypeInfo** type_info); |
| 559 | |
| 560 | /** |
| 561 | * \param out should be freed by ReleaseTypeInfo after use |
| 562 | */ |
| 563 | ORT_API2_STATUS(SessionGetOutputTypeInfo, _In_ const OrtSession* sess, size_t index, |
| 564 | _Outptr_ OrtTypeInfo** type_info); |
| 565 | |
| 566 | /** |
| 567 | * \param out should be freed by ReleaseTypeInfo after use |
| 568 | */ |
| 569 | ORT_API2_STATUS(SessionGetOverridableInitializerTypeInfo, _In_ const OrtSession* sess, size_t index, |
| 570 | _Outptr_ OrtTypeInfo** type_info); |
| 571 | |
| 572 | /** |
| 573 | * \param value is set to a null terminated UTF-8 encoded string allocated using 'allocator'. |
| 574 | * The caller is responsible for freeing it. |
| 575 | */ |
| 576 | ORT_API2_STATUS(SessionGetInputName, _In_ const OrtSession* sess, size_t index, _Inout_ OrtAllocator* allocator, |
| 577 | _Outptr_ char** value); |
| 578 | ORT_API2_STATUS(SessionGetOutputName, _In_ const OrtSession* sess, size_t index, _Inout_ OrtAllocator* allocator, |
| 579 | _Outptr_ char** value); |
| 580 | ORT_API2_STATUS(SessionGetOverridableInitializerName, _In_ const OrtSession* sess, size_t index, |
| 581 | _Inout_ OrtAllocator* allocator, _Outptr_ char** value); |
| 582 | |
| 583 | /** |
| 584 | * \return A pointer to the newly created object. The pointer should be freed by ReleaseRunOptions after use |
| 585 | */ |
| 586 | ORT_API2_STATUS(CreateRunOptions, _Outptr_ OrtRunOptions** out); |
| 587 | |
| 588 | ORT_API2_STATUS(RunOptionsSetRunLogVerbosityLevel, _Inout_ OrtRunOptions* options, int value); |
| 589 | ORT_API2_STATUS(RunOptionsSetRunLogSeverityLevel, _Inout_ OrtRunOptions* options, int value); |
| 590 | ORT_API2_STATUS(RunOptionsSetRunTag, _Inout_ OrtRunOptions*, _In_ const char* run_tag); |
| 591 | |
| 592 | ORT_API2_STATUS(RunOptionsGetRunLogVerbosityLevel, _In_ const OrtRunOptions* options, _Out_ int* out); |
| 593 | ORT_API2_STATUS(RunOptionsGetRunLogSeverityLevel, _In_ const OrtRunOptions* options, _Out_ int* out); |
| 594 | ORT_API2_STATUS(RunOptionsGetRunTag, _In_ const OrtRunOptions*, _Out_ const char** out); |
| 595 | |
| 596 | // Set a flag so that ALL incomplete OrtRun calls that are using this instance of OrtRunOptions |
| 597 | // will exit as soon as possible. |
| 598 | ORT_API2_STATUS(RunOptionsSetTerminate, _Inout_ OrtRunOptions* options); |
| 599 | // Unset the terminate flag to enable this OrtRunOptions instance being used in new OrtRun calls. |
| 600 | ORT_API2_STATUS(RunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options); |
| 601 | |
| 602 | /** |
| 603 | * Create a tensor from an allocator. ReleaseValue will also release the buffer inside the output value |
| 604 | * \param out Should be freed by calling ReleaseValue |
| 605 | * \param type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx |
| 606 | */ |
| 607 | ORT_API2_STATUS(CreateTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* shape, size_t shape_len, |
| 608 | ONNXTensorElementDataType type, _Outptr_ OrtValue** out); |
| 609 | |
| 610 | /** |
| 611 | * Create a tensor with user's buffer. You can fill the buffer either before calling this function or after. |
| 612 | * p_data is owned by caller. ReleaseValue won't release p_data. |
| 613 | * \param out Should be freed by calling ReleaseValue |
| 614 | */ |
| 615 | ORT_API2_STATUS(CreateTensorWithDataAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data, |
| 616 | size_t p_data_len, _In_ const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type, |
| 617 | _Outptr_ OrtValue** out); |
| 618 | |
| 619 | /** |
| 620 | * \Sets *out to 1 iff an OrtValue is a tensor, 0 otherwise |
| 621 | */ |
| 622 | ORT_API2_STATUS(IsTensor, _In_ const OrtValue* value, _Out_ int* out); |
| 623 | |
| 624 | // This function doesn't work with string tensor |
| 625 | // this is a no-copy method whose pointer is only valid until the backing OrtValue is free'd. |
| 626 | ORT_API2_STATUS(GetTensorMutableData, _Inout_ OrtValue* value, _Outptr_ void** out); |
| 627 | |
| 628 | /** |
| 629 | * \param value A tensor created from OrtCreateTensor... function. |
| 630 | * \param s each A string array. Each string in this array must be null terminated. |
| 631 | * \param s_len length of s |
| 632 | */ |
| 633 | ORT_API2_STATUS(FillStringTensor, _Inout_ OrtValue* value, _In_ const char* const* s, size_t s_len); |
| 634 | |
| 635 | /** |
| 636 | * Obtain a total length of strings contained within a tensor. |
| 637 | * For sparse tensors it returns the total length of values (nnz) strings. |
| 638 | * \param[in] value A tensor created from OrtCreateTensor... function. |
| 639 | * \param[out] len total data length, not including the trailing '\0' chars. |
| 640 | */ |
| 641 | ORT_API2_STATUS(GetStringTensorDataLength, _In_ const OrtValue* value, _Out_ size_t* len); |
| 642 | |
| 643 | /** |
| 644 | * This API returns all of of UTF-8 encoded strings that are contained within a tensor |
| 645 | * or in non-empty values of a sparse tensor in one single buffer. Use offsets to calculate |
| 646 | * the length of each string such as len[i] = offsets[i + 1] - offsets[i] except the last |
| 647 | * string for which the length is calculated as total_len - offset[i]. |
| 648 | * |
| 649 | * \param[in] value A tensor created from OrtCreateTensor... API or a sparse tensor |
| 650 | * created with OrtCreateSparseTensor... API. |
| 651 | * \param[in,out] s string contents. Each string is NOT null-terminated. |
| 652 | * \param[in] s_len total data length, get it from OrtGetStringTensorDataLength |
| 653 | * \param[in,out] offsets pointer to a preallocated buffer where offsets for each of the string |
| 654 | * element are returned. The number of offsets must match the number of string elements. |
| 655 | * \param[in] offsets_len number of offsets expected in the buffer. |
| 656 | */ |
| 657 | ORT_API2_STATUS(GetStringTensorContent, _In_ const OrtValue* value, _Out_writes_bytes_all_(s_len) void* s, |
| 658 | size_t s_len, _Out_writes_all_(offsets_len) size_t* offsets, size_t offsets_len); |
| 659 | |
| 660 | /** Retrieves OrtTensorTypeAndShapeInfo part of the OrtTypeInfo |
| 661 | * |
| 662 | * \param[in] type_info |
| 663 | * \param[out] out a returned ptr. Don't free the 'out' value, it is owned by type_info |
| 664 | */ |
| 665 | ORT_API2_STATUS(CastTypeInfoToTensorInfo, _In_ const OrtTypeInfo* type_info, |
| 666 | _Outptr_result_maybenull_ const OrtTensorTypeAndShapeInfo** out); |
| 667 | |
| 668 | /** |
| 669 | * Return OnnxType from OrtTypeInfo |
| 670 | */ |
| 671 | ORT_API2_STATUS(GetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo*, _Out_ enum ONNXType* out); |
| 672 | |
| 673 | /** |
| 674 | * The 'out' value should be released by calling ReleaseTensorTypeAndShapeInfo |
| 675 | */ |
| 676 | ORT_API2_STATUS(CreateTensorTypeAndShapeInfo, _Outptr_ OrtTensorTypeAndShapeInfo** out); |
| 677 | |
| 678 | ORT_API2_STATUS(SetTensorElementType, _Inout_ OrtTensorTypeAndShapeInfo*, enum ONNXTensorElementDataType type); |
| 679 | |
| 680 | /** |
| 681 | * \param info Created from CreateTensorTypeAndShapeInfo() function |
| 682 | * \param dim_values An array with length of `dim_count`. Its elements can contain negative values. |
| 683 | * \param dim_count length of dim_values |
| 684 | */ |
| 685 | ORT_API2_STATUS(SetDimensions, OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count); |
| 686 | |
| 687 | ORT_API2_STATUS(GetTensorElementType, _In_ const OrtTensorTypeAndShapeInfo*, |
| 688 | _Out_ enum ONNXTensorElementDataType* out); |
| 689 | ORT_API2_STATUS(GetDimensionsCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out); |
| 690 | ORT_API2_STATUS(GetDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values, |
| 691 | size_t dim_values_length); |
| 692 | ORT_API2_STATUS(GetSymbolicDimensions, _In_ const OrtTensorTypeAndShapeInfo* info, |
| 693 | _Out_writes_all_(dim_params_length) const char* dim_params[], size_t dim_params_length); |
| 694 | |
| 695 | /** |
| 696 | * Return the number of elements specified by the tensor shape. |
| 697 | * Return a negative value if unknown (i.e., any dimension is negative.) |
| 698 | * e.g. |
| 699 | * [] -> 1 |
| 700 | * [1,3,4] -> 12 |
| 701 | * [2,0,4] -> 0 |
| 702 | * [-1,3,4] -> -1 |
| 703 | */ |
| 704 | ORT_API2_STATUS(GetTensorShapeElementCount, _In_ const OrtTensorTypeAndShapeInfo* info, _Out_ size_t* out); |
| 705 | |
| 706 | /** |
| 707 | * Returns data type and shape iff OrtValue contains a Tensor or a SparseTensor. |
| 708 | * For sparse tensors it returns a dense shape of the tensor. |
| 709 | * |
| 710 | * \param[in] value OrtValue that contains tensor or a sparse tensor |
| 711 | * \param[out] out Should be freed by ReleaseTensorTypeAndShapeInfo after use |
| 712 | */ |
| 713 | ORT_API2_STATUS(GetTensorTypeAndShape, _In_ const OrtValue* value, _Outptr_ OrtTensorTypeAndShapeInfo** out); |
| 714 | |
| 715 | /** |
| 716 | * Get the type information of an OrtValue. API works for tensors and sparse tensors. |
| 717 | * |
| 718 | * \param[in] value |
| 719 | * \param[in,out] out The returned value should be freed by ReleaseTypeInfo after use |
| 720 | */ |
| 721 | ORT_API2_STATUS(GetTypeInfo, _In_ const OrtValue* value, _Outptr_result_maybenull_ OrtTypeInfo** out); |
| 722 | |
| 723 | ORT_API2_STATUS(GetValueType, _In_ const OrtValue* value, _Out_ enum ONNXType* out); |
| 724 | |
| 725 | /** |
| 726 | * Creates an instance of OrtMemoryInfo. It must be freed by ReleaseMemoryInfo after use. |
| 727 | * This may describe one of the existing ORT allocator types OR a custom allocator. |
| 728 | * |
| 729 | * \param[in] name such as "cpu", "gpu" |
| 730 | * \param[in] type one of the enum values |
| 731 | * \param[in] device ID. For GPU gpu id. |
| 732 | * \param[in] mem_type. Memory type enum value. |
| 733 | */ |
| 734 | ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name, enum OrtAllocatorType type, int id, |
| 735 | enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out); |
| 736 | |
| 737 | /** |
| 738 | * Convenience function for special case of CreateMemoryInfo, for the CPU allocator. Uses name = "Cpu" and id = 0. |
| 739 | */ |
| 740 | ORT_API2_STATUS(CreateCpuMemoryInfo, enum OrtAllocatorType type, enum OrtMemType mem_type1, |
| 741 | _Outptr_ OrtMemoryInfo** out); |
| 742 | |
| 743 | /** |
| 744 | * Test if two memory info are equal |
| 745 | * \Sets 'out' to 0 if equal, -1 if not equal |
| 746 | */ |
| 747 | ORT_API2_STATUS(CompareMemoryInfo, _In_ const OrtMemoryInfo* info1, _In_ const OrtMemoryInfo* info2, _Out_ int* out); |
| 748 | |
| 749 | /** |
| 750 | * Do not free the returned value |
| 751 | */ |
| 752 | ORT_API2_STATUS(MemoryInfoGetName, _In_ const OrtMemoryInfo* ptr, _Out_ const char** out); |
| 753 | ORT_API2_STATUS(MemoryInfoGetId, _In_ const OrtMemoryInfo* ptr, _Out_ int* out); |
| 754 | ORT_API2_STATUS(MemoryInfoGetMemType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtMemType* out); |
| 755 | ORT_API2_STATUS(MemoryInfoGetType, _In_ const OrtMemoryInfo* ptr, _Out_ OrtAllocatorType* out); |
| 756 | |
| 757 | ORT_API2_STATUS(AllocatorAlloc, _Inout_ OrtAllocator* ptr, size_t size, _Outptr_ void** out); |
| 758 | ORT_API2_STATUS(AllocatorFree, _Inout_ OrtAllocator* ptr, void* p); |
| 759 | ORT_API2_STATUS(AllocatorGetInfo, _In_ const OrtAllocator* ptr, _Outptr_ const struct OrtMemoryInfo** out); |
| 760 | |
| 761 | // This API returns a CPU non-arena based allocator |
| 762 | // The returned pointer doesn't have to be freed. |
| 763 | // Always returns the same instance on every invocation. |
| 764 | ORT_API2_STATUS(GetAllocatorWithDefaultOptions, _Outptr_ OrtAllocator** out); |
| 765 | |
| 766 | // Override symbolic dimensions (by specific denotation strings) with actual values if known at session initialization time to enable |
| 767 | // optimizations that can take advantage of fixed values (such as memory planning, etc) |
| 768 | ORT_API2_STATUS(AddFreeDimensionOverride, _Inout_ OrtSessionOptions* options, _In_ const char* dim_denotation, |
| 769 | _In_ int64_t dim_value); |
| 770 | |
| 771 | /** |
| 772 | * APIs to support non-tensor types - map and sequence. |
| 773 | * Currently only the following types are supported |
| 774 | * Note: the following types should be kept in sync with data_types.h |
| 775 | * Map types |
| 776 | * ========= |
| 777 | * std::map<std::string, std::string> |
| 778 | * std::map<std::string, int64_t> |
| 779 | * std::map<std::string, float> |
| 780 | * std::map<std::string, double> |
| 781 | * std::map<int64_t, std::string> |
| 782 | * std::map<int64_t, int64_t> |
| 783 | * std::map<int64_t, float> |
| 784 | * std::map<int64_t, double> |
| 785 | * |
| 786 | * Sequence types |
| 787 | * ============== |
| 788 | * std::vector<std::string> |
| 789 | * std::vector<int64_t> |
| 790 | * std::vector<float> |
| 791 | * std::vector<double> |
| 792 | * std::vector<std::map<std::string, float>> |
| 793 | * std::vector<std::map<int64_t, float> |
| 794 | */ |
| 795 | |
| 796 | /** |
| 797 | * If input OrtValue represents a map, you need to retrieve the keys and values |
| 798 | * separately. Use index=0 to retrieve keys and index=1 to retrieve values. |
| 799 | * If input OrtValue represents a sequence, use index to retrieve the index'th element |
| 800 | * of the sequence. |
| 801 | */ |
| 802 | ORT_API2_STATUS(GetValue, _In_ const OrtValue* value, int index, _Inout_ OrtAllocator* allocator, |
| 803 | _Outptr_ OrtValue** out); |
| 804 | |
| 805 | /** |
| 806 | * Returns 2 for type map and N for sequence where N is the number of elements |
| 807 | * in the sequence. |
| 808 | */ |
| 809 | ORT_API2_STATUS(GetValueCount, _In_ const OrtValue* value, _Out_ size_t* out); |
| 810 | |
| 811 | /** |
| 812 | * To construct a map, use num_values = 2 and 'in' should be an arrary of 2 OrtValues |
| 813 | * representing keys and values. |
| 814 | * To construct a sequence, use num_values = N where N is the number of the elements in the |
| 815 | * sequence. 'in' should be an arrary of N OrtValues. |
| 816 | * \value_type should be either map or sequence. |
| 817 | */ |
| 818 | ORT_API2_STATUS(CreateValue, _In_reads_(num_values) const OrtValue* const* in, size_t num_values, |
| 819 | enum ONNXType value_type, _Outptr_ OrtValue** out); |
| 820 | |
| 821 | /** |
| 822 | * Construct OrtValue that contains a value of non-standard type created for |
| 823 | * experiments or while awaiting standardization. OrtValue in this case would contain |
| 824 | * an internal representation of the Opaque type. Opaque types are distinguished between |
| 825 | * each other by two strings 1) domain and 2) type name. The combination of the two |
| 826 | * must be unique, so the type representation is properly identified internally. The combination |
| 827 | * must be properly registered from within ORT at both compile/run time or by another API. |
| 828 | * |
| 829 | * To construct the OrtValue pass domain and type names, also a pointer to a data container |
| 830 | * the type of which must be know to both ORT and the client program. That data container may or may |
| 831 | * not match the internal representation of the Opaque type. The sizeof(data_container) is passed for |
| 832 | * verification purposes. |
| 833 | * |
| 834 | * \domain_name - domain name for the Opaque type, null terminated. |
| 835 | * \type_name - type name for the Opaque type, null terminated. |
| 836 | * \data_contianer - data to populate OrtValue |
| 837 | * \data_container_size - sizeof() of the data container. Must match the sizeof() of the expected |
| 838 | * data_container size internally. |
| 839 | */ |
| 840 | ORT_API2_STATUS(CreateOpaqueValue, _In_z_ const char* domain_name, _In_z_ const char* type_name, |
| 841 | _In_ const void* data_container, size_t data_container_size, _Outptr_ OrtValue** out); |
| 842 | |
| 843 | /** |
| 844 | * Fetch data from an OrtValue that contains a value of non-standard type created for |
| 845 | * experiments or while awaiting standardization. |
| 846 | * \domain_name - domain name for the Opaque type, null terminated. |
| 847 | * \type_name - type name for the Opaque type, null terminated. |
| 848 | * \data_contianer - data to populate OrtValue |
| 849 | * \data_container_size - sizeof() of the data container. Must match the sizeof() of the expected |
| 850 | * data_container size internally. |
| 851 | */ |
| 852 | |
| 853 | ORT_API2_STATUS(GetOpaqueValue, _In_ const char* domain_name, _In_ const char* type_name, _In_ const OrtValue* in, |
| 854 | _Out_ void* data_container, size_t data_container_size); |
| 855 | |
| 856 | /** |
| 857 | * Fetch a float stored as an attribute in the graph node |
| 858 | * \info - OrtKernelInfo instance |
| 859 | * \name - name of the attribute to be parsed |
| 860 | * \out - pointer to memory where the attribute is to be stored |
| 861 | */ |
| 862 | ORT_API2_STATUS(KernelInfoGetAttribute_float, _In_ const OrtKernelInfo* info, _In_ const char* name, |
| 863 | _Out_ float* out); |
| 864 | |
| 865 | /** |
| 866 | * Fetch a 64-bit int stored as an attribute in the graph node |
| 867 | * \info - OrtKernelInfo instance |
| 868 | * \name - name of the attribute to be parsed |
| 869 | * \out - pointer to memory where the attribute is to be stored |
| 870 | */ |
| 871 | ORT_API2_STATUS(KernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* info, _In_ const char* name, |
| 872 | _Out_ int64_t* out); |
| 873 | /** |
| 874 | * Fetch a string stored as an attribute in the graph node |
| 875 | * \info - OrtKernelInfo instance |
| 876 | * \name - name of the attribute to be parsed |
| 877 | * \out - pointer to memory where the attribute's contents are to be stored |
| 878 | * \size - actual size of string attribute |
| 879 | * (If `out` is nullptr, the value of `size` is set to the true size of the string |
| 880 | attribute, and a success status is returned. |
| 881 | |
| 882 | If the `size` parameter is greater than or equal to the actual string attribute's size, |
| 883 | the value of `size` is set to the true size of the string attribute, the provided memory |
| 884 | is filled with the attribute's contents, and a success status is returned. |
| 885 | |
| 886 | If the `size` parameter is lesser than the actual string attribute's size and `out` |
| 887 | is not nullptr, the value of `size` is set to the true size of the string attribute |
| 888 | and a failure status is returned.) |
| 889 | */ |
| 890 | ORT_API2_STATUS(KernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info, _In_ const char* name, _Out_ char* out, |
| 891 | _Inout_ size_t* size); |
| 892 | |
| 893 | ORT_API2_STATUS(KernelContext_GetInputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out); |
| 894 | ORT_API2_STATUS(KernelContext_GetOutputCount, _In_ const OrtKernelContext* context, _Out_ size_t* out); |
| 895 | ORT_API2_STATUS(KernelContext_GetInput, _In_ const OrtKernelContext* context, _In_ size_t index, |
| 896 | _Out_ const OrtValue** out); |
| 897 | ORT_API2_STATUS(KernelContext_GetOutput, _Inout_ OrtKernelContext* context, _In_ size_t index, |
| 898 | _In_ const int64_t* dim_values, size_t dim_count, _Outptr_ OrtValue** out); |
| 899 | |
| 900 | ORT_CLASS_RELEASE(Env); |
| 901 | ORT_CLASS_RELEASE(Status); // nullptr for Status* indicates success |
| 902 | ORT_CLASS_RELEASE(MemoryInfo); |
| 903 | ORT_CLASS_RELEASE(Session); //Don't call ReleaseSession from Dllmain (because session owns a thread pool) |
| 904 | ORT_CLASS_RELEASE(Value); |
| 905 | ORT_CLASS_RELEASE(RunOptions); |
| 906 | ORT_CLASS_RELEASE(TypeInfo); |
| 907 | ORT_CLASS_RELEASE(TensorTypeAndShapeInfo); |
| 908 | ORT_CLASS_RELEASE(SessionOptions); |
| 909 | ORT_CLASS_RELEASE(CustomOpDomain); |
| 910 | |
| 911 | // End of Version 1 - DO NOT MODIFY ABOVE (see above text for more information) |
| 912 | |
| 913 | // Version 2 - In development, feel free to add/remove/rearrange here |
| 914 | |
| 915 | /** |
| 916 | * GetDenotationFromTypeInfo |
| 917 | * This api augments OrtTypeInfo to return denotations on the type. |
| 918 | * This is used by WinML to determine if an input/output is intended to be an Image or a Tensor. |
| 919 | */ |
| 920 | ORT_API2_STATUS(GetDenotationFromTypeInfo, _In_ const OrtTypeInfo*, _Out_ const char** const denotation, |
| 921 | _Out_ size_t* len); |
| 922 | |
| 923 | // OrtTypeInfo Casting methods |
| 924 | |
| 925 | /** |
| 926 | * CastTypeInfoToMapTypeInfo |
| 927 | * This api augments OrtTypeInfo to return an OrtMapTypeInfo when the type is a map. |
| 928 | * The OrtMapTypeInfo has additional information about the map's key type and value type. |
| 929 | * This is used by WinML to support model reflection APIs. |
| 930 | * This is used by WinML to support model reflection APIs. |
| 931 | * |
| 932 | * Don't free the 'out' value |
| 933 | */ |
| 934 | ORT_API2_STATUS(CastTypeInfoToMapTypeInfo, _In_ const OrtTypeInfo* type_info, |
| 935 | _Outptr_result_maybenull_ const OrtMapTypeInfo** out); |
| 936 | |
| 937 | /** |
| 938 | * CastTypeInfoToSequenceTypeInfo |
| 939 | * This api augments OrtTypeInfo to return an OrtSequenceTypeInfo when the type is a sequence. |
| 940 | * The OrtSequenceTypeInfo has additional information about the sequence's element type. |
| 941 | * This is used by WinML to support model reflection APIs. |
| 942 | * |
| 943 | * Don't free the 'out' value |
| 944 | */ |
| 945 | ORT_API2_STATUS(CastTypeInfoToSequenceTypeInfo, _In_ const OrtTypeInfo* type_info, |
| 946 | _Outptr_result_maybenull_ const OrtSequenceTypeInfo** out); |
| 947 | |
| 948 | // OrtMapTypeInfo Accessors |
| 949 | |
| 950 | /** |
| 951 | * GetMapKeyType |
| 952 | * This api augments get the key type of a map. Key types are restricted to being scalar types and use ONNXTensorElementDataType. |
| 953 | * This is used by WinML to support model reflection APIs. |
| 954 | */ |
| 955 | ORT_API2_STATUS(GetMapKeyType, _In_ const OrtMapTypeInfo* map_type_info, _Out_ enum ONNXTensorElementDataType* out); |
| 956 | |
| 957 | /** |
| 958 | * GetMapValueType |
| 959 | * This api augments get the value type of a map. |
| 960 | */ |
| 961 | ORT_API2_STATUS(GetMapValueType, _In_ const OrtMapTypeInfo* map_type_info, _Outptr_ OrtTypeInfo** type_info); |
| 962 | |
| 963 | // OrtSequenceTypeInfo Accessors |
| 964 | |
| 965 | /** |
| 966 | * GetSequenceElementType |
| 967 | * This api augments get the element type of a sequence. |
| 968 | * This is used by WinML to support model reflection APIs. |
| 969 | */ |
| 970 | ORT_API2_STATUS(GetSequenceElementType, _In_ const OrtSequenceTypeInfo* sequence_type_info, |
| 971 | _Outptr_ OrtTypeInfo** type_info); |
| 972 | |
| 973 | ORT_CLASS_RELEASE(MapTypeInfo); |
| 974 | ORT_CLASS_RELEASE(SequenceTypeInfo); |
| 975 | |
| 976 | /** |
| 977 | * \param out is set to a null terminated string allocated using 'allocator'. The caller is responsible for freeing it. |
| 978 | * Profiling is turned ON automatically if enabled for the particular session by invoking EnableProfiling() |
| 979 | * on the SessionOptions instance used to create the session. |
| 980 | */ |
| 981 | ORT_API2_STATUS(SessionEndProfiling, _In_ OrtSession* sess, _Inout_ OrtAllocator* allocator, _Outptr_ char** out); |
| 982 | |
| 983 | /** |
| 984 | * \param out is a pointer to the newly created object. The pointer should be freed by calling ReleaseModelMetadata after use. |
| 985 | */ |
| 986 | ORT_API2_STATUS(SessionGetModelMetadata, _In_ const OrtSession* sess, _Outptr_ OrtModelMetadata** out); |
| 987 | |
| 988 | /** |
| 989 | * \param value is set to a null terminated string allocated using 'allocator'. The caller is responsible for freeing it. |
| 990 | */ |
| 991 | ORT_API2_STATUS(ModelMetadataGetProducerName, _In_ const OrtModelMetadata* model_metadata, |
| 992 | _Inout_ OrtAllocator* allocator, _Outptr_ char** value); |
| 993 | ORT_API2_STATUS(ModelMetadataGetGraphName, _In_ const OrtModelMetadata* model_metadata, |
| 994 | _Inout_ OrtAllocator* allocator, _Outptr_ char** value); |
| 995 | ORT_API2_STATUS(ModelMetadataGetDomain, _In_ const OrtModelMetadata* model_metadata, _Inout_ OrtAllocator* allocator, |
| 996 | _Outptr_ char** value); |
| 997 | ORT_API2_STATUS(ModelMetadataGetDescription, _In_ const OrtModelMetadata* model_metadata, |
| 998 | _Inout_ OrtAllocator* allocator, _Outptr_ char** value); |
| 999 | /** |
| 1000 | * \param value is set to a null terminated string allocated using 'allocator'. The caller is responsible for freeing it. |
| 1001 | * 'value' will be a nullptr if the given key is not found in the custom metadata map. |
| 1002 | */ |
| 1003 | ORT_API2_STATUS(ModelMetadataLookupCustomMetadataMap, _In_ const OrtModelMetadata* model_metadata, |
| 1004 | _Inout_ OrtAllocator* allocator, _In_ const char* key, _Outptr_result_maybenull_ char** value); |
| 1005 | |
| 1006 | ORT_API2_STATUS(ModelMetadataGetVersion, _In_ const OrtModelMetadata* model_metadata, _Out_ int64_t* value); |
| 1007 | |
| 1008 | ORT_CLASS_RELEASE(ModelMetadata); |
| 1009 | |
| 1010 | /* |
| 1011 | * Creates an environment with global threadpools that will be shared across sessions. |
| 1012 | * Use this in conjunction with DisablePerSessionThreads API or else the session will use |
| 1013 | * its own thread pools. |
| 1014 | */ |
| 1015 | ORT_API2_STATUS(CreateEnvWithGlobalThreadPools, OrtLoggingLevel logging_level, _In_ const char* logid, |
| 1016 | _In_ const OrtThreadingOptions* t_options, _Outptr_ OrtEnv** out); |
| 1017 | |
| 1018 | /* |
| 1019 | * Calling this API will make the session use the global threadpools shared across sessions. |
| 1020 | * This API should be used in conjunction with CreateEnvWithGlobalThreadPools API. |
| 1021 | */ |
| 1022 | ORT_API2_STATUS(DisablePerSessionThreads, _Inout_ OrtSessionOptions* options); |
| 1023 | |
| 1024 | ORT_API2_STATUS(CreateThreadingOptions, _Outptr_ OrtThreadingOptions** out); |
| 1025 | |
| 1026 | ORT_CLASS_RELEASE(ThreadingOptions); |
| 1027 | |
| 1028 | /** |
| 1029 | * \param num_keys contains the number of keys in the custom metadata map |
| 1030 | * \param keys is an array of null terminated strings (array count = num_keys) allocated using 'allocator'. |
| 1031 | * The caller is responsible for freeing each string and the pointer array. |
| 1032 | * 'keys' will be a nullptr if custom metadata map is empty. |
| 1033 | */ |
| 1034 | ORT_API2_STATUS(ModelMetadataGetCustomMetadataMapKeys, _In_ const OrtModelMetadata* model_metadata, |
| 1035 | _Inout_ OrtAllocator* allocator, _Outptr_result_buffer_maybenull_(*num_keys) char*** keys, _Out_ int64_t* num_keys); |
| 1036 | |
| 1037 | // Override symbolic dimensions (by specific name strings) with actual values |
| 1038 | // if known at session initialization time to enable optimizations that can |
| 1039 | // take advantage of fixed values (such as memory planning, etc) |
| 1040 | ORT_API2_STATUS(AddFreeDimensionOverrideByName, |
| 1041 | _Inout_ OrtSessionOptions* options, _In_ const char* dim_name, |
| 1042 | _In_ int64_t dim_value); |
| 1043 | |
| 1044 | /** |
| 1045 | * \param out_ptr will hold a pointer to the array of char * |
| 1046 | * representing available providers. |
| 1047 | * \param provider_length is a pointer to an int variable where |
| 1048 | * the number of available providers will be added. |
| 1049 | * The caller is responsible for freeing each char * and the pointer |
| 1050 | * array by calling ReleaseAvailableProviders(). |
| 1051 | */ |
| 1052 | ORT_API2_STATUS(GetAvailableProviders, _Outptr_ char*** out_ptr, |
| 1053 | _In_ int* provider_length); |
| 1054 | |
| 1055 | /** |
| 1056 | * \param ptr is the pointer to an array of available providers you |
| 1057 | * get after calling GetAvailableProviders(). |
| 1058 | * \param providers_length is the number of available providers. |
| 1059 | */ |
| 1060 | ORT_API2_STATUS(ReleaseAvailableProviders, _In_ char** ptr, |
| 1061 | _In_ int providers_length); |
| 1062 | |
| 1063 | /** |
| 1064 | * This API returns a length of string element at [index]. For sparse tensors |
| 1065 | * it will return a string element of sparse values. It is an error to request |
| 1066 | * an out of bounds element. |
| 1067 | * |
| 1068 | * \param[in] value - A tensor created from OrtCreateTensor... function. |
| 1069 | * \param[in] index - flat index of string tensor element, length of element at index will be returned. |
| 1070 | * \param[out] out - number of UTF-8 bytes that the string contains |
| 1071 | */ |
| 1072 | ORT_API2_STATUS(GetStringTensorElementLength, _In_ const OrtValue* value, size_t index, _Out_ size_t* out); |
| 1073 | |
| 1074 | /** |
| 1075 | * This API will return a copy UTF-8 data contained with a string element at the specified index. |
| 1076 | * For sparse tensors it would return a string element of sparse values. It is an error to request an out |
| 1077 | * of bounds element. |
| 1078 | * |
| 1079 | * \param s string element contents in UTF-8 encoding. The string is NOT null-terminated. |
| 1080 | * \param value A tensor created from OrtCreateTensor... function. |
| 1081 | * \param s_len element length, get it from OrtGetStringTensorElementLength. |
| 1082 | * \param index offset of element of tensor to return. |
| 1083 | */ |
| 1084 | ORT_API2_STATUS(GetStringTensorElement, _In_ const OrtValue* value, size_t s_len, size_t index, _Out_writes_bytes_all_(s_len) void* s); |
| 1085 | |
| 1086 | /** |
| 1087 | * \param value - A tensor created from OrtCreateTensor... function. |
| 1088 | * \param s - A null terminated UTF-8 encoded string. |
| 1089 | * \param index - index of string tensor element to fill |
| 1090 | */ |
| 1091 | ORT_API2_STATUS(FillStringTensorElement, _Inout_ OrtValue* value, _In_ const char* s, size_t index); |
| 1092 | |
| 1093 | /** |
| 1094 | * Set a single session configuration entry as a pair of strings |
| 1095 | * If a configuration with same key exists, this will overwrite the configuration with the given config_value |
| 1096 | * \param config_key A null terminated string representation of the config key |
| 1097 | * \param config_value A null terminated string representation of the config value |
| 1098 | * The config_key and the format of config_value are defined in onnxruntime_session_options_config_keys.h |
| 1099 | */ |
| 1100 | ORT_API2_STATUS(AddSessionConfigEntry, _Inout_ OrtSessionOptions* options, |
| 1101 | _In_z_ const char* config_key, _In_z_ const char* config_value); |
| 1102 | |
| 1103 | /** |
| 1104 | * This API returns an allocator bound to the provided OrtSession instance according |
| 1105 | * to the spec within mem_info if successful |
| 1106 | * \param sess valid OrtSession instance |
| 1107 | * \param mem_info - valid OrtMemoryInfo instance |
| 1108 | * \param - out a ptr to an instance of OrtAllocator which wraps the allocator |
| 1109 | bound to the OrtSession instance |
| 1110 | Freeing the returned pointer only frees the OrtAllocator instance and not |
| 1111 | the wrapped session owned allocator itself. |
| 1112 | * \return OrtStatus or nullptr if successful |
| 1113 | */ |
| 1114 | ORT_API2_STATUS(CreateAllocator, _In_ const OrtSession* sess, _In_ const OrtMemoryInfo* mem_info, |
| 1115 | _Outptr_ OrtAllocator** out); |
| 1116 | |
| 1117 | // Release instance of OrtAllocator obtained from CreateAllocator API |
| 1118 | ORT_CLASS_RELEASE(Allocator); |
| 1119 | |
| 1120 | ORT_API2_STATUS(RunWithBinding, _Inout_ OrtSession* sess, _In_ const OrtRunOptions* run_options, _In_ const OrtIoBinding* binding_ptr); |
| 1121 | |
| 1122 | // Creates an IoBinding instance that allows one to bind pre-allocated OrtValues |
| 1123 | // to input names. Thus if you want to use a raw on device buffer as input or output |
| 1124 | // you can avoid extra copy during runtime. |
| 1125 | ORT_API2_STATUS(CreateIoBinding, _Inout_ OrtSession* sess, _Outptr_ OrtIoBinding** out); |
| 1126 | |
| 1127 | // Release instance or OrtIoBinding obtained from CreateIoBinding API |
| 1128 | ORT_CLASS_RELEASE(IoBinding); |
| 1129 | |
| 1130 | /** |
| 1131 | * The function will bind the OrtValue to a specified input name. |
| 1132 | * The OrtValue must be a Tensor. ORT would use that value in place of input for the specified name. |
| 1133 | * \param binding_ptr - an instance of OrtIoBinding created by CreateIoBinding() |
| 1134 | * \param name - name for the model input |
| 1135 | * \param val_ptr - OrtValue of Tensor type. |
| 1136 | * \return OrtStatus instance on error which the caller is responsible to free or nullptr on success |
| 1137 | */ |
| 1138 | ORT_API2_STATUS(BindInput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr); |
| 1139 | |
| 1140 | /** |
| 1141 | * The function will bind the OrtValue to the specified output name. |
| 1142 | * The OrtValue must be a Tensor. ORT would use that value in place of output for the specified name. |
| 1143 | * |
| 1144 | * \param binding_ptr - an instance of OrtIoBinding created by CreateIoBinding() |
| 1145 | * \param name - name for the model output |
| 1146 | * \param val_ptr - OrtValue of Tensor type. |
| 1147 | * \return OrtStatus instance on error which the caller is responsible to free or nullptr on success |
| 1148 | */ |
| 1149 | ORT_API2_STATUS(BindOutput, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtValue* val_ptr); |
| 1150 | |
| 1151 | /** |
| 1152 | * The function will bind the OrtValue to a device which specification is contained within OrtMemoryInfo |
| 1153 | * You can either create an instance of OrtMemoryInfo with a device id or obtain one from the allocator that you are created/using |
| 1154 | * This is useful when one or more outputs have dynamic shapes and, it is hard to pre-allocated and bind a chunk of |
| 1155 | * memory within OrtValue ahead of time. |
| 1156 | * |
| 1157 | * \param binding_ptr - an instance of OrtIoBinding created by CreateIoBinding() |
| 1158 | * \param name - name for the model output |
| 1159 | * \param mem_info_ptr - OrtMemoryInfo |
| 1160 | * \return OrtStatus instance on error which the caller is responsible to free or nullptr on success |
| 1161 | */ |
| 1162 | ORT_API2_STATUS(BindOutputToDevice, _Inout_ OrtIoBinding* binding_ptr, _In_ const char* name, _In_ const OrtMemoryInfo* val_ptr); |
| 1163 | |
| 1164 | /** |
| 1165 | * The function returns the names of the outputs in the order they were bound. This is useful after running the model |
| 1166 | * with bound outputs because the returned names are in order in which output OrtValues are returned. This API is optional |
| 1167 | * to use. If you knew the order of outputs and its names you used for binding you would not need to use this API. |
| 1168 | * |
| 1169 | * \param binding_ptr - a ptr to an instance of OrtIoBinding created obtained from CreateIoBinding() |
| 1170 | * \param allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions() |
| 1171 | * the specified allocator will be used to allocate continuous buffers for output strings and lengths. |
| 1172 | * \param buffer - pointer to a continuous buffer of non-zero terminated UTF-8 encoded strings. The number of strings stored is returned count parameter. |
| 1173 | * this buffer will be allocated with the specified allocator and must be freed after it is no longer needed. |
| 1174 | * \param lengths - a pointer to a continuous buffer of size_t lengths of strings returned in the buffer. The number of items is returned |
| 1175 | * in the count. This buffer is allocated with the specified allocator and must be freed after it is no longer needed. |
| 1176 | * \para count - is the number of strings returned. If the instance of OrtIoBiding has no bound outputs, zero is returned, |
| 1177 | * no memory allocation is performed and buffer and lengths are nullptr on return. |
| 1178 | */ |
| 1179 | ORT_API2_STATUS(GetBoundOutputNames, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator, |
| 1180 | _Out_ char** buffer, _Out_writes_all_(count) size_t** lengths, _Out_ size_t* count); |
| 1181 | |
| 1182 | /** |
| 1183 | * The function returns an array of pointers to individually allocated OrtValues that contain results of a model execution with RunWithBinding() |
| 1184 | * The array contains the same number of OrtValues and they are in the same order as they were bound with BindOutput() |
| 1185 | * or BindOutputToDevice(). |
| 1186 | * The returned OrtValues must be individually released after they are no longer needed. |
| 1187 | * The array is allocated using the specified instance of the allocator and must be freed using the same allocator after |
| 1188 | * all the OrtValues contained therein are individually released. |
| 1189 | * |
| 1190 | * \param binding_ptr - instance of OrtIoBidning |
| 1191 | * \param allocator - instance of allocator to allocate output array |
| 1192 | * \param output - pointer to the allocated buffer. Returns nullptr if no outputs. |
| 1193 | * \param output_count - pointer to the number of OrtValues returned. Zero if no outputs. |
| 1194 | */ |
| 1195 | ORT_API2_STATUS(GetBoundOutputValues, _In_ const OrtIoBinding* binding_ptr, _In_ OrtAllocator* allocator, |
| 1196 | _Out_writes_all_(output_count) OrtValue*** output, _Out_ size_t* output_count); |
| 1197 | |
| 1198 | /** Clears any previously specified bindings for inputs/outputs |
| 1199 | */ |
| 1200 | void(ORT_API_CALL* ClearBoundInputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; |
| 1201 | void(ORT_API_CALL* ClearBoundOutputs)(_Inout_ OrtIoBinding* binding_ptr) NO_EXCEPTION ORT_ALL_ARGS_NONNULL; |
| 1202 | |
| 1203 | /** |
| 1204 | * Provides element-level access into a tensor. |
| 1205 | * \param location_values a pointer to an array of index values that specify an element's location in the tensor data blob |
| 1206 | * \param location_values_count length of location_values |
| 1207 | * \param out a pointer to the element specified by location_values |
| 1208 | * e.g. |
| 1209 | * Given a tensor with overall shape [3,224,224], an element at |
| 1210 | * location [2,150,128] can be accessed directly. |
| 1211 | * |
| 1212 | * This function only works for numeric tensors. |
| 1213 | * This is a no-copy method whose pointer is only valid until the backing OrtValue is free'd. |
| 1214 | */ |
| 1215 | ORT_API2_STATUS(TensorAt, _Inout_ OrtValue* value, const int64_t* location_values, size_t location_values_count, _Outptr_ void** out); |
| 1216 | |
| 1217 | /** |
| 1218 | * Creates an allocator instance and registers it with the env to enable |
| 1219 | * sharing between multiple sessions that use the same env instance. |
| 1220 | * Lifetime of the created allocator will be valid for the duration of the environment. |
| 1221 | * Returns an error if an allocator with the same OrtMemoryInfo is already registered. |
| 1222 | * \param env OrtEnv instance (must be non-null). |
| 1223 | * \param mem_info (must be non-null). |
| 1224 | * \param arena_cfg if nullptr defaults will be used. |
| 1225 | * See docs/C_API.md for details. |
| 1226 | */ |
| 1227 | ORT_API2_STATUS(CreateAndRegisterAllocator, _Inout_ OrtEnv* env, _In_ const OrtMemoryInfo* mem_info, |
| 1228 | _In_ const OrtArenaCfg* arena_cfg); |
| 1229 | |
| 1230 | /** |
| 1231 | * Set the language projection for collecting telemetry data when Env is created |
| 1232 | * \param projection the source projected language. |
| 1233 | */ |
| 1234 | ORT_API2_STATUS(SetLanguageProjection, _In_ const OrtEnv* ort_env, _In_ OrtLanguageProjection projection); |
| 1235 | |
| 1236 | /** |
| 1237 | * On some platforms, this timer may not be as precise as nanoseconds |
| 1238 | * For instance, on Windows and MacOS, the precision will be ~100ns |
| 1239 | * \param out is set to the nanoseconds of profiling's start time |
| 1240 | */ |
| 1241 | ORT_API2_STATUS(SessionGetProfilingStartTimeNs, _In_ const OrtSession* sess, _Outptr_ uint64_t* out); |
| 1242 | |
| 1243 | /** |
| 1244 | * Use this API to configure the global thread pool options to be used in the call to CreateEnvWithGlobalThreadPools. |
| 1245 | * A value of 0 means ORT will pick the default. |
| 1246 | * A value of 1 means the invoking thread will be used; no threads will be created in the thread pool. |
| 1247 | */ |
| 1248 | ORT_API2_STATUS(SetGlobalIntraOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int intra_op_num_threads); |
| 1249 | ORT_API2_STATUS(SetGlobalInterOpNumThreads, _Inout_ OrtThreadingOptions* tp_options, int inter_op_num_threads); |
| 1250 | |
| 1251 | /** |
| 1252 | * Use this API to configure the global thread pool options to be used in the call to CreateEnvWithGlobalThreadPools. |
| 1253 | * Allow spinning of thread pools when their queues are empty. This API will set the value for both |
| 1254 | * inter_op and intra_op threadpools. |
| 1255 | * \param allow_spinning valid values are 1 and 0. |
| 1256 | * 1: threadpool will spin to wait for queue to become non-empty, 0: it won't spin. |
| 1257 | * Prefer a value of 0 if your CPU usage is very high. |
| 1258 | */ |
| 1259 | ORT_API2_STATUS(SetGlobalSpinControl, _Inout_ OrtThreadingOptions* tp_options, int allow_spinning); |
| 1260 | |
| 1261 | /** |
| 1262 | * Add a pre-allocated initializer to a session. If a model contains an initializer with a name |
| 1263 | * that is same as the name passed to this API call, ORT will use this initializer instance |
| 1264 | * instead of deserializing one from the model file. This is useful when you want to share |
| 1265 | * the same initializer across sessions. |
| 1266 | * \param name name of the initializer |
| 1267 | * \param val OrtValue containing the initializer. Lifetime of 'val' and the underlying initializer buffer must be |
| 1268 | * managed by the user (created using the CreateTensorWithDataAsOrtValue API) and it must outlive the session object |
| 1269 | * to which it is added. |
| 1270 | */ |
| 1271 | ORT_API2_STATUS(AddInitializer, _Inout_ OrtSessionOptions* options, _In_z_ const char* name, |
| 1272 | _In_ const OrtValue* val); |
| 1273 | |
| 1274 | /** |
| 1275 | * Creates a custom environment with global threadpools and logger that will be shared across sessions. |
| 1276 | * Use this in conjunction with DisablePerSessionThreads API or else the session will use |
| 1277 | * its own thread pools. |
| 1278 | * |
| 1279 | * \param out should be freed by `ReleaseEnv` after use |
| 1280 | */ |
| 1281 | ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel logging_level, |
| 1282 | _In_ const char* logid, _In_ const struct OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out); |
| 1283 | |
| 1284 | /** |
| 1285 | * Append CUDA execution provider to the session options |
| 1286 | * If CUDA is not available (due to a non cuda enabled build), this function will return failure. |
| 1287 | */ |
| 1288 | ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CUDA, |
| 1289 | _In_ OrtSessionOptions* options, _In_ const OrtCUDAProviderOptions* cuda_options); |
| 1290 | |
| 1291 | /** |
| 1292 | * Append ROCM execution provider to the session options |
| 1293 | * If ROCM is not available (due to a non rocm enabled build), this function will return failure. |
| 1294 | */ |
| 1295 | ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_ROCM, |
| 1296 | _In_ OrtSessionOptions* options, _In_ const OrtROCMProviderOptions* rocm_options); |
| 1297 | |
| 1298 | /** |
| 1299 | * Append OpenVINO execution provider to the session options |
| 1300 | * If OpenVINO is not available (due to the OpenVINO provider shared library or its dependencies not being installed), this function will fail. |
| 1301 | */ |
| 1302 | ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_OpenVINO, |
| 1303 | _In_ OrtSessionOptions* options, _In_ const OrtOpenVINOProviderOptions* provider_options); |
| 1304 | |
| 1305 | /** |
| 1306 | * Use this API to configure the global thread pool options to be used in the call to CreateEnvWithGlobalThreadPools. |
| 1307 | * When this API is called, flush-to-zero and denormal-as-zero are applied to threads in both intra and inter global thread pool. |
| 1308 | * Note that an alternative way not using this option at runtime is to train and export a model without denormals |
| 1309 | * and that's recommended because turning this option on may hurt model accuracy. |
| 1310 | */ |
| 1311 | ORT_API2_STATUS(SetGlobalDenormalAsZero, _Inout_ OrtThreadingOptions* tp_options); |
| 1312 | |
| 1313 | /** |
| 1314 | * (Deprecated) Use `CreateArenaCfgV2` instead |
| 1315 | * Use this API to create the configuration of an arena that can eventually be used to define |
| 1316 | * an arena based allocator's behavior |
| 1317 | * \param max_mem - use 0 to allow ORT to choose the default |
| 1318 | * \param arena_extend_strategy - use -1 to allow ORT to choose the default, 0 = kNextPowerOfTwo, 1 = kSameAsRequested |
| 1319 | * \param initial_chunk_size_bytes - use -1 to allow ORT to choose the default |
| 1320 | * \param max_dead_bytes_per_chunk - use -1 to allow ORT to choose the default |
| 1321 | * \param out - a pointer to an OrtArenaCfg instance |
| 1322 | * \return a nullptr in case of success or a pointer to an OrtStatus instance in case of failure |
| 1323 | * See docs/C_API.md for details on what the following parameters mean and how to choose these values |
| 1324 | */ |
| 1325 | ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, |
| 1326 | int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out); |
| 1327 | |
| 1328 | ORT_CLASS_RELEASE(ArenaCfg); |
| 1329 | |
| 1330 | /** |
| 1331 | * Use this API to obtain the description of the graph present in the model |
| 1332 | * (doc_string field of the GraphProto message within the ModelProto message). |
| 1333 | * If it doesn't exist, an empty string will be returned. |
| 1334 | * \param model_metadata - an instance of OrtModelMetadata |
| 1335 | * \param allocator - allocator used to allocate the string that will be returned back |
| 1336 | * \param value - is set to a null terminated string allocated using 'allocator'. |
| 1337 | The caller is responsible for freeing it. |
| 1338 | */ |
| 1339 | ORT_API2_STATUS(ModelMetadataGetGraphDescription, _In_ const OrtModelMetadata* model_metadata, |
| 1340 | _Inout_ OrtAllocator* allocator, _Outptr_ char** value); |
| 1341 | /** |
| 1342 | * Append TensorRT execution provider to the session options with TensorRT provider options. |
| 1343 | * If TensorRT is not available (due to a non TensorRT enabled build), this function will return failure. |
| 1344 | */ |
| 1345 | ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT, |
| 1346 | _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptions* tensorrt_options); |
| 1347 | |
| 1348 | /** |
| 1349 | * Set the current device id of the GPU execution provider (cuda/tensorrt/rocm). The device id should be less |
| 1350 | * than the total number of devices available. Using this API makes sense only when doing multi-GPU inferencing. |
| 1351 | */ |
| 1352 | ORT_API2_STATUS(SetCurrentGpuDeviceId, _In_ int device_id); |
| 1353 | |
| 1354 | /** |
| 1355 | * Get the current device id of the GPU execution provider (cuda/tensorrt/rocm). |
| 1356 | */ |
| 1357 | ORT_API2_STATUS(GetCurrentGpuDeviceId, _In_ int* device_id); |
| 1358 | |
| 1359 | /** |
| 1360 | * Fetch an array of int64_t values stored as an attribute in the graph node |
| 1361 | * \info - OrtKernelInfo instance |
| 1362 | * \name - name of the attribute to be parsed |
| 1363 | * \out - pointer to memory where the attribute's contents are to be stored |
| 1364 | * \size - actual size of attribute array |
| 1365 | * (If `out` is nullptr, the value of `size` is set to the true size of the attribute |
| 1366 | array's size, and a success status is returned. |
| 1367 | |
| 1368 | If the `size` parameter is greater than or equal to the actual attribute array's size, |
| 1369 | the value of `size` is set to the true size of the attribute array's size, |
| 1370 | the provided memory is filled with the attribute's contents, |
| 1371 | and a success status is returned. |
| 1372 | |
| 1373 | If the `size` parameter is lesser than the actual attribute array's size and `out` |
| 1374 | is not nullptr, the value of `size` is set to the true size of the attribute array's size |
| 1375 | and a failure status is returned.) |
| 1376 | */ |
| 1377 | ORT_API2_STATUS(KernelInfoGetAttributeArray_float, _In_ const OrtKernelInfo* info, _In_ const char* name, |
| 1378 | _Out_ float* out, _Inout_ size_t* size); |
| 1379 | |
| 1380 | /** |
| 1381 | * Fetch an array of int64_t values stored as an attribute in the graph node |
| 1382 | * \info - OrtKernelInfo instance |
| 1383 | * \name - name of the attribute to be parsed |
| 1384 | * \out - pointer to memory where the attribute's contents are to be stored |
| 1385 | * \size - actual size of attribute array |
| 1386 | * (If `out` is nullptr, the value of `size` is set to the true size of the attribute |
| 1387 | array's size, and a success status is returned. |
| 1388 | |
| 1389 | If the `size` parameter is greater than or equal to the actual attribute array's size, |
| 1390 | the value of `size` is set to the true size of the attribute array's size, |
| 1391 | the provided memory is filled with the attribute's contents, |
| 1392 | and a success status is returned. |
| 1393 | |
| 1394 | If the `size` parameter is lesser than the actual attribute array's size and `out` |
| 1395 | is not nullptr, the value of `size` is set to the true size of the attribute array's size |
| 1396 | and a failure status is returned.) |
| 1397 | */ |
| 1398 | ORT_API2_STATUS(KernelInfoGetAttributeArray_int64, _In_ const OrtKernelInfo* info, _In_ const char* name, |
| 1399 | _Out_ int64_t* out, _Inout_ size_t* size); |
| 1400 | |
| 1401 | /** |
| 1402 | * Use this API to create the configuration of an arena that can eventually be used to define |
| 1403 | * an arena based allocator's behavior |
| 1404 | * \param arena_config_keys - keys to configure the arena |
| 1405 | * \param arena_config_values - values to configure the arena |
| 1406 | * \param num_keys - number of keys passed in |
| 1407 | * Supported keys are (See docs/C_API.md for details on what the following parameters mean and how to choose these values.): |
| 1408 | * "max_mem": Maximum memory that can be allocated by the arena based allocator. |
| 1409 | Use 0 for ORT to pick the best value. Default is 0. |
| 1410 | * "arena_extend_strategy": 0 = kNextPowerOfTwo, 1 = kSameAsRequested. |
| 1411 | Use -1 to allow ORT to choose the default. |
| 1412 | * "initial_chunk_size_bytes": (Possible) Size of the first allocation in the arena. |
| 1413 | Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1 to allow ORT to choose the default. |
| 1414 | Ultimately, the first allocation size is determined by the allocation memory request. |
| 1415 | * "max_dead_bytes_per_chunk": Threshold of unused memory in an allocated chunk of arena memory after |
| 1416 | crossing which the current chunk is chunked into 2. |
| 1417 | * "initial_growth_chunk_size_bytes": (Possible) Size of the second allocation in the arena. |
| 1418 | Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1 to allow ORT to choose the default. |
| 1419 | Ultimately, the allocation size is determined by the allocation memory request. |
| 1420 | Further allocation sizes are governed by the arena extend strategy. |
| 1421 | */ |
| 1422 | ORT_API2_STATUS(CreateArenaCfgV2, _In_reads_(num_keys) const char* const* arena_config_keys, |
| 1423 | _In_reads_(num_keys) const size_t* arena_config_values, _In_ size_t num_keys, |
| 1424 | _Outptr_ OrtArenaCfg** out); |
| 1425 | |
| 1426 | /** |
| 1427 | * Set a single run configuration entry as a pair of strings |
| 1428 | * If a configuration with same key exists, this will overwrite the configuration with the given config_value |
| 1429 | * \param config_key A null terminated string representation of the config key |
| 1430 | * \param config_value A null terminated string representation of the config value |
| 1431 | * The config_key and the format of config_value are defined in onnxruntime_run_options_config_keys.h |
| 1432 | */ |
| 1433 | ORT_API2_STATUS(AddRunConfigEntry, _Inout_ OrtRunOptions* options, |
| 1434 | _In_z_ const char* config_key, _In_z_ const char* config_value); |
| 1435 | |
| 1436 | /* |
| 1437 | * Creates an OrtPrepackedWeightsContainer instance. |
| 1438 | * This container will hold pre-packed buffers of shared initializers for sharing between sessions |
| 1439 | * (i.e.) if there are shared initializers that can be shared between sessions, the pre-packed buffers |
| 1440 | * of these (if any) may possibly be shared to provide memory footprint savings. Pass this container |
| 1441 | * to sessions that you would like to share pre-packed buffers of shared initializers at session |
| 1442 | * creation time. |
| 1443 | * \out - created OrtPrepackedWeightsContainer instance |
| 1444 | */ |
| 1445 | ORT_API2_STATUS(CreatePrepackedWeightsContainer, _Outptr_ OrtPrepackedWeightsContainer** out); |
| 1446 | |
| 1447 | /* |
| 1448 | * Release OrtPrepackedWeightsContainer instance |
| 1449 | * Note: The OrtPrepackedWeightsContainer instance must not be released until the sessions using it are released |
| 1450 | */ |
| 1451 | ORT_CLASS_RELEASE(PrepackedWeightsContainer); |
| 1452 | |
| 1453 | /** |
| 1454 | * Same functionality offered by CreateSession() API except that a container that contains |
| 1455 | pre-packed weights' buffers is written into/read from by the created session. |
| 1456 | This is useful when used in conjunction with the AddInitializer() API which injects |
| 1457 | shared initializer info into sessions. Wherever possible, the pre-packed versions of these |
| 1458 | shared initializers are cached in this container so that multiple sessions can just re-use |
| 1459 | these instead of duplicating these in memory. |
| 1460 | * \env - OrtEnv instance instance |
| 1461 | * \model_path - model path |
| 1462 | * \options - OrtSessionOptions instance |
| 1463 | * \prepacked_weights_container - OrtPrepackedWeightsContainer instance |
| 1464 | * \out - created session instance |
| 1465 | */ |
| 1466 | ORT_API2_STATUS(CreateSessionWithPrepackedWeightsContainer, _In_ const OrtEnv* env, _In_ const ORTCHAR_T* model_path, |
| 1467 | _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container, |
| 1468 | _Outptr_ OrtSession** out); |
| 1469 | |
| 1470 | /** |
| 1471 | * Same functionality offered by CreateSessionFromArray() API except that a container that contains |
| 1472 | pre-packed weights' buffers is written into/read from by the created session. |
| 1473 | This is useful when used in conjunction with the AddInitializer() API which injects |
| 1474 | shared initializer info into sessions. Wherever possible, the pre-packed versions of these |
| 1475 | shared initializers are cached in this container so that multiple sessions can just re-use |
| 1476 | these instead of duplicating these in memory. |
| 1477 | * \env - OrtEnv instance instance |
| 1478 | * \model_data - model byte array |
| 1479 | * \model_data_length - the size of the model byte array |
| 1480 | * \options - OrtSessionOptions instance |
| 1481 | * \prepacked_weights_container - OrtPrepackedWeightsContainer instance |
| 1482 | * \out - created session instance |
| 1483 | */ |
| 1484 | ORT_API2_STATUS(CreateSessionFromArrayWithPrepackedWeightsContainer, _In_ const OrtEnv* env, |
| 1485 | _In_ const void* model_data, size_t model_data_length, |
| 1486 | _In_ const OrtSessionOptions* options, _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container, |
| 1487 | _Outptr_ OrtSession** out); |
| 1488 | |
| 1489 | /* |
| 1490 | * Append TensorRT execution provider to the session options with TensorRT provider options. |
| 1491 | * If TensorRT is not available (due to a non TensorRT enabled build), this function will return failure. |
| 1492 | * Note: this API is slightly different than SessionOptionsAppendExecutionProvider_TensorRT. |
| 1493 | * SessionOptionsAppendExecutionProvider_TensorRT takes struct OrtTensorRTProviderOptions which is open to user as argument, |
| 1494 | * but this API takes opaque struct OrtTensorRTProviderOptionsV2 which must be created by CreateTensorRTProviderOptions. |
| 1495 | * User needs to instantiate OrtTensorRTProviderOptions as well as allocate/release buffers for some members of OrtTensorRTProviderOptions. |
| 1496 | * However, for using OrtTensorRTProviderOptionsV2, CreateTensorRTProviderOptions and ReleaseTensorRTProviderOptions will do the memory allocation and release for you. |
| 1497 | * |
| 1498 | * \param options - OrtSessionOptions instance |
| 1499 | * \param tensorrt_options - OrtTensorRTProviderOptionsV2 instance |
| 1500 | */ |
| 1501 | ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT_V2, |
| 1502 | _In_ OrtSessionOptions* options, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options); |
| 1503 | |
| 1504 | /** |
| 1505 | * Use this API to create the configuration of a TensorRT Execution Provider which is an instance of OrtTensorRTProviderOptionsV2. |
| 1506 | * |
| 1507 | * \param out - pointer to the pointer of TensorRT EP provider options instance. |
| 1508 | */ |
| 1509 | ORT_API2_STATUS(CreateTensorRTProviderOptions, _Outptr_ OrtTensorRTProviderOptionsV2** out); |
| 1510 | |
| 1511 | /** |
| 1512 | * Use this API to set appropriate configuration knobs of a TensorRT Execution Provider. |
| 1513 | * |
| 1514 | * Please reference to https://www.onnxruntime.ai/docs/reference/execution-providers/TensorRT-ExecutionProvider.html#c-api-example |
| 1515 | * to know the available keys and values. Key should be in string format of the member of OrtTensorRTProviderOptions and value should be its related range. |
| 1516 | * For example, key="trt_max_workspace_size" and value="2147483648" |
| 1517 | * |
| 1518 | * \param tensorrt_options - OrtTensorRTProviderOptionsV2 instance |
| 1519 | * \param provider_options_keys - array of UTF-8 null-terminated string for provider options keys |
| 1520 | * \param provider_options_values - array of UTF-8 null-terminated string for provider options values |
| 1521 | * \param num_keys - number of keys |
| 1522 | */ |
| 1523 | ORT_API2_STATUS(UpdateTensorRTProviderOptions, _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options, |
| 1524 | _In_reads_(num_keys) const char* const* provider_options_keys, |
| 1525 | _In_reads_(num_keys) const char* const* provider_options_values, |
| 1526 | _In_ size_t num_keys); |
| 1527 | |
| 1528 | /** |
| 1529 | * Get serialized TensorRT provider options string. |
| 1530 | * |
| 1531 | * For example, "trt_max_workspace_size=2147483648;trt_max_partition_iterations=10;trt_int8_enable=1;......" |
| 1532 | * |
| 1533 | * \param tensorrt_options - OrTensorRTProviderOptionsV2 instance |
| 1534 | * \param allocator - a ptr to an instance of OrtAllocator obtained with CreateAllocator() or GetAllocatorWithDefaultOptions() |
| 1535 | * the specified allocator will be used to allocate continuous buffers for output strings and lengths. |
| 1536 | * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'. The caller is responsible for using the same allocator to free it. |
| 1537 | */ |
| 1538 | ORT_API2_STATUS(GetTensorRTProviderOptionsAsString, _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options, _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr); |
| 1539 | |
| 1540 | /** |
| 1541 | * Use this API to release the instance of OrtTensorRTProviderV2. |
| 1542 | */ |
| 1543 | ORT_CLASS_RELEASE2(TensorRTProviderOptions); |
| 1544 | |
| 1545 | /* |
| 1546 | * Enable custom operators in onnxruntime-extensions: https://github.com/microsoft/onnxruntime-extensions.git |
| 1547 | */ |
| 1548 | ORT_API2_STATUS(EnableOrtCustomOps, _Inout_ OrtSessionOptions* options); |
| 1549 | |
| 1550 | /** |
| 1551 | * Registers a custom allocator instance with the env to enable |
| 1552 | * sharing between multiple sessions that use the same env instance. |
| 1553 | * Returns an error if an allocator with the same OrtMemoryInfo is already registered. |
| 1554 | * |
| 1555 | * The behavior of this API is exactly the same as CreateAndRegisterAllocator() except |
| 1556 | * instead of ORT creating an allocator based on provided info, in this case |
| 1557 | * ORT uses the user-provided custom allocator. |
| 1558 | * See docs/C_API.md for details. |
| 1559 | * |
| 1560 | * \param[in,out] env OrtEnv instance (must be non-null). |
| 1561 | * \param[in] allocator user provided allocator (must be non-null). |
| 1562 | * |
| 1563 | */ |
| 1564 | ORT_API2_STATUS(RegisterAllocator, _Inout_ OrtEnv* env, _In_ OrtAllocator* allocator); |
| 1565 | |
| 1566 | /** |
| 1567 | * Unregisters a registered allocator for sharing across sessions |
| 1568 | * based on provided OrtMemoryInfo. |
| 1569 | * It is an error if you provide an OrtmemoryInfo not corresponding to any |
| 1570 | * registered allocators for sharing. |
| 1571 | */ |
| 1572 | ORT_API2_STATUS(UnregisterAllocator, _Inout_ OrtEnv* env, |
| 1573 | _In_ const OrtMemoryInfo* mem_info); |
| 1574 | |
| 1575 | /** |
| 1576 | * Sets *out to 1 iff an OrtValue is a SparseTensor, and 0 otherwise |
| 1577 | * |
| 1578 | * \param[in] value existing OrtValue |
| 1579 | * \param[out] out unless an error occurs, contains 1 iff the value contains an instance |
| 1580 | * of sparse tensor or 0 otherwise. |
| 1581 | */ |
| 1582 | ORT_API2_STATUS(IsSparseTensor, _In_ const OrtValue* value, _Out_ int* out); |
| 1583 | |
| 1584 | /** |
| 1585 | * Create an OrtValue with a sparse tensor that is empty. |
| 1586 | * Use FillSparseTensor<Format>() functions to populate sparse tensor with non-zero values and |
| 1587 | * format specific indices data. |
| 1588 | * Use ReleaseValue to destroy the sparse tensor, this will also release the buffer inside the output value |
| 1589 | * if any was allocated. |
| 1590 | * \param[in,out] allocator allocator to use when performing an allocation. Allocation will be performed |
| 1591 | * by FillSparseTensor<Format>() APIs. The lifespan of the allocator instance must eclipse the lifespan |
| 1592 | * this sparse tensor instance as the same allocator will be used to free memory. |
| 1593 | * \param[in] dense_shape shape of the original dense tensor |
| 1594 | * \param[in] dense_shape_len number of shape dimensions being passed |
| 1595 | * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx |
| 1596 | * \param[out] out Should be freed by calling ReleaseValue |
| 1597 | * \return OrtStatus* |
| 1598 | */ |
| 1599 | ORT_API2_STATUS(CreateSparseTensorAsOrtValue, _Inout_ OrtAllocator* allocator, _In_ const int64_t* dense_shape, |
| 1600 | size_t dense_shape_len, ONNXTensorElementDataType type, _Outptr_ OrtValue** out); |
| 1601 | |
| 1602 | /** |
| 1603 | * This API fills populates an empty tensor that was created using CreateSparseTensorAsOrtValue API. |
| 1604 | * The API will allocate required memory and copy the supplied NNZ values and COO indices into that memory allocation. |
| 1605 | * Memory allocation is performed using the allocator that was specified with CreateSparseTensorAsOrtValue. |
| 1606 | * |
| 1607 | * \param[in,out] ort_value OrtValue to populate with data |
| 1608 | * \param[in] mem_info serves to identify the location of the data to be copied. If the allocator specified |
| 1609 | * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. |
| 1610 | * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. |
| 1611 | * \param[in] values_shape pointer to values shape array |
| 1612 | * \param[in] values_shape_len length of the values_shape |
| 1613 | * \param[in] values pointer to an array of values. For strings, pass const char**. |
| 1614 | * \param[in] indices_data pointer to a location of COO indices |
| 1615 | * \param[in] indices_num number of COO indices |
| 1616 | */ |
| 1617 | ORT_API2_STATUS(FillSparseTensorCoo, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, |
| 1618 | _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, |
| 1619 | _In_ const int64_t* indices_data, size_t indices_num); |
| 1620 | |
| 1621 | /** |
| 1622 | * This API fills populates an empty tensor that was created using CreateSparseTensorAsOrtValue API. |
| 1623 | * The API will allocate required memory and copy the supplied NNZ values and CSR indices into that memory allocation. |
| 1624 | * Memory allocation is performed using the allocator that was specified with CreateSparseTensorAsOrtValue. |
| 1625 | * |
| 1626 | * \param[in,out] ort_value OrtValue to populate with data |
| 1627 | * \param[in] mem_info serves to identify the location of the data to be copied. If the allocator specified |
| 1628 | * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. |
| 1629 | * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. |
| 1630 | * \param[in] values_shape pointer to values shape array |
| 1631 | * \param[in] values_shape_len length of the values_shape |
| 1632 | * \param[in] values - pointer to an array of values. For strings, pass const char**. |
| 1633 | * \param[in] inner_indices_data pointer to a location of CSR inner indices |
| 1634 | * \param[in] inner_indices_num number of CSR inner indices |
| 1635 | * \param[in] outer_indices_data pointer to a location of CSR outer indices |
| 1636 | * \param[in] outer_indices_num number of CSR outer indices |
| 1637 | */ |
| 1638 | ORT_API2_STATUS(FillSparseTensorCsr, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, |
| 1639 | _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, |
| 1640 | _In_ const int64_t* inner_indices_data, size_t inner_indices_num, |
| 1641 | _In_ const int64_t* outer_indices_data, size_t outer_indices_num); |
| 1642 | |
| 1643 | /** |
| 1644 | * This API fills populates an empty tensor that was created using CreateSparseTensorAsOrtValue API. |
| 1645 | * The API will allocate required memory and copy the supplied NNZ values and BlockSparse indices into that memory allocation. |
| 1646 | * Memory allocation is performed using the allocator that was specified with CreateSparseTensorAsOrtValue. |
| 1647 | * |
| 1648 | * \param[in,out] ort_value OrtValue to populate with data |
| 1649 | * \param[in] mem_info serves to identify the location of the data to be copied. If the allocator specified |
| 1650 | * at the creation time has memory info that is not the same as mem_info argument to this function a X-device copy will be performed. |
| 1651 | * String data is assumed to be on CPU and will only be copied into a CPU allocated buffer. |
| 1652 | * \param[in] values structure with values information |
| 1653 | * \param[in] indices_shape_data pointer to a location of indices shape |
| 1654 | * \param[in] indices_shape_len length of the block sparse indices shape |
| 1655 | * \param[in] indices_data pointer to a location of indices data. Shape will determine the length of the indices data. |
| 1656 | */ |
| 1657 | ORT_API2_STATUS(FillSparseTensorBlockSparse, _Inout_ OrtValue* ort_value, _In_ const OrtMemoryInfo* data_mem_info, |
| 1658 | _In_ const int64_t* values_shape, size_t values_shape_len, _In_ const void* values, |
| 1659 | _In_ const int64_t* indices_shape_data, size_t indices_shape_len, |
| 1660 | _In_ const int32_t* indices_data); |
| 1661 | |
| 1662 | /** |
| 1663 | * Create an OrtValue with a sparse tensor. This is the first step. |
| 1664 | * Next, use Use<Format>Indices() functions to supply sparse tensor with |
| 1665 | * format specific indices data and set its sparse format to a specific enum value. |
| 1666 | * This API will not perform memory allocations. It will |
| 1667 | * use supplied user buffer which should outlive the created sparse tensor. |
| 1668 | * Use ReleaseValue to destroy the sparse tensor. It would not release the supplied values buffer. |
| 1669 | * This API can not be used to map strings from the user allocated memory. Strings must always be copied |
| 1670 | * and have UTF-8 encoding. Therefore, use CreateSparseTensorAsOrtValue() API above and then fill it with data |
| 1671 | * using appropriate Make*() function. |
| 1672 | * |
| 1673 | * \param[in] info memory info where sparse values reside. |
| 1674 | * \param[in,out] p_data pointer to a user allocated buffer with values. To create a full sparse tensor with no non-zero |
| 1675 | * values, pass nullptr |
| 1676 | * \param[in] dense_shape shape of the original dense tensor |
| 1677 | * \param[in] dense_shape_len number of shape dimensions being passed |
| 1678 | * \param[in] values_shape shape of the values data. To create a fully sparse tensor with no non-zero values, |
| 1679 | * pass {0} shape. |
| 1680 | * \param[in] values_shape_len number of values shape dimensions |
| 1681 | * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx |
| 1682 | * \param[out] out Should be freed by calling ReleaseValue |
| 1683 | * \return OrtStatus* |
| 1684 | */ |
| 1685 | ORT_API2_STATUS(CreateSparseTensorWithValuesAsOrtValue, _In_ const OrtMemoryInfo* info, _Inout_ void* p_data, |
| 1686 | _In_ const int64_t* dense_shape, size_t dense_shape_len, |
| 1687 | _In_ const int64_t* values_shape, size_t values_shape_len, |
| 1688 | ONNXTensorElementDataType type, _Outptr_ OrtValue** out); |
| 1689 | |
| 1690 | /** |
| 1691 | * The API assigns Coo format indices to the SparseTensor that was created by |
| 1692 | * CreateSparseTensorWithValuesAsOrtValue API above. It also sets OrtSparseFormat to |
| 1693 | * ORT_SPARSE_COO. The API will not allocate any additional memory for data. The life span of |
| 1694 | * indices_data buffer should eclipse the life span of this OrtValue. |
| 1695 | * |
| 1696 | * \param[in,out] ort_value OrtValue instance constructed with CreateSparseTensorWithValuesAsOrtValue |
| 1697 | * \param[in,out] indices_data pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. |
| 1698 | * \param[in] indices_num number of COO indices. Should either be 0 for fully sparse tensors, be equal |
| 1699 | * to the number of nnz values specified to CreateSparseTensorWithValuesAsOrtValue for 1-D {nnz} indices or |
| 1700 | * be twice as number of nnz values for a 2-D indices {nnz, 2} |
| 1701 | */ |
| 1702 | ORT_API2_STATUS(UseCooIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* indices_data, size_t indices_num); |
| 1703 | |
| 1704 | /** |
| 1705 | * The API assigns CSR format indices to the SparseTensor that was created by |
| 1706 | * CreateSparseTensorWithValuesAsOrtValue API above. It also sets OrtSparseFormat to |
| 1707 | * ORT_SPARSE_CSRC. The API will not allocate any additional memory for data. The life spans of |
| 1708 | * indner_data and outer_data buffers should eclipse the life span of this OrtValue. |
| 1709 | * |
| 1710 | * \param[in,out] ort_value OrtValue instance constructed with CreateSparseTensorWithValuesAsOrtValue |
| 1711 | * \param[in,out] inner_data pointer to a user pre-allocated buffer or nullptr for fully sparse tensors. |
| 1712 | * \param[in] inner_num number of inner CSR indices. Should either be 0 for fully sparse tensors or be equal |
| 1713 | * to the number of nnz values specified to CreateSparseTensorWithValuesAsOrtValue. |
| 1714 | * \param[in,out] outer_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors. |
| 1715 | * \param[in] outer_num number of CSR outer indices. Should either be 0 for fully sparse tensors or |
| 1716 | * equal to rows + 1 of the dense shape. |
| 1717 | */ |
| 1718 | ORT_API2_STATUS(UseCsrIndices, _Inout_ OrtValue* ort_value, _Inout_ int64_t* inner_data, size_t inner_num, |
| 1719 | _Inout_ int64_t* outer_data, size_t outer_num); |
| 1720 | |
| 1721 | /** |
| 1722 | * The API assigns BlockSparse format indices to the SparseTensor that was created by |
| 1723 | * CreateSparseTensorWithValuesAsOrtValue API above. It also sets OrtSparseFormat to |
| 1724 | * ORT_SPARSE_BLOCK_SPARSE. The API will not allocate any additional memory for data. The life span of |
| 1725 | * indices_data buffer must eclipse the lifespan of this OrtValue. |
| 1726 | * |
| 1727 | * \param[in,out] ort_value OrtValue instance constructed with CreateSparseTensorWithValuesAsOrtValue |
| 1728 | * \param[in] indices_shape pointer to indices shape. Use {0} for fully sparse tensors |
| 1729 | * \param[in] indices_shape_len length of the indices shape |
| 1730 | * \param[in,out] indices_data pointer to user pre-allocated buffer or nullptr for fully sparse tensors. |
| 1731 | */ |
| 1732 | ORT_API2_STATUS(UseBlockSparseIndices, _Inout_ OrtValue* ort_value, const int64_t* indices_shape, size_t indices_shape_len, _Inout_ int32_t* indices_data); |
| 1733 | |
| 1734 | /** |
| 1735 | * The API returns sparse tensor format enum iff a given ort value contains an instance of sparse tensor. |
| 1736 | * |
| 1737 | * \param[in] ort_value OrtValue that contains an instance of sparse tensor |
| 1738 | * \param[out] out pointer to out parameter |
| 1739 | */ |
| 1740 | ORT_API2_STATUS(GetSparseTensorFormat, _In_ const OrtValue* ort_value, _Out_ enum OrtSparseFormat* out); |
| 1741 | |
| 1742 | /** |
| 1743 | * The API Returns data type and shape of sparse tensor values (nnz) iff OrtValue contains a SparseTensor. |
| 1744 | * |
| 1745 | * \param[in] ort_value an OrtValue that contains a fully constructed sparse tensor |
| 1746 | * \param[out] out Should be freed by ReleaseTensorTypeAndShapeInfo after use |
| 1747 | */ |
| 1748 | ORT_API2_STATUS(GetSparseTensorValuesTypeAndShape, _In_ const OrtValue* ort_value, _Outptr_ OrtTensorTypeAndShapeInfo** out); |
| 1749 | |
| 1750 | /** |
| 1751 | * The API returns numeric data for sparse tensor values (nnz). For string values use GetStringTensor*() API. |
| 1752 | * |
| 1753 | * \param[in] ort_value an instance of OrtValue containing sparse tensor |
| 1754 | * \param[out] out returns a pointer to values data. Do not attempt to free this ptr. |
| 1755 | */ |
| 1756 | ORT_API2_STATUS(GetSparseTensorValues, _In_ const OrtValue* ort_value, _Outptr_ const void** out); |
| 1757 | |
| 1758 | /** |
| 1759 | * The API returns data type, shape for the type of indices specified by |
| 1760 | * indices_format. |
| 1761 | * |
| 1762 | * \param[in] ort_value OrtValue containing sparse tensor. |
| 1763 | * \param[in] indices_format - one of the indices formats. It is an error to request a format that the sparse |
| 1764 | * tensor does not contain. |
| 1765 | * \param[out] an instance of OrtTensorTypeAndShapeInfo. Must be freed by the ReleaseTensorTypeAndShapeInfo. |
| 1766 | */ |
| 1767 | ORT_API2_STATUS(GetSparseTensorIndicesTypeShape, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Outptr_ OrtTensorTypeAndShapeInfo** out); |
| 1768 | |
| 1769 | /** |
| 1770 | * The API returns indices data for the type of the indices specified by indices_format. |
| 1771 | * Do not free the returned ptr as it points directly to the internal sparse tensor buffer. |
| 1772 | * |
| 1773 | * \param[in] ort_value OrtValue containing sparse tensor. |
| 1774 | * \param[in] indices_format - one of the indices formats. It is an error to request a format that the sparse |
| 1775 | * tensor does not contain. |
| 1776 | * \param[out] num_indices ptr where the number of indices entries is returned |
| 1777 | * \param[out] indices out param where the pointer to the internal buffer is returned. Do not free this buffer. |
| 1778 | */ |
| 1779 | ORT_API2_STATUS(GetSparseTensorIndices, _In_ const OrtValue* ort_value, enum OrtSparseIndicesFormat indices_format, _Out_ size_t* num_indices, _Outptr_ const void** indices); |
| 1780 | }; |
| 1781 | |
| 1782 | /* |
| 1783 | * Steps to use a custom op: |
| 1784 | * 1 Create an OrtCustomOpDomain with the domain name used by the custom ops |
| 1785 | * 2 Create an OrtCustomOp structure for each op and add them to the domain |
| 1786 | * 3 Call OrtAddCustomOpDomain to add the custom domain of ops to the session options |
| 1787 | */ |
| 1788 | #define OrtCustomOpApi OrtApi |
| 1789 | |
| 1790 | // Specifies some characteristics of inputs/outputs of custom ops: |
| 1791 | // Specify if the inputs/outputs are one of: |
| 1792 | // 1) Non-optional (input/output must be present in the node) |
| 1793 | // 2) Optional (input/output may be absent in the node) |
| 1794 | typedef enum OrtCustomOpInputOutputCharacteristic { |
| 1795 | // TODO: Support 'Variadic' inputs/outputs |
| 1796 | INPUT_OUTPUT_REQUIRED = 0, |
| 1797 | INPUT_OUTPUT_OPTIONAL, |
| 1798 | } OrtCustomOpInputOutputCharacteristic; |
| 1799 | |
| 1800 | /* |
| 1801 | * The OrtCustomOp structure defines a custom op's schema and its kernel callbacks. The callbacks are filled in by |
| 1802 | * the implementor of the custom op. |
| 1803 | */ |
| 1804 | struct OrtCustomOp { |
| 1805 | uint32_t version; // Initialize to ORT_API_VERSION |
| 1806 | |
| 1807 | // This callback creates the kernel, which is a user defined parameter that is passed to the Kernel* callbacks below. |
| 1808 | void*(ORT_API_CALL* CreateKernel)(_In_ const struct OrtCustomOp* op, _In_ const OrtApi* api, |
| 1809 | _In_ const OrtKernelInfo* info); |
| 1810 | |
| 1811 | // Returns the name of the op |
| 1812 | const char*(ORT_API_CALL* GetName)(_In_ const struct OrtCustomOp* op); |
| 1813 | |
| 1814 | // Returns the type of the execution provider, return nullptr to use CPU execution provider |
| 1815 | const char*(ORT_API_CALL* GetExecutionProviderType)(_In_ const struct OrtCustomOp* op); |
| 1816 | |
| 1817 | // Returns the count and types of the input & output tensors |
| 1818 | ONNXTensorElementDataType(ORT_API_CALL* GetInputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index); |
| 1819 | size_t(ORT_API_CALL* GetInputTypeCount)(_In_ const struct OrtCustomOp* op); |
| 1820 | ONNXTensorElementDataType(ORT_API_CALL* GetOutputType)(_In_ const struct OrtCustomOp* op, _In_ size_t index); |
| 1821 | size_t(ORT_API_CALL* GetOutputTypeCount)(_In_ const struct OrtCustomOp* op); |
| 1822 | |
| 1823 | // Op kernel callbacks |
| 1824 | void(ORT_API_CALL* KernelCompute)(_In_ void* op_kernel, _In_ OrtKernelContext* context); |
| 1825 | void(ORT_API_CALL* KernelDestroy)(_In_ void* op_kernel); |
| 1826 | |
| 1827 | // Returns the characteristics of the input & output tensors |
| 1828 | OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetInputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index); |
| 1829 | OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index); |
| 1830 | }; |
| 1831 | |
| 1832 | /* |
| 1833 | * This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality |
| 1834 | * This function always exists, but will only succeed if Onnxruntime was built with CUDA support and the CUDA provider shared library exists |
| 1835 | * |
| 1836 | * \param device_id cuda device id, starts from zero. |
| 1837 | */ |
| 1838 | ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id); |
| 1839 | |
| 1840 | #ifdef __cplusplus |
| 1841 | } |
| 1842 | #endif |
| 1843 | |