tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

onnxruntime_c_api.h (250048B)


      1 // Copyright (c) Microsoft Corporation. All rights reserved.
      2 // Licensed under the MIT License.
      3 
      4 // See docs\c_cxx\README.md on generating the Doxygen documentation from this
      5 // file
      6 
      7 /** \mainpage ONNX Runtime
      8 *
      9 * ONNX Runtime is a high-performance inference and training graph execution
     10 * engine for deep learning models.
     11 *
     12 * ONNX Runtime's C, C++ APIs offer an easy to use interface to onboard and
     13 * execute onnx models.
     14 * - \subpage c_cpp_api "Core C, C++ APIs"
     15 * - \subpage training_c_cpp_api "Training C, C++ APIs for on-device training"
     16 *
     17 * \page c_cpp_api Core C, C++ APIs
     18 * <h1>C</h1>
     19 *
     20 * ::OrtApi - Click here to go to the structure with all C API functions.
     21 *
     22 * <h1>C++</h1>
     23 *
     24 * ::Ort - Click here to go to the namespace holding all of the C++ wrapper
     25 * classes
     26 *
     27 * It is a set of header only wrapper classes around the C API. The goal is to
     28 * turn the C style return value error codes into C++ exceptions, and to
     29 * automate memory management through standard C++ RAII principles.
     30 *
     31 * \addtogroup Global
     32 * ONNX Runtime C API
     33 * @{
     34 */
     35 
     36 #pragma once
     37 #include <stdbool.h>
     38 #include <stdint.h>
     39 #include <stdlib.h>
     40 #include <string.h>
     41 
     42 /** \brief The API version defined in this header
     43 *
     44 * This value is used by some API functions to behave as this version of the
     45 * header expects.
     46 */
     47 #define ORT_API_VERSION 22
     48 
     49 #ifdef __cplusplus
     50 extern "C" {
     51 #endif
     52 
     53 //! @}
     54 // SAL2 Definitions
     55 #ifndef _MSC_VER
     56 #  define _In_
     57 #  define _In_z_
     58 #  define _In_opt_
     59 #  define _In_opt_z_
     60 #  define _Out_
     61 #  define _Outptr_
     62 #  define _Out_opt_
     63 #  define _Inout_
     64 #  define _Inout_opt_
     65 #  define _Frees_ptr_opt_
     66 #  define _Ret_maybenull_
     67 #  define _Ret_notnull_
     68 #  define _Check_return_
     69 #  define _Outptr_result_maybenull_
     70 #  define _In_reads_(X)
     71 #  define _Inout_updates_(X)
     72 #  define _Out_writes_(X)
     73 #  define _Inout_updates_all_(X)
     74 #  define _Out_writes_bytes_all_(X)
     75 #  define _Out_writes_all_(X)
     76 #  define _Success_(X)
     77 #  define _Outptr_result_buffer_maybenull_(X)
     78 #  define ORT_ALL_ARGS_NONNULL __attribute__((nonnull))
     79 #else
     80 #  include <specstrings.h>
     81 #  define ORT_ALL_ARGS_NONNULL
     82 #endif
     83 
     84 #ifdef _WIN32
     85 // Define ORT_DLL_IMPORT if your program is dynamically linked to Ort.
     86 // dllexport is not used, we use a .def file.
     87 #  ifdef ORT_DLL_IMPORT
     88 #    define ORT_EXPORT __declspec(dllimport)
     89 #  else
     90 #    define ORT_EXPORT
     91 #  endif
     92 #  define ORT_API_CALL _stdcall
     93 #  define ORT_MUST_USE_RESULT
     94 #  define ORTCHAR_T wchar_t
     95 #else
     96 // To make symbols visible on macOS/iOS
     97 #  ifdef __APPLE__
     98 #    define ORT_EXPORT __attribute__((visibility("default")))
     99 #  else
    100 #    define ORT_EXPORT
    101 #  endif
    102 #  define ORT_API_CALL
    103 #  define ORT_MUST_USE_RESULT __attribute__((warn_unused_result))
    104 #  define ORTCHAR_T char
    105 #endif
    106 
    107 /// ORTCHAR_T, ORT_TSTR are reserved specifically for path handling.
    108 /// All other strings are UTF-8 encoded, use char and std::string
    109 #ifndef ORT_TSTR
    110 #  ifdef _WIN32
    111 #    define ORT_TSTR(X) L##X
    112 // When X is a macro, L##X is not defined. In this case, we need to use
    113 // ORT_TSTR_ON_MACRO.
    114 #    define ORT_TSTR_ON_MACRO(X) L"" X
    115 #  else
    116 #    define ORT_TSTR(X) X
    117 #    define ORT_TSTR_ON_MACRO(X) X
    118 #  endif
    119 #endif
    120 
    121 // On Windows, ORT_FILE is a wchar_t version of the __FILE__ macro.
    122 // Otherwise, ORT_FILE is equivalent to __FILE__.
    123 #ifndef ORT_FILE
    124 #  define ORT_FILE_INTERNAL(x) ORT_TSTR(x)
    125 #  define ORT_FILE ORT_FILE_INTERNAL(__FILE__)
    126 #endif
    127 
    128 // Any pointer marked with _In_ or _Out_, cannot be NULL.
    129 
    130 // Windows users should use unicode paths when possible to bypass the MAX_PATH
    131 // limitation Every pointer marked with _In_ or _Out_, cannot be NULL. Caller
    132 // should ensure that. for ReleaseXXX(...) functions, they can accept NULL
    133 // pointer.
    134 
    135 #ifdef __cplusplus
    136 // For any compiler with C++11 support, MSVC 2015 and greater, or Clang version
    137 // supporting noexcept. Such complex condition is needed because compilers set
    138 // __cplusplus value differently.
    139 #  ifndef __has_feature
    140 #    define __has_feature(x) 0
    141 #  endif
    142 #  if ((__cplusplus >= 201103L) || (_MSC_VER >= 1900) || \
    143       (defined(__has_feature) && __has_feature(cxx_noexcept)))
    144 #    define NO_EXCEPTION noexcept
    145 #  else
    146 #    define NO_EXCEPTION throw()
    147 #  endif
    148 #else
    149 #  define NO_EXCEPTION
    150 #endif
    151 
    152 // __VA_ARGS__ on Windows and Linux are different
    153 #define ORT_API(RETURN_TYPE, NAME, ...) \
    154  RETURN_TYPE ORT_API_CALL NAME(__VA_ARGS__) NO_EXCEPTION
    155 
    156 #define ORT_API_STATUS(NAME, ...)                              \
    157  _Success_(return == 0)                                       \
    158      _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL \
    159      NAME(__VA_ARGS__)                                        \
    160  NO_EXCEPTION ORT_MUST_USE_RESULT
    161 
    162 // XXX: Unfortunately, SAL annotations are known to not work with function
    163 // pointers
    164 #define ORT_API2_STATUS(NAME, ...)                                             \
    165  _Check_return_ _Ret_maybenull_ OrtStatusPtr(ORT_API_CALL* NAME)(__VA_ARGS__) \
    166      NO_EXCEPTION ORT_MUST_USE_RESULT
    167 
    168 // Used in *.cc files. Almost as same as ORT_API_STATUS, except without
    169 // ORT_MUST_USE_RESULT and ORT_EXPORT
    170 #define ORT_API_STATUS_IMPL(NAME, ...)                         \
    171  _Success_(return == 0)                                       \
    172      _Check_return_ _Ret_maybenull_ OrtStatusPtr ORT_API_CALL \
    173      NAME(__VA_ARGS__) NO_EXCEPTION
    174 
    175 #define ORT_CLASS_RELEASE(X) \
    176  void(ORT_API_CALL * Release##X)(_Frees_ptr_opt_ Ort##X * input)
    177 
    178 #ifdef __DOXYGEN__
    179 #  undef ORT_API_STATUS
    180 #  define ORT_API_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
    181 #  undef ORT_API2_STATUS
    182 #  define ORT_API2_STATUS(NAME, ...) OrtStatus* NAME(__VA_ARGS__)
    183 #  undef ORT_CLASS_RELEASE
    184 #  define ORT_CLASS_RELEASE(X) void Release##X(Ort##X* input)
    185 #  undef NO_EXCEPTION
    186 #  define NO_EXCEPTION
    187 #endif
    188 /** \addtogroup Global
    189 * ONNX Runtime C API
    190 * @{
    191 */
    192 
    193 /** Copied from TensorProto::DataType
    194 * Currently, Ort doesn't support complex64, complex128
    195 */
    196 typedef enum ONNXTensorElementDataType {
    197  ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED,
    198  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,   // maps to c type float
    199  ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8,   // maps to c type uint8_t
    200  ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8,    // maps to c type int8_t
    201  ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16,  // maps to c type uint16_t
    202  ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16,   // maps to c type int16_t
    203  ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32,   // maps to c type int32_t
    204  ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64,   // maps to c type int64_t
    205  ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING,  // maps to c++ type std::string
    206  ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL,
    207  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16,
    208  ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE,      // maps to c type double
    209  ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32,      // maps to c type uint32_t
    210  ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64,      // maps to c type uint64_t
    211  ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64,   // complex with float32 real and
    212                                             // imaginary components
    213  ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128,  // complex with float64 real and
    214                                             // imaginary components
    215  ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16,    // Non-IEEE floating-point format
    216                                           // based on IEEE754 single-precision
    217  // float 8 types were introduced in onnx 1.14, see
    218  // https://onnx.ai/onnx/technical/float8.html
    219  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FN,  // Non-IEEE floating-point format
    220                                               // based on IEEE754
    221                                               // single-precision
    222  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E4M3FNUZ,  // Non-IEEE floating-point
    223                                                 // format based on IEEE754
    224                                                 // single-precision
    225  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2,  // Non-IEEE floating-point format
    226                                             // based on IEEE754
    227                                             // single-precision
    228  ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT8E5M2FNUZ,  // Non-IEEE floating-point
    229                                                 // format based on IEEE754
    230                                                 // single-precision
    231  // Int4 types were introduced in ONNX 1.16. See
    232  // https://onnx.ai/onnx/technical/int4.html
    233  ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT4,  // maps to a pair of packed uint4 values
    234                                        // (size == 1 byte)
    235  ONNX_TENSOR_ELEMENT_DATA_TYPE_INT4    // maps to a pair of packed int4 values
    236                                        // (size == 1 byte)
    237 } ONNXTensorElementDataType;
    238 
    239 // Synced with onnx TypeProto oneof
    240 typedef enum ONNXType {
    241  ONNX_TYPE_UNKNOWN,
    242  ONNX_TYPE_TENSOR,
    243  ONNX_TYPE_SEQUENCE,
    244  ONNX_TYPE_MAP,
    245  ONNX_TYPE_OPAQUE,
    246  ONNX_TYPE_SPARSETENSOR,
    247  ONNX_TYPE_OPTIONAL
    248 } ONNXType;
    249 
    250 // These types are synced with internal
    251 // SparseFormatFlags
    252 typedef enum OrtSparseFormat {
    253  ORT_SPARSE_UNDEFINED = 0,
    254  ORT_SPARSE_COO = 0x1,
    255  ORT_SPARSE_CSRC = 0x2,
    256  ORT_SPARSE_BLOCK_SPARSE = 0x4
    257 } OrtSparseFormat;
    258 
    259 // Enum allows to query sparse tensor indices
    260 enum OrtSparseIndicesFormat {
    261  ORT_SPARSE_COO_INDICES,
    262  ORT_SPARSE_CSR_INNER_INDICES,
    263  ORT_SPARSE_CSR_OUTER_INDICES,
    264  ORT_SPARSE_BLOCK_SPARSE_INDICES
    265 };
    266 
    267 /** \brief Logging severity levels
    268 *
    269 * In typical API usage, specifying a logging severity level specifies the
    270 * minimum severity of log messages to show.
    271 */
    272 typedef enum OrtLoggingLevel {
    273  ORT_LOGGING_LEVEL_VERBOSE,  ///< Verbose informational messages (least
    274                              ///< severe).
    275  ORT_LOGGING_LEVEL_INFO,     ///< Informational messages.
    276  ORT_LOGGING_LEVEL_WARNING,  ///< Warning messages.
    277  ORT_LOGGING_LEVEL_ERROR,    ///< Error messages.
    278  ORT_LOGGING_LEVEL_FATAL,    ///< Fatal error messages (most severe).
    279 } OrtLoggingLevel;
    280 
    281 typedef enum OrtErrorCode {
    282  ORT_OK,
    283  ORT_FAIL,
    284  ORT_INVALID_ARGUMENT,
    285  ORT_NO_SUCHFILE,
    286  ORT_NO_MODEL,
    287  ORT_ENGINE_ERROR,
    288  ORT_RUNTIME_EXCEPTION,
    289  ORT_INVALID_PROTOBUF,
    290  ORT_MODEL_LOADED,
    291  ORT_NOT_IMPLEMENTED,
    292  ORT_INVALID_GRAPH,
    293  ORT_EP_FAIL,
    294 } OrtErrorCode;
    295 
    296 typedef enum OrtOpAttrType {
    297  ORT_OP_ATTR_UNDEFINED = 0,
    298  ORT_OP_ATTR_INT,
    299  ORT_OP_ATTR_INTS,
    300  ORT_OP_ATTR_FLOAT,
    301  ORT_OP_ATTR_FLOATS,
    302  ORT_OP_ATTR_STRING,
    303  ORT_OP_ATTR_STRINGS,
    304 } OrtOpAttrType;
    305 
    306 //! @}
    307 #define ORT_RUNTIME_CLASS(X) \
    308  struct Ort##X;             \
    309  typedef struct Ort##X Ort##X
    310 
    311 /** \addtogroup Global
    312 * ONNX Runtime C API
    313 * @{
    314 */
    315 // The actual types defined have an Ort prefix
    316 ORT_RUNTIME_CLASS(Env);
    317 ORT_RUNTIME_CLASS(Status);  // nullptr for Status* indicates success
    318 ORT_RUNTIME_CLASS(MemoryInfo);
    319 ORT_RUNTIME_CLASS(IoBinding);
    320 ORT_RUNTIME_CLASS(Session);  // Don't call ReleaseSession from Dllmain (because
    321                             // session owns a thread pool)
    322 ORT_RUNTIME_CLASS(Value);
    323 ORT_RUNTIME_CLASS(RunOptions);
    324 ORT_RUNTIME_CLASS(TypeInfo);
    325 ORT_RUNTIME_CLASS(TensorTypeAndShapeInfo);
    326 ORT_RUNTIME_CLASS(MapTypeInfo);
    327 ORT_RUNTIME_CLASS(SequenceTypeInfo);
    328 ORT_RUNTIME_CLASS(OptionalTypeInfo);
    329 ORT_RUNTIME_CLASS(SessionOptions);
    330 ORT_RUNTIME_CLASS(CustomOpDomain);
    331 ORT_RUNTIME_CLASS(ModelMetadata);
    332 ORT_RUNTIME_CLASS(ThreadPoolParams);
    333 ORT_RUNTIME_CLASS(ThreadingOptions);
    334 ORT_RUNTIME_CLASS(ArenaCfg);
    335 ORT_RUNTIME_CLASS(PrepackedWeightsContainer);
    336 ORT_RUNTIME_CLASS(TensorRTProviderOptionsV2);
    337 ORT_RUNTIME_CLASS(CUDAProviderOptionsV2);
    338 ORT_RUNTIME_CLASS(CANNProviderOptions);
    339 ORT_RUNTIME_CLASS(DnnlProviderOptions);
    340 ORT_RUNTIME_CLASS(Op);
    341 ORT_RUNTIME_CLASS(OpAttr);
    342 ORT_RUNTIME_CLASS(Logger);
    343 ORT_RUNTIME_CLASS(ShapeInferContext);
    344 ORT_RUNTIME_CLASS(LoraAdapter);
    345 ORT_RUNTIME_CLASS(ValueInfo);
    346 ORT_RUNTIME_CLASS(Node);
    347 ORT_RUNTIME_CLASS(Graph);
    348 ORT_RUNTIME_CLASS(Model);
    349 
    350 #ifdef _MSC_VER
    351 typedef _Return_type_success_(return == 0) OrtStatus* OrtStatusPtr;
    352 #else
    353 typedef OrtStatus* OrtStatusPtr;
    354 #endif
    355 
    356 /** \brief Memory allocation interface
    357 *
    358 * Structure of function pointers that defines a memory allocator. This can be
    359 * created and filled in by the user for custom allocators.
    360 *
    361 * When an allocator is passed to any function, be sure that the allocator
    362 * object is not destroyed until the last allocated object using it is freed.
    363 */
    364 typedef struct OrtAllocator {
    365  uint32_t version;  ///< Must be initialized to ORT_API_VERSION
    366  void*(ORT_API_CALL* Alloc)(struct OrtAllocator* this_,
    367                             size_t size);  ///< Returns a pointer to an
    368                                            ///< allocated block of `size` bytes
    369  void(ORT_API_CALL* Free)(struct OrtAllocator* this_,
    370                           void* p);  ///< Free a block of memory previously
    371                                      ///< allocated with OrtAllocator::Alloc
    372  const struct OrtMemoryInfo*(ORT_API_CALL* Info)(
    373      const struct OrtAllocator*
    374          this_);  ///< Return a pointer to an ::OrtMemoryInfo that describes
    375                   ///< this allocator
    376  /**
    377   * @brief Optional allocation function to use for memory allocations made
    378   * during session initialization. Use this function if you want to separate
    379   * allocations made by ORT during Run() calls from those made during session
    380   * initialization. This allows for separate memory management strategies for
    381   * these allocations.
    382   */
    383  void*(ORT_API_CALL* Reserve)(
    384      struct OrtAllocator* this_,
    385      size_t
    386          size);  ///< Returns a pointer to an allocated block of `size` bytes
    387 } OrtAllocator;
    388 
    389 typedef void(ORT_API_CALL* OrtLoggingFunction)(
    390    void* param, OrtLoggingLevel severity, const char* category,
    391    const char* logid, const char* code_location, const char* message);
    392 
    393 /** \brief Graph optimization level
    394 *
    395 * Refer to
    396 * https://www.onnxruntime.ai/docs/performance/graph-optimizations.html#graph-optimization-levels
    397 * for an in-depth understanding of the Graph Optimization Levels.
    398 */
    399 typedef enum GraphOptimizationLevel {
    400  ORT_DISABLE_ALL = 0,
    401  ORT_ENABLE_BASIC = 1,
    402  ORT_ENABLE_EXTENDED = 2,
    403  ORT_ENABLE_ALL = 99
    404 } GraphOptimizationLevel;
    405 
    406 typedef enum ExecutionMode {
    407  ORT_SEQUENTIAL = 0,
    408  ORT_PARALLEL = 1,
    409 } ExecutionMode;
    410 
    411 /** \brief Language projection identifiers
    412 * /see OrtApi::SetLanguageProjection
    413 */
    414 typedef enum OrtLanguageProjection {
    415  ORT_PROJECTION_C = 0,
    416  ORT_PROJECTION_CPLUSPLUS = 1,
    417  ORT_PROJECTION_CSHARP = 2,
    418  ORT_PROJECTION_PYTHON = 3,
    419  ORT_PROJECTION_JAVA = 4,
    420  ORT_PROJECTION_WINML = 5,
    421  ORT_PROJECTION_NODEJS = 6,
    422 } OrtLanguageProjection;
    423 
    424 struct OrtKernelInfo;
    425 typedef struct OrtKernelInfo OrtKernelInfo;
    426 struct OrtKernelContext;
    427 typedef struct OrtKernelContext OrtKernelContext;
    428 struct OrtCustomOp;
    429 typedef struct OrtCustomOp OrtCustomOp;
    430 
    431 typedef enum OrtAllocatorType {
    432  OrtInvalidAllocator = -1,
    433  OrtDeviceAllocator = 0,
    434  OrtArenaAllocator = 1
    435 } OrtAllocatorType;
    436 
    437 /** \brief Memory types for allocated memory, execution provider specific types
    438 * should be extended in each provider.
    439 */
    440 // Whenever this struct is updated, please also update the MakeKey function in
    441 // onnxruntime / core / framework / execution_provider.cc
    442 typedef enum OrtMemType {
    443  OrtMemTypeCPUInput =
    444      -2,  ///< Any CPU memory used by non-CPU execution provider
    445  OrtMemTypeCPUOutput = -1,  ///< CPU accessible memory outputted by non-CPU
    446                             ///< execution provider, i.e. CUDA_PINNED
    447  OrtMemTypeCPU =
    448      OrtMemTypeCPUOutput,  ///< Temporary CPU accessible memory allocated by
    449                            ///< non-CPU execution provider, i.e. CUDA_PINNED
    450  OrtMemTypeDefault = 0,    ///< The default allocator for execution provider
    451 } OrtMemType;
    452 
    453 /** \brief This mimics OrtDevice type constants so they can be returned in the
    454 * API
    455 */
    456 typedef enum OrtMemoryInfoDeviceType {
    457  OrtMemoryInfoDeviceType_CPU = 0,
    458  OrtMemoryInfoDeviceType_GPU = 1,
    459  OrtMemoryInfoDeviceType_FPGA = 2
    460 } OrtMemoryInfoDeviceType;
    461 
    462 /** \brief Algorithm to use for cuDNN Convolution Op
    463 */
    464 typedef enum OrtCudnnConvAlgoSearch {
    465  OrtCudnnConvAlgoSearchExhaustive,  // expensive exhaustive benchmarking using
    466                                     // cudnnFindConvolutionForwardAlgorithmEx
    467  OrtCudnnConvAlgoSearchHeuristic,   // lightweight heuristic based search using
    468                                     // cudnnGetConvolutionForwardAlgorithm_v7
    469  OrtCudnnConvAlgoSearchDefault,     // default algorithm using
    470                                  // CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM
    471 } OrtCudnnConvAlgoSearch;
    472 
    473 /** \brief CUDA Provider Options
    474 *
    475 * \see OrtApi::SessionOptionsAppendExecutionProvider_CUDA
    476 */
    477 typedef struct OrtCUDAProviderOptions {
    478 #ifdef __cplusplus
    479  OrtCUDAProviderOptions()
    480      : device_id{},
    481        cudnn_conv_algo_search{OrtCudnnConvAlgoSearchExhaustive},
    482        gpu_mem_limit{SIZE_MAX},
    483        arena_extend_strategy{},
    484        do_copy_in_default_stream{1},
    485        has_user_compute_stream{},
    486        user_compute_stream{},
    487        default_memory_arena_cfg{},
    488        tunable_op_enable{false},
    489        tunable_op_tuning_enable{false},
    490        tunable_op_max_tuning_duration_ms{} {}
    491 #endif
    492 
    493  /** \brief CUDA device Id
    494   *   Defaults to 0.
    495   */
    496  int device_id;
    497 
    498  /** \brief CUDA Convolution algorithm search configuration.
    499   *   See enum OrtCudnnConvAlgoSearch for more details.
    500   *   Defaults to OrtCudnnConvAlgoSearchExhaustive.
    501   */
    502  OrtCudnnConvAlgoSearch cudnn_conv_algo_search;
    503 
    504  /** \brief CUDA memory limit (To use all possible memory pass in maximum
    505   * size_t) Defaults to SIZE_MAX.
    506   *   \note If a ::OrtArenaCfg has been applied, it will override this field
    507   */
    508  size_t gpu_mem_limit;
    509 
    510  /** \brief Strategy used to grow the memory arena
    511   *   0 = kNextPowerOfTwo<br>
    512   *   1 = kSameAsRequested<br>
    513   *   Defaults to 0.
    514   *   \note If a ::OrtArenaCfg has been applied, it will override this field
    515   */
    516  int arena_extend_strategy;
    517 
    518  /** \brief Flag indicating if copying needs to take place on the same stream
    519   * as the compute stream in the CUDA EP 0 = Use separate streams for copying
    520   * and compute. 1 = Use the same stream for copying and compute. Defaults
    521   * to 1. WARNING: Setting this to 0 may result in data races for some models.
    522   *   Please see issue #4829 for more details.
    523   */
    524  int do_copy_in_default_stream;
    525 
    526  /** \brief Flag indicating if there is a user provided compute stream
    527   *   Defaults to 0.
    528   */
    529  int has_user_compute_stream;
    530 
    531  /** \brief User provided compute stream.
    532   *   If provided, please set `has_user_compute_stream` to 1.
    533   */
    534  void* user_compute_stream;
    535 
    536  /** \brief CUDA memory arena configuration parameters
    537   */
    538  OrtArenaCfg* default_memory_arena_cfg;
    539 
    540  /** \brief Enable TunableOp for using.
    541   *   Set it to 1/0 to enable/disable TunableOp. Otherwise, it is disabled by
    542   * default. This option can be overridden by environment variable
    543   * ORT_CUDA_TUNABLE_OP_ENABLE.
    544   */
    545  int tunable_op_enable;
    546 
    547  /** \brief Enable TunableOp for tuning.
    548   *   Set it to 1/0 to enable/disable TunableOp tuning. Otherwise, it is
    549   * disabled by default. This option can be overridden by environment variable
    550   * ORT_CUDA_TUNABLE_OP_TUNING_ENABLE.
    551   */
    552  int tunable_op_tuning_enable;
    553 
    554  /** \brief Max tuning duration time limit for each instance of TunableOp.
    555   *   Defaults to 0 to disable the limit.
    556   */
    557  int tunable_op_max_tuning_duration_ms;
    558 
    559 } OrtCUDAProviderOptions;
    560 
    561 /** \brief ROCM Provider Options
    562 *
    563 * \see OrtApi::SessionOptionsAppendExecutionProvider_ROCM
    564 */
    565 typedef struct OrtROCMProviderOptions {
    566 #ifdef __cplusplus
    567  OrtROCMProviderOptions()
    568      : device_id{},
    569        miopen_conv_exhaustive_search{0},
    570        gpu_mem_limit{SIZE_MAX},
    571        arena_extend_strategy{},
    572        do_copy_in_default_stream{1},
    573        has_user_compute_stream{},
    574        user_compute_stream{},
    575        default_memory_arena_cfg{},
    576        enable_hip_graph{false},
    577        tunable_op_enable{false},
    578        tunable_op_tuning_enable{false},
    579        tunable_op_max_tuning_duration_ms{} {}
    580 #endif
    581 
    582  /** \brief ROCM device Id
    583   *   Defaults to 0.
    584   */
    585  int device_id;
    586 
    587  /** \brief ROCM MIOpen Convolution algorithm exaustive search option.
    588   *   Defaults to 0 (false).
    589   */
    590  int miopen_conv_exhaustive_search;
    591 
    592  /** \brief ROCM memory limit (To use all possible memory pass in maximum
    593   * size_t) Defaults to SIZE_MAX.
    594   *   \note If a ::OrtArenaCfg has been applied, it will override this field
    595   */
    596  size_t gpu_mem_limit;
    597 
    598  /** \brief Strategy used to grow the memory arena
    599   *   0 = kNextPowerOfTwo<br>
    600   *   1 = kSameAsRequested<br>
    601   *   Defaults to 0.
    602   *   \note If a ::OrtArenaCfg has been applied, it will override this field
    603   */
    604  int arena_extend_strategy;
    605 
    606  /** \brief Flag indicating if copying needs to take place on the same stream
    607   * as the compute stream in the ROCM EP 0 = Use separate streams for copying
    608   * and compute. 1 = Use the same stream for copying and compute. Defaults
    609   * to 1. WARNING: Setting this to 0 may result in data races for some models.
    610   *   Please see issue #4829 for more details.
    611   */
    612  int do_copy_in_default_stream;
    613 
    614  /** \brief Flag indicating if there is a user provided compute stream
    615   *   Defaults to 0.
    616   */
    617  int has_user_compute_stream;
    618 
    619  /** \brief User provided compute stream.
    620   *   If provided, please set `has_user_compute_stream` to 1.
    621   */
    622  void* user_compute_stream;
    623 
    624  /** \brief ROCM memory arena configuration parameters
    625   */
    626  OrtArenaCfg* default_memory_arena_cfg;
    627 
    628  int enable_hip_graph;
    629 
    630  /** \brief Enable TunableOp for using.
    631   *   Set it to 1/0 to enable/disable TunableOp. Otherwise, it is disabled by
    632   * default. This option can be overridden by environment variable
    633   * ORT_ROCM_TUNABLE_OP_ENABLE.
    634   */
    635  int tunable_op_enable;
    636 
    637  /** \brief Enable TunableOp for tuning.
    638   *   Set it to 1/0 to enable/disable TunableOp tuning. Otherwise, it is
    639   * disabled by default. This option can be overridden by environment variable
    640   * ORT_ROCM_TUNABLE_OP_TUNING_ENABLE.
    641   */
    642  int tunable_op_tuning_enable;
    643 
    644  /** \brief Max tuning duration time limit for each instance of TunableOp.
    645   *   Defaults to 0 to disable the limit.
    646   */
    647  int tunable_op_max_tuning_duration_ms;
    648 
    649 } OrtROCMProviderOptions;
    650 
    651 /** \brief TensorRT Provider Options
    652 *
    653 * \see OrtApi::SessionOptionsAppendExecutionProvider_TensorRT
    654 */
    655 typedef struct OrtTensorRTProviderOptions {
    656  int device_id;                     ///< CUDA device id (0 = default device)
    657  int has_user_compute_stream;       // indicator of user specified CUDA compute
    658                                     // stream.
    659  void* user_compute_stream;         // user specified CUDA compute stream.
    660  int trt_max_partition_iterations;  // maximum iterations for TensorRT parser
    661                                     // to get capability
    662  int trt_min_subgraph_size;         // minimum size of TensorRT subgraphs
    663  size_t trt_max_workspace_size;     // maximum workspace size for TensorRT.
    664  int trt_fp16_enable;  // enable TensorRT FP16 precision. Default 0 = false,
    665                        // nonzero = true
    666  int trt_int8_enable;  // enable TensorRT INT8 precision. Default 0 = false,
    667                        // nonzero = true
    668  const char*
    669      trt_int8_calibration_table_name;  // TensorRT INT8 calibration table name.
    670  int trt_int8_use_native_calibration_table;  // use native TensorRT generated
    671                                              // calibration table. Default 0 =
    672                                              // false, nonzero = true
    673  int trt_dla_enable;      // enable DLA. Default 0 = false, nonzero = true
    674  int trt_dla_core;        // DLA core number. Default 0
    675  int trt_dump_subgraphs;  // dump TRT subgraph. Default 0 = false, nonzero =
    676                           // true
    677  int trt_engine_cache_enable;  // enable engine caching. Default 0 = false,
    678                                // nonzero = true
    679  const char* trt_engine_cache_path;  // specify engine cache path
    680  int trt_engine_decryption_enable;   // enable engine decryption. Default 0 =
    681                                      // false, nonzero = true
    682  const char*
    683      trt_engine_decryption_lib_path;  // specify engine decryption library path
    684  int trt_force_sequential_engine_build;  // force building TensorRT engine
    685                                          // sequentially. Default 0 = false,
    686                                          // nonzero = true
    687  // This is the legacy struct and don't add new fields here.
    688  // For new field that can be represented by string, please add it in
    689  // include/onnxruntime/core/providers/tensorrt/tensorrt_provider_options.h For
    690  // non-string field, need to create a new separate api to handle it.
    691 } OrtTensorRTProviderOptions;
    692 
    693 /** \brief MIGraphX Provider Options
    694 *
    695 * \see OrtApi::SessionOptionsAppendExecutionProvider_MIGraphX
    696 */
    697 typedef struct OrtMIGraphXProviderOptions {
    698  int device_id;             // hip device id.
    699  int migraphx_fp16_enable;  // MIGraphX FP16 precision. Default 0 = false,
    700                             // nonzero = true
    701  int migraphx_int8_enable;  // MIGraphX INT8 precision. Default 0 = false,
    702                             // nonzero = true
    703  int migraphx_use_native_calibration_table;  // MIGraphx INT8 cal table.
    704                                              // Default 0 = false, noznero =
    705                                              // true
    706  const char* migraphx_int8_calibration_table_name;  // MIGraphx INT8
    707                                                     // calibration table name
    708  int migraphx_save_compiled_model;  // migraphx save compiled model. Default 0
    709                                     // = false, noznero = true
    710  const char* migraphx_save_model_path;  // migraphx model path name
    711  int migraphx_load_compiled_model;      // migraphx int8 cal table. Default 0 =
    712                                         // false, noznero = true
    713  const char* migraphx_load_model_path;  // migraphx model path name
    714  bool migraphx_exhaustive_tune;  // migraphx tuned compile  Default = false
    715 } OrtMIGraphXProviderOptions;
    716 
    717 /** \brief OpenVINO Provider Options
    718 *  \brief This Struct is frozen since ORT 1.13.0. Its maintained part of Legacy
    719 * API for compatibility.
    720 *  \brief For latest OpenVINO Provider Options update to the ProviderOptions
    721 * map.
    722 *  \brief Latest OpenVINO Provider Options are listed in the
    723 *  \htmlonly
    724 *  <a
    725 * href="https://onnxruntime.ai/docs/execution-providers/OpenVINO-ExecutionProvider.html#summary-of-options">onnxruntime
    726 * document.</a>
    727 *  \endhtmlonly
    728 * \see OrtApi::SessionOptionsAppendExecutionProvider()
    729 */
    730 typedef struct OrtOpenVINOProviderOptions {
    731 #ifdef __cplusplus
    732  OrtOpenVINOProviderOptions()
    733      : device_type{},
    734        enable_npu_fast_compile{},
    735        device_id{},
    736        num_of_threads{},
    737        cache_dir{},
    738        context{},
    739        enable_opencl_throttling{},
    740        enable_dynamic_shapes{} {}
    741 #endif
    742  /** \brief Device type string
    743   *
    744   * Valid settings are one of: "CPU_FP32", "CPU_FP16", "GPU_FP32", "GPU_FP16"
    745   */
    746  const char* device_type;
    747  unsigned char enable_npu_fast_compile;  ///< 0 = disabled, nonzero = enabled
    748  const char* device_id;
    749  size_t num_of_threads;  ///< 0 = Use default number of threads
    750  const char* cache_dir;  // path is set to empty by default
    751  void* context;
    752  unsigned char enable_opencl_throttling;  ///< 0 = disabled, nonzero = enabled
    753  unsigned char enable_dynamic_shapes;     ///< 0 = disabled, nonzero = enabled
    754 } OrtOpenVINOProviderOptions;
    755 
    756 struct OrtApi;
    757 typedef struct OrtApi OrtApi;
    758 
    759 struct OrtTrainingApi;
    760 typedef struct OrtTrainingApi OrtTrainingApi;
    761 
    762 struct OrtModelEditorApi;
    763 typedef struct OrtModelEditorApi OrtModelEditorApi;
    764 
    765 /** \brief The helper interface to get the right version of OrtApi
    766 *
    767 * Get a pointer to this structure through ::OrtGetApiBase
    768 */
    769 struct OrtApiBase {
    770  /** \brief Get a pointer to the requested version of the ::OrtApi
    771   *
    772   * \param[in] version Must be ::ORT_API_VERSION
    773   * \return The ::OrtApi for the version requested, nullptr will be returned if
    774   * this version is unsupported, for example when using a runtime older than
    775   * the version created with this header file.
    776   *
    777   * One can call GetVersionString() to get the version of the Onnxruntime
    778   * library for logging and error reporting purposes.
    779   */
    780  const OrtApi*(ORT_API_CALL* GetApi)(uint32_t version)NO_EXCEPTION;
    781 
    782  /** \brief Returns a null terminated string of the version of the Onnxruntime
    783   * library (eg: "1.8.1")
    784   *
    785   *  \return UTF-8 encoded version string. Do not deallocate the returned
    786   * buffer.
    787   */
    788  const char*(ORT_API_CALL* GetVersionString)(void)NO_EXCEPTION;
    789 };
    790 
    791 typedef struct OrtApiBase OrtApiBase;
    792 
    793 /** \brief The Onnxruntime library's entry point to access the C API
    794 *
    795 * Call this to get the a pointer to an ::OrtApiBase
    796 */
    797 ORT_EXPORT const OrtApiBase* ORT_API_CALL OrtGetApiBase(void) NO_EXCEPTION;
    798 
    799 /** \brief Thread work loop function
    800 *
    801 * Onnxruntime will provide the working loop on custom thread creation
    802 * Argument is an onnxruntime built-in type which will be provided when thread
    803 * pool calls OrtCustomCreateThreadFn
    804 */
    805 typedef void (*OrtThreadWorkerFn)(void* ort_worker_fn_param);
    806 
    807 typedef const struct OrtCustomHandleType {
    808  char __place_holder;
    809 }* OrtCustomThreadHandle;
    810 
    811 /** \brief Ort custom thread creation function
    812 *
    813 * The function should return a thread handle to be used in onnxruntime thread
    814 * pools Onnxruntime will throw exception on return value of nullptr or 0,
    815 * indicating that the function failed to create a thread
    816 */
    817 typedef OrtCustomThreadHandle (*OrtCustomCreateThreadFn)(
    818    void* ort_custom_thread_creation_options,
    819    OrtThreadWorkerFn ort_thread_worker_fn, void* ort_worker_fn_param);
    820 
    821 /** \brief Custom thread join function
    822 *
    823 * Onnxruntime thread pool destructor will call the function to join a custom
    824 * thread. Argument ort_custom_thread_handle is the value returned by
    825 * OrtCustomCreateThreadFn
    826 */
    827 typedef void (*OrtCustomJoinThreadFn)(
    828    OrtCustomThreadHandle ort_custom_thread_handle);
    829 
    830 typedef OrtStatus*(ORT_API_CALL* RegisterCustomOpsFn)(
    831    OrtSessionOptions* options, const OrtApiBase* api);
    832 
    833 /** \brief Callback function for RunAsync
    834 *
    835 * \param[in] user_data User specific data that passed back to the callback
    836 * \param[out] outputs On succeed, outputs host inference results, on error, the
    837 * value will be nullptr
    838 * \param[out] num_outputs Number of outputs, on error, the value will be zero
    839 * \param[out] status On error, status will provide details
    840 */
    841 typedef void (*RunAsyncCallbackFn)(void* user_data, OrtValue** outputs,
    842                                   size_t num_outputs, OrtStatusPtr status);
    843 
    844 /** \brief The C API
    845 *
    846 * All C API functions are defined inside this structure as pointers to
    847 * functions. Call OrtApiBase::GetApi to get a pointer to it
    848 *
    849 * \nosubgrouping
    850 */
    851 struct OrtApi {
    852  /// \name OrtStatus
    853  /// @{
    854 
    855  /**
    856   * \brief Create an OrtStatus from a null terminated string
    857   *
    858   * \param[in] code
    859   * \param[in] msg A null-terminated string. Its contents will be copied.
    860   * \return A new OrtStatus object, must be destroyed with
    861   * OrtApi::ReleaseStatus
    862   */
    863  OrtStatus*(ORT_API_CALL* CreateStatus)(
    864      OrtErrorCode code, _In_ const char* msg)NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
    865 
    866  /** \brief Get OrtErrorCode from OrtStatus
    867   *
    868   * \param[in] status
    869   * \return OrtErrorCode that \p status was created with
    870   */
    871  OrtErrorCode(ORT_API_CALL* GetErrorCode)(_In_ const OrtStatus* status)
    872      NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
    873 
    874  /** \brief Get error string from OrtStatus
    875   *
    876   * \param[in] status
    877   * \return The error message inside the `status`. Do not free the returned
    878   * value.
    879   */
    880  const char*(ORT_API_CALL* GetErrorMessage)(_In_ const OrtStatus* status)
    881      NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
    882 
    883  /// @}
    884  /// \name OrtEnv
    885  /// @{
    886 
    887  /** \brief Create an OrtEnv
    888   *
    889   * \note Invoking this function will return the same instance of the
    890   * environment as that returned by a previous call to another env creation
    891   * function; all arguments to this function will be ignored.
    892   * \param[in] log_severity_level The log severity level.
    893   * \param[in] logid The log identifier.
    894   * \param[out] out Returned newly created OrtEnv. Must be freed with
    895   * OrtApi::ReleaseEnv
    896   *
    897   * \snippet{doc} snippets.dox OrtStatus Return Value
    898   */
    899  ORT_API2_STATUS(CreateEnv, OrtLoggingLevel log_severity_level,
    900                  _In_ const char* logid, _Outptr_ OrtEnv** out);
    901 
    902  /** \brief Create an OrtEnv
    903   *
    904   * \note Invoking this function will return the same instance of the
    905   * environment as that returned by a previous call to another env creation
    906   * function; all arguments to this function will be ignored. If you want to
    907   * provide your own logging function, consider setting it using the
    908   * SetUserLoggingFunction API instead.
    909   * \param[in] logging_function A pointer to a logging function.
    910   * \param[in] logger_param A pointer to arbitrary data passed as the
    911   * ::OrtLoggingFunction `param` parameter to `logging_function`. This
    912   * parameter is optional.
    913   * \param[in] log_severity_level The log severity level.
    914   * \param[in] logid The log identifier.
    915   * \param[out] out Returned newly created OrtEnv. Must be freed with
    916   * OrtApi::ReleaseEnv
    917   *
    918   * \snippet{doc} snippets.dox OrtStatus Return Value
    919   */
    920  ORT_API2_STATUS(CreateEnvWithCustomLogger,
    921                  _In_ OrtLoggingFunction logging_function,
    922                  _In_opt_ void* logger_param,
    923                  _In_ OrtLoggingLevel log_severity_level,
    924                  _In_ const char* logid, _Outptr_ OrtEnv** out);
    925 
    926  /** \brief Enable Telemetry
    927   *
    928   * \note Telemetry events are on by default since they are lightweight
    929   * \param[in] env
    930   *
    931   * \snippet{doc} snippets.dox OrtStatus Return Value
    932   */
    933  ORT_API2_STATUS(EnableTelemetryEvents, _In_ const OrtEnv* env);
    934  /** \brief Disable Telemetry
    935   *
    936   * \see OrtApi::EnableTelemetryEvents
    937   * \param[in] env
    938   *
    939   * \snippet{doc} snippets.dox OrtStatus Return Value
    940   */
    941  ORT_API2_STATUS(DisableTelemetryEvents, _In_ const OrtEnv* env);
    942 
    943  /// @}
    944  /// \name OrtSession
    945  /// @{
    946 
    947  /** \brief Create an OrtSession from a model file
    948   *
    949   * \param[in] env
    950   * \param[in] model_path
    951   * \param[in] options
    952   * \param[out] out Returned newly created OrtSession. Must be freed with
    953   * OrtApi::ReleaseSession
    954   *
    955   * \snippet{doc} snippets.dox OrtStatus Return Value
    956   */
    957  // TODO: document the path separator convention? '/' vs '\'
    958  // TODO: should specify the access characteristics of model_path. Is this read
    959  // only during the execution of CreateSession, or does the OrtSession retain a
    960  // handle to the file/directory and continue to access throughout the
    961  // OrtSession lifetime?
    962  //  What sort of access is needed to model_path : read or read/write?
    963  ORT_API2_STATUS(CreateSession, _In_ const OrtEnv* env,
    964                  _In_ const ORTCHAR_T* model_path,
    965                  _In_ const OrtSessionOptions* options,
    966                  _Outptr_ OrtSession** out);
    967 
    968  /** \brief Create an OrtSession from memory
    969   *
    970   * \param[in] env
    971   * \param[in] model_data
    972   * \param[in] model_data_length
    973   * \param[in] options
    974   * \param[out] out Returned newly created OrtSession. Must be freed with
    975   * OrtApi::ReleaseSession
    976   *
    977   * \snippet{doc} snippets.dox OrtStatus Return Value
    978   */
    979  ORT_API2_STATUS(CreateSessionFromArray, _In_ const OrtEnv* env,
    980                  _In_ const void* model_data, size_t model_data_length,
    981                  _In_ const OrtSessionOptions* options,
    982                  _Outptr_ OrtSession** out);
    983 
    984  /** \brief Run the model in an ::OrtSession
    985   *
    986   * Will not return until the model run has completed. Multiple threads might
    987   * be used to run the model based on the options in the ::OrtSession and
    988   * settings used when creating the ::OrtEnv
    989   *
    990   * \param[in] session
    991   * \param[in] run_options If nullptr, will use a default ::OrtRunOptions
    992   * \param[in] input_names Array of null terminated UTF8 encoded strings of the
    993   * input names
    994   * \param[in] inputs Array of ::OrtValue%s of the input values
    995   * \param[in] input_len Number of elements in the input_names and inputs
    996   * arrays
    997   * \param[in] output_names Array of null terminated UTF8 encoded strings of
    998   * the output names
    999   * \param[in] output_names_len Number of elements in the output_names and
   1000   * outputs array
   1001   * \param[out] outputs Array of ::OrtValue%s that the outputs are stored in.
   1002   * This can also be an array of nullptr values, in this case ::OrtValue
   1003   * objects will be allocated and pointers to them will be set into the
   1004   * `outputs` array.
   1005   *
   1006   * \snippet{doc} snippets.dox OrtStatus Return Value
   1007   */
   1008  ORT_API2_STATUS(Run, _Inout_ OrtSession* session,
   1009                  _In_opt_ const OrtRunOptions* run_options,
   1010                  _In_reads_(input_len) const char* const* input_names,
   1011                  _In_reads_(input_len) const OrtValue* const* inputs,
   1012                  size_t input_len,
   1013                  _In_reads_(output_names_len) const char* const* output_names,
   1014                  size_t output_names_len,
   1015                  _Inout_updates_all_(output_names_len) OrtValue** outputs);
   1016 
   1017  /// @}
   1018  /// \name OrtSessionOptions
   1019  /// @{
   1020 
   1021  /** \brief Create an ::OrtSessionOptions object
   1022   *
   1023   * To use additional providers, you must build ORT with the extra providers
   1024   * enabled. Then call one of these functions to enable them in the
   1025   * session:<br> OrtSessionOptionsAppendExecutionProvider_CPU<br>
   1026   *   OrtSessionOptionsAppendExecutionProvider_CUDA<br>
   1027   *   OrtSessionOptionsAppendExecutionProvider_(remaining providers...)<br>
   1028   * The order they are called indicates the preference order as well. In other
   1029   * words call this method on your most preferred execution provider first
   1030   * followed by the less preferred ones. If none are called Ort will use its
   1031   * internal CPU execution provider.
   1032   *
   1033   * \param[out] options The newly created OrtSessionOptions. Must be freed with
   1034   * OrtApi::ReleaseSessionOptions
   1035   *
   1036   * \snippet{doc} snippets.dox OrtStatus Return Value
   1037   */
   1038  ORT_API2_STATUS(CreateSessionOptions, _Outptr_ OrtSessionOptions** options);
   1039 
   1040  /** \brief Set filepath to save optimized model after graph level
   1041   * transformations
   1042   *
   1043   * \param[in] options
   1044   * \param[in] optimized_model_filepath
   1045   *
   1046   * \snippet{doc} snippets.dox OrtStatus Return Value
   1047   */
   1048  ORT_API2_STATUS(SetOptimizedModelFilePath, _Inout_ OrtSessionOptions* options,
   1049                  _In_ const ORTCHAR_T* optimized_model_filepath);
   1050 
   1051  /** \brief Create a copy of an existing ::OrtSessionOptions
   1052   *
   1053   * \param[in] in_options OrtSessionOptions to copy
   1054   * \param[out] out_options Returned newly created ::OrtSessionOptions. Must be
   1055   * freed with OrtApi::ReleaseSessionOptions
   1056   *
   1057   * \snippet{doc} snippets.dox OrtStatus Return Value
   1058   */
   1059  ORT_API2_STATUS(CloneSessionOptions, _In_ const OrtSessionOptions* in_options,
   1060                  _Outptr_ OrtSessionOptions** out_options);
   1061 
   1062  /** \brief Set execution mode
   1063   *
   1064   * Controls whether you want to execute operators in your graph sequentially
   1065   * or in parallel. Usually when the model has many branches, setting this
   1066   * option to ExecutionMode.ORT_PARALLEL will give you better performance. See
   1067   * [docs/ONNX_Runtime_Perf_Tuning.md] for more details.
   1068   *
   1069   * \param[in] options
   1070   * \param[in] execution_mode
   1071   *
   1072   * \snippet{doc} snippets.dox OrtStatus Return Value
   1073   */
   1074  ORT_API2_STATUS(SetSessionExecutionMode, _Inout_ OrtSessionOptions* options,
   1075                  ExecutionMode execution_mode);
   1076 
   1077  /** \brief Enable profiling for a session
   1078   *
   1079   * \param[in] options
   1080   * \param[in] profile_file_prefix
   1081   *
   1082   * \snippet{doc} snippets.dox OrtStatus Return Value
   1083   */
   1084  ORT_API2_STATUS(EnableProfiling, _Inout_ OrtSessionOptions* options,
   1085                  _In_ const ORTCHAR_T* profile_file_prefix);
   1086 
   1087  /** \brief Disable profiling for a session
   1088   *
   1089   * \param[in] options
   1090   *
   1091   * \snippet{doc} snippets.dox OrtStatus Return Value
   1092   */
   1093  ORT_API2_STATUS(DisableProfiling, _Inout_ OrtSessionOptions* options);
   1094 
   1095  /** \brief Enable the memory pattern optimization
   1096   *
   1097   * The idea is if the input shapes are the same, we could trace the internal
   1098   * memory allocation and generate a memory pattern for future request. So next
   1099   * time we could just do one allocation with a big chunk for all the internal
   1100   * memory allocation.
   1101   * \note Memory pattern optimization is only available when Sequential
   1102   * Execution mode is enabled (see OrtApi::SetSessionExecutionMode)
   1103   *
   1104   * \see OrtApi::DisableMemPattern
   1105   *
   1106   * \param[in] options
   1107   *
   1108   * \snippet{doc} snippets.dox OrtStatus Return Value
   1109   */
   1110  ORT_API2_STATUS(EnableMemPattern, _Inout_ OrtSessionOptions* options);
   1111 
   1112  /** \brief Disable the memory pattern optimization
   1113   *
   1114   * \see OrtApi::EnableMemPattern
   1115   *
   1116   * \param[in] options
   1117   *
   1118   * \snippet{doc} snippets.dox OrtStatus Return Value
   1119   */
   1120  ORT_API2_STATUS(DisableMemPattern, _Inout_ OrtSessionOptions* options);
   1121 
   1122  /** \brief Enable the memory arena on CPU
   1123   *
   1124   * Arena may pre-allocate memory for future usage.
   1125   *
   1126   * \param[in] options
   1127   *
   1128   * \snippet{doc} snippets.dox OrtStatus Return Value
   1129   */
   1130  ORT_API2_STATUS(EnableCpuMemArena, _Inout_ OrtSessionOptions* options);
   1131 
   1132  /** \brief Disable the memory arena on CPU
   1133   *
   1134   * \param[in] options
   1135   *
   1136   * \snippet{doc} snippets.dox OrtStatus Return Value
   1137   */
   1138  ORT_API2_STATUS(DisableCpuMemArena, _Inout_ OrtSessionOptions* options);
   1139 
   1140  /** \brief Set session log id
   1141   *
   1142   * \param[in] options
   1143   * \param[in] logid The log identifier.
   1144   *
   1145   * \snippet{doc} snippets.dox OrtStatus Return Value
   1146   */
   1147  ORT_API2_STATUS(SetSessionLogId, _Inout_ OrtSessionOptions* options,
   1148                  const char* logid);
   1149 
   1150  /** \brief Set session log verbosity level
   1151   *
   1152   * Applies to session load, initialization, etc
   1153   *
   1154   * \param[in] options
   1155   * \param[in] session_log_verbosity_level \snippet{doc} snippets.dox Log
   1156   * Verbosity Level
   1157   *
   1158   * \snippet{doc} snippets.dox OrtStatus Return Value
   1159   */
   1160  ORT_API2_STATUS(SetSessionLogVerbosityLevel,
   1161                  _Inout_ OrtSessionOptions* options,
   1162                  int session_log_verbosity_level);
   1163 
   1164  /** \brief Set session log severity level
   1165   *
   1166   * \param[in] options
   1167   * \param[in] session_log_severity_level The log severity level (refer to
   1168   * ::OrtLoggingLevel for possible values).
   1169   *
   1170   * \snippet{doc} snippets.dox OrtStatus Return Value
   1171   */
   1172  ORT_API2_STATUS(SetSessionLogSeverityLevel,
   1173                  _Inout_ OrtSessionOptions* options,
   1174                  int session_log_severity_level);
   1175 
   1176  /** \brief Set the optimization level to apply when loading a graph
   1177   *
   1178   * Please see
   1179   * https://onnxruntime.ai/docs/performance/model-optimizations/graph-optimizations.html
   1180   * for an in-depth explanation
   1181   * \param[in,out] options The session options object
   1182   * \param[in] graph_optimization_level The optimization level
   1183   *
   1184   * \snippet{doc} snippets.dox OrtStatus Return Value
   1185   */
   1186  ORT_API2_STATUS(SetSessionGraphOptimizationLevel,
   1187                  _Inout_ OrtSessionOptions* options,
   1188                  GraphOptimizationLevel graph_optimization_level);
   1189 
   1190  /** \brief Sets the number of threads used to parallelize the execution within
   1191   * nodes
   1192   *
   1193   * When running a single node operation, ex. add, this sets the maximum number
   1194   * of threads to use.
   1195   *
   1196   * \note If built with OpenMP, this has no effect on the number of threads
   1197   * used. In this case use the OpenMP env variables to configure the number of
   1198   * intra op num threads.
   1199   *
   1200   * \param[in] options
   1201   * \param[in] intra_op_num_threads Number of threads to use<br>
   1202   *   A value of 0 will use the default number of threads<br>
   1203   *
   1204   * \snippet{doc} snippets.dox OrtStatus Return Value
   1205   */
   1206  ORT_API2_STATUS(SetIntraOpNumThreads, _Inout_ OrtSessionOptions* options,
   1207                  int intra_op_num_threads);
   1208 
   1209  /** \brief Sets the number of threads used to parallelize the execution of the
   1210   * graph
   1211   *
   1212   * If nodes can be run in parallel, this sets the maximum number of threads to
   1213   * use to run them in parallel.
   1214   *
   1215   * \note If sequential execution is enabled this value is ignored, it acts as
   1216   * if it was set to 1.
   1217   *
   1218   * \param[in] options
   1219   * \param[in] inter_op_num_threads Number of threads to use<br>
   1220   *   A value of 0 will use the default number of threads<br>
   1221   *
   1222   * \snippet{doc} snippets.dox OrtStatus Return Value
   1223   */
   1224  ORT_API2_STATUS(SetInterOpNumThreads, _Inout_ OrtSessionOptions* options,
   1225                  int inter_op_num_threads);
   1226 
   1227  /// @}
   1228  /// \name OrtCustomOpDomain
   1229  /// @{
   1230 
   1231  /** \brief Create a custom op domain
   1232   *
   1233   * \param[in] domain
   1234   * \param[out] out Newly created domain. Must be freed with
   1235   * OrtApi::ReleaseCustomOpDomain
   1236   *
   1237   * \snippet{doc} snippets.dox OrtStatus Return Value
   1238   */
   1239  ORT_API2_STATUS(CreateCustomOpDomain, _In_ const char* domain,
   1240                  _Outptr_ OrtCustomOpDomain** out);
   1241 
   1242  /** \brief Add a custom op to a custom op domain
   1243   *
   1244   * \note The OrtCustomOp* pointer must remain valid until the
   1245   * ::OrtCustomOpDomain using it is released
   1246   *
   1247   * \param[in] custom_op_domain
   1248   * \param[in] op
   1249   *
   1250   * \snippet{doc} snippets.dox OrtStatus Return Value
   1251   */
   1252  ORT_API2_STATUS(CustomOpDomain_Add,
   1253                  _Inout_ OrtCustomOpDomain* custom_op_domain,
   1254                  _In_ const OrtCustomOp* op);
   1255 
   1256  /// @}
   1257  /// \name OrtSessionOptions
   1258  /// @{
   1259 
   1260  /** \brief Add custom op domain to a session options
   1261   *
   1262   * \note The OrtCustomOpDomain* must not be deleted until all sessions using
   1263   * it are released
   1264   *
   1265   * \param[in] options
   1266   * \param[in] custom_op_domain
   1267   *
   1268   * \snippet{doc} snippets.dox OrtStatus Return Value
   1269   */
   1270  ORT_API2_STATUS(AddCustomOpDomain, _Inout_ OrtSessionOptions* options,
   1271                  _In_ OrtCustomOpDomain* custom_op_domain);
   1272 
   1273  /** \deprecated Use OrtApi::RegisterCustomOpsLibrary_V2.
   1274   *
   1275   * Registers custom ops from a shared library.
   1276   *
   1277   * Loads a shared library (dll on windows, so on linux, etc) named
   1278   *'library_path' and looks for this entry point: OrtStatus*
   1279   *RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); It
   1280   *then passes in the provided session options to this function along with the
   1281   *api base. The handle to the loaded library is returned in library_handle. It
   1282   *can be freed by the caller after all sessions using the passed in session
   1283   *options are destroyed, or if an error occurs and it is non null.
   1284   *
   1285   * \param[in] options
   1286   * \param[in] library_path
   1287   * \param[out] library_handle OS specific handle to the loaded library (Use
   1288   *FreeLibrary on Windows, dlclose on Linux, etc.. to unload)
   1289   *
   1290   * \snippet{doc} snippets.dox OrtStatus Return Value
   1291   */
   1292  ORT_API2_STATUS(RegisterCustomOpsLibrary, _Inout_ OrtSessionOptions* options,
   1293                  _In_ const char* library_path,
   1294                  _Outptr_ void** library_handle);
   1295 
   1296  /// @}
   1297  /// \name OrtSession
   1298  /// @{
   1299 
   1300  /** \brief Get input count for a session
   1301   *
   1302   * This number must also match the number of inputs passed to OrtApi::Run
   1303   *
   1304   * \see OrtApi::SessionGetInputTypeInfo, OrtApi::SessionGetInputName,
   1305   * OrtApi::Session
   1306   *
   1307   * \param[in] session
   1308   * \param[out] out Number of inputs
   1309   *
   1310   * \snippet{doc} snippets.dox OrtStatus Return Value
   1311   */
   1312  ORT_API2_STATUS(SessionGetInputCount, _In_ const OrtSession* session,
   1313                  _Out_ size_t* out);
   1314 
   1315  /** \brief Get output count for a session
   1316   *
   1317   * This number must also match the number of outputs returned by OrtApi::Run
   1318   *
   1319   * \see OrtApi::SessionGetOutputTypeInfo, OrtApi::SessionGetOutputName,
   1320   * OrtApi::Session
   1321   *
   1322   * \param[in] session
   1323   * \param[out] out Number of outputs
   1324   *
   1325   * \snippet{doc} snippets.dox OrtStatus Return Value
   1326   */
   1327  ORT_API2_STATUS(SessionGetOutputCount, _In_ const OrtSession* session,
   1328                  _Out_ size_t* out);
   1329 
   1330  /** \brief Get overridable initializer count
   1331   *
   1332   * \see OrtApi::SessionGetOverridableInitializerTypeInfo,
   1333   * OrtApi::SessionGetOverridableInitializerName
   1334   *
   1335   * \param[in] session
   1336   * \param[in] out
   1337   *
   1338   * \snippet{doc} snippets.dox OrtStatus Return Value
   1339   */
   1340  ORT_API2_STATUS(SessionGetOverridableInitializerCount,
   1341                  _In_ const OrtSession* session, _Out_ size_t* out);
   1342 
   1343  /** \brief Get input type information
   1344   *
   1345   * \param[in] session
   1346   * \param[in] index Must be between 0 (inclusive) and what
   1347   * OrtApi::SessionGetInputCount returns (exclusive)
   1348   * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo
   1349   *
   1350   * \snippet{doc} snippets.dox OrtStatus Return Value
   1351   */
   1352  ORT_API2_STATUS(SessionGetInputTypeInfo, _In_ const OrtSession* session,
   1353                  size_t index, _Outptr_ OrtTypeInfo** type_info);
   1354 
   1355  /** \brief Get output type information
   1356   *
   1357   * \param[in] session
   1358   * \param[in] index Must be between 0 (inclusive) and what
   1359   * OrtApi::SessionGetOutputCount returns (exclusive)
   1360   * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo
   1361   *
   1362   * \snippet{doc} snippets.dox OrtStatus Return Value
   1363   */
   1364  ORT_API2_STATUS(SessionGetOutputTypeInfo, _In_ const OrtSession* session,
   1365                  size_t index, _Outptr_ OrtTypeInfo** type_info);
   1366 
   1367  /** \brief Get overridable initializer type information
   1368   *
   1369   * \param[in] session
   1370   * \param[in] index Must be between 0 (inclusive) and what
   1371   * OrtApi::SessionGetOverridableInitializerCount returns (exclusive)
   1372   * \param[out] type_info Must be freed with OrtApi::ReleaseTypeInfo
   1373   *
   1374   * \snippet{doc} snippets.dox OrtStatus Return Value
   1375   */
   1376  ORT_API2_STATUS(SessionGetOverridableInitializerTypeInfo,
   1377                  _In_ const OrtSession* session, size_t index,
   1378                  _Outptr_ OrtTypeInfo** type_info);
   1379 
   1380  /** \brief Get input name
   1381   *
   1382   * \param[in] session
   1383   * \param[in] index Must be between 0 (inclusive) and what
   1384   * OrtApi::SessionGetInputCount returns (exclusive)
   1385   * \param[in] allocator
   1386   * \param[out] value Set to a null terminated UTF-8 encoded string allocated
   1387   * using `allocator`. Must be freed using `allocator`.
   1388   *
   1389   * \snippet{doc} snippets.dox OrtStatus Return Value
   1390   */
   1391  ORT_API2_STATUS(SessionGetInputName, _In_ const OrtSession* session,
   1392                  size_t index, _Inout_ OrtAllocator* allocator,
   1393                  _Outptr_ char** value);
   1394 
   1395  /** \brief Get output name
   1396   *
   1397   * \param[in] session
   1398   * \param[in] index Must be between 0 (inclusive) and what
   1399   * OrtApi::SessionGetOutputCount returns (exclusive)
   1400   * \param[in] allocator
   1401   * \param[out] value Set to a null terminated UTF-8 encoded string allocated
   1402   * using `allocator`. Must be freed using `allocator`.
   1403   *
   1404   * \snippet{doc} snippets.dox OrtStatus Return Value
   1405   */
   1406  ORT_API2_STATUS(SessionGetOutputName, _In_ const OrtSession* session,
   1407                  size_t index, _Inout_ OrtAllocator* allocator,
   1408                  _Outptr_ char** value);
   1409 
   1410  /** \brief Get overridable initializer name
   1411   *
   1412   * \param[in] session
   1413   * \param[in] index Must be between 0 (inclusive) and what
   1414   * OrtApi::SessionGetOverridableInitializerCount returns (exclusive)
   1415   * \param[in] allocator
   1416   * \param[out] value Set to a null terminated UTF-8 encoded string allocated
   1417   * using `allocator`. Must be freed using `allocator`.
   1418   *
   1419   * \snippet{doc} snippets.dox OrtStatus Return Value
   1420   */
   1421  ORT_API2_STATUS(SessionGetOverridableInitializerName,
   1422                  _In_ const OrtSession* session, size_t index,
   1423                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   1424 
   1425  /// @}
   1426  /// \name OrtRunOptions
   1427  /// @{
   1428 
   1429  /** \brief Create an OrtRunOptions
   1430   *
   1431   * \param[out] out Returned newly created ::OrtRunOptions. Must be freed with
   1432   * OrtApi::ReleaseRunOptions
   1433   *
   1434   * \snippet{doc} snippets.dox OrtStatus Return Value
   1435   */
   1436  ORT_API2_STATUS(CreateRunOptions, _Outptr_ OrtRunOptions** out);
   1437 
   1438  /** \brief Set per-run log verbosity level
   1439   *
   1440   * \see OrtApi::RunOptionsGetRunLogVerbosityLevel
   1441   *
   1442   * \param[in] options
   1443   * \param[in] log_verbosity_level \snippet{doc} snippets.dox Log Verbosity
   1444   * Level
   1445   *
   1446   * \snippet{doc} snippets.dox OrtStatus Return Value
   1447   */
   1448  ORT_API2_STATUS(RunOptionsSetRunLogVerbosityLevel,
   1449                  _Inout_ OrtRunOptions* options, int log_verbosity_level);
   1450 
   1451  /** \brief Set per-run log severity level
   1452   *
   1453   * \see OrtApi::RunOptionsGetRunLogSeverityLevel
   1454   *
   1455   * \param[in] options
   1456   * \param[in] log_severity_level The log severity level (refer to
   1457   * ::OrtLoggingLevel for possible values).
   1458   */
   1459  ORT_API2_STATUS(RunOptionsSetRunLogSeverityLevel,
   1460                  _Inout_ OrtRunOptions* options, int log_severity_level);
   1461 
   1462  /** \brief Set per-run tag
   1463   *
   1464   * This is used in a per-run log identifier.
   1465   *
   1466   * \see OrtApi::RunOptionsGetRunTag
   1467   *
   1468   * \param[in] options
   1469   * \param[in] run_tag The run tag.
   1470   */
   1471  ORT_API2_STATUS(RunOptionsSetRunTag, _Inout_ OrtRunOptions* options,
   1472                  _In_ const char* run_tag);
   1473 
   1474  /** \brief Get per-run log verbosity level
   1475   *
   1476   * \see OrtApi::RunOptionsSetRunLogVerbosityLevel
   1477   *
   1478   * \param[in] options
   1479   * \param[out] log_verbosity_level \snippet{doc} snippets.dox Log Verbosity
   1480   * Level
   1481   *
   1482   * \snippet{doc} snippets.dox OrtStatus Return Value
   1483   */
   1484  ORT_API2_STATUS(RunOptionsGetRunLogVerbosityLevel,
   1485                  _In_ const OrtRunOptions* options,
   1486                  _Out_ int* log_verbosity_level);
   1487 
   1488  /** \brief Get per-run log severity level
   1489   *
   1490   * \see OrtApi::RunOptionsSetRunLogSeverityLevel
   1491   *
   1492   * \param[in] options
   1493   * \param[out] log_severity_level The log severity level (refer to
   1494   * ::OrtLoggingLevel for possible values).
   1495   */
   1496  ORT_API2_STATUS(RunOptionsGetRunLogSeverityLevel,
   1497                  _In_ const OrtRunOptions* options,
   1498                  _Out_ int* log_severity_level);
   1499 
   1500  /** \brief Get per-run tag
   1501   *
   1502   * This is used in a per-run log identifier.
   1503   *
   1504   * \see OrtApi::RunOptionsSetRunTag
   1505   *
   1506   * \param[in] options
   1507   * \param[out] run_tag The run tag.
   1508   *                     Do not free this value, it is owned by `options`. It
   1509   * will be invalidated if the run tag changes (i.e., with
   1510   * OrtApi::RunOptionsSetRunTag) or `options` is freed.
   1511   */
   1512  ORT_API2_STATUS(RunOptionsGetRunTag, _In_ const OrtRunOptions* options,
   1513                  _Out_ const char** run_tag);
   1514 
   1515  /** \brief Set terminate flag
   1516   *
   1517   * If a currently executing session needs to be force terminated, this can be
   1518   * called from another thread to force it to fail with an error.
   1519   *
   1520   * \param[in] options
   1521   *
   1522   * \snippet{doc} snippets.dox OrtStatus Return Value
   1523   */
   1524  ORT_API2_STATUS(RunOptionsSetTerminate, _Inout_ OrtRunOptions* options);
   1525 
   1526  /** \brief Clears the terminate flag
   1527   *
   1528   * Used so the OrtRunOptions instance can be used in a new OrtApi::Run call
   1529   * without it instantly terminating
   1530   *
   1531   * \param[in] options
   1532   *
   1533   * \snippet{doc} snippets.dox OrtStatus Return Value
   1534   */
   1535  ORT_API2_STATUS(RunOptionsUnsetTerminate, _Inout_ OrtRunOptions* options);
   1536 
   1537  /// @}
   1538  /// \name OrtValue
   1539  /// @{
   1540 
   1541  /** \brief Create a tensor
   1542   *
   1543   * Create a tensor using a supplied ::OrtAllocator
   1544   *
   1545   * \param[in] allocator
   1546   * \param[in] shape Pointer to the tensor shape dimensions.
   1547   * \param[in] shape_len The number of tensor shape dimensions.
   1548   * \param[in] type
   1549   * \param[out] out Returns newly created ::OrtValue. Must be freed with
   1550   * OrtApi::ReleaseValue
   1551   *
   1552   * \snippet{doc} snippets.dox OrtStatus Return Value
   1553   */
   1554  ORT_API2_STATUS(CreateTensorAsOrtValue, _Inout_ OrtAllocator* allocator,
   1555                  _In_ const int64_t* shape, size_t shape_len,
   1556                  ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
   1557 
   1558  /** \brief Create a tensor backed by a user supplied buffer
   1559   *
   1560   * Create a tensor with user's buffer. You can fill the buffer either before
   1561   * calling this function or after. p_data is owned by caller. ReleaseValue
   1562   * won't release p_data.
   1563   *
   1564   * If you wish to transfer ownership of p_data to ORT use
   1565   * CreateTensorWithDataAndDeleterAsOrtValue.
   1566   *
   1567   * \param[in] info Memory description of where the p_data buffer resides (CPU
   1568   * vs GPU etc).
   1569   * \param[in] p_data Pointer to the data buffer.
   1570   * \param[in] p_data_len The number of bytes in the data buffer.
   1571   * \param[in] shape Pointer to the tensor shape dimensions.
   1572   * \param[in] shape_len The number of tensor shape dimensions.
   1573   * \param[in] type The data type.
   1574   * \param[out] out Returns newly created ::OrtValue. Must be freed with
   1575   * OrtApi::ReleaseValue
   1576   *
   1577   * \snippet{doc} snippets.dox OrtStatus Return Value
   1578   */
   1579  ORT_API2_STATUS(CreateTensorWithDataAsOrtValue,
   1580                  _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
   1581                  size_t p_data_len, _In_ const int64_t* shape,
   1582                  size_t shape_len, ONNXTensorElementDataType type,
   1583                  _Outptr_ OrtValue** out);
   1584 
   1585  /** \brief Return if an ::OrtValue is a tensor type
   1586   *
   1587   * \param[in] value A tensor type (string tensors are not supported)
   1588   * \param[out] out Set to 1 iff ::OrtValue is a tensor, 0 otherwise
   1589   *
   1590   * \snippet{doc} snippets.dox OrtStatus Return Value
   1591   */
   1592  ORT_API2_STATUS(IsTensor, _In_ const OrtValue* value, _Out_ int* out);
   1593 
   1594  /** \brief Get a pointer to the raw data inside a tensor
   1595   *
   1596   * Used to read/write/modify the internal tensor data directly.
   1597   * \note The returned pointer is valid until the \p value is destroyed.
   1598   *
   1599   * \param[in] value A tensor type (string tensors are not supported)
   1600   * \param[out] out Filled in with a pointer to the internal storage
   1601   *
   1602   * \snippet{doc} snippets.dox OrtStatus Return Value
   1603   */
   1604  ORT_API2_STATUS(GetTensorMutableData, _In_ OrtValue* value,
   1605                  _Outptr_ void** out);
   1606 
   1607  /** \brief Set all strings at once in a string tensor
   1608   *
   1609   * \param[in,out] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING
   1610   * \param[in] s An array of strings. Each string in this array must be null
   1611   * terminated.
   1612   * \param[in] s_len Count of strings in s (Must match the size of \p value's
   1613   * tensor shape)
   1614   *
   1615   * \snippet{doc} snippets.dox OrtStatus Return Value
   1616   */
   1617  ORT_API2_STATUS(FillStringTensor, _Inout_ OrtValue* value,
   1618                  _In_ const char* const* s, size_t s_len);
   1619 
   1620  /** \brief Get total byte length for all strings in a string tensor
   1621   *
   1622   * Typically used with OrtApi::GetStringTensorContent
   1623   *
   1624   * \param[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING
   1625   * \param[out] len Total byte length of all strings (does not include trailing
   1626   * nulls)
   1627   *
   1628   * \snippet{doc} snippets.dox OrtStatus Return Value
   1629   */
   1630  ORT_API2_STATUS(GetStringTensorDataLength, _In_ const OrtValue* value,
   1631                  _Out_ size_t* len);
   1632 
   1633  /** \brief Get all strings from a string tensor
   1634   *
   1635   * An example of the results:<br>
   1636   * Given \p value is a string tensor with the strings { "This" "is" "a" "test"
   1637   * }<br>
   1638   * \p s must have a size of 11 bytes<br>
   1639   * \p offsets must have 4 elements<br>
   1640   * After the call, these values will be filled in:<br>
   1641   * \p s will contain "Thisisatest"<br>
   1642   * \p offsets will contain { 0, 4, 6, 7 }<br>
   1643   * The length of the last string is just s_len - offsets[last]
   1644   *
   1645   * \param[in] value A tensor of type ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING
   1646   * \param[in] s Buffer to sequentially write all tensor strings to. Each
   1647   * string is NOT null-terminated.
   1648   * \param[in] s_len Number of bytes of buffer pointed to by \p s (Get it from
   1649   * OrtApi::GetStringTensorDataLength)
   1650   * \param[out] offsets Array of start offsets into the strings written to \p s
   1651   * \param[in] offsets_len Number of elements in offsets
   1652   *
   1653   * \snippet{doc} snippets.dox OrtStatus Return Value
   1654   */
   1655  ORT_API2_STATUS(GetStringTensorContent, _In_ const OrtValue* value,
   1656                  _Out_writes_bytes_all_(s_len) void* s, size_t s_len,
   1657                  _Out_writes_all_(offsets_len) size_t* offsets,
   1658                  size_t offsets_len);
   1659 
   1660  /// @}
   1661  /// \name OrtTypeInfo
   1662  /// @{
   1663 
   1664  /** \brief Get ::OrtTensorTypeAndShapeInfo from an ::OrtTypeInfo
   1665   *
   1666   * \param[in] type_info
   1667   * \param[out] out Do not free this value, it will be valid until type_info is
   1668   * freed. If type_info does not represent tensor, this value will be set to
   1669   * nullptr.
   1670   *
   1671   * \snippet{doc} snippets.dox OrtStatus Return Value
   1672   */
   1673  ORT_API2_STATUS(
   1674      CastTypeInfoToTensorInfo, _In_ const OrtTypeInfo* type_info,
   1675      _Outptr_result_maybenull_ const OrtTensorTypeAndShapeInfo** out);
   1676 
   1677  /** \brief Get ::ONNXType from ::OrtTypeInfo
   1678   *
   1679   * \param[in] type_info
   1680   * \param[out] out
   1681   *
   1682   * \snippet{doc} snippets.dox OrtStatus Return Value
   1683   */
   1684  ORT_API2_STATUS(GetOnnxTypeFromTypeInfo, _In_ const OrtTypeInfo* type_info,
   1685                  _Out_ enum ONNXType* out);
   1686 
   1687  /// @}
   1688  /// \name OrtTensorTypeAndShapeInfo
   1689  /// @{
   1690 
   1691  /** \brief Create an ::OrtTensorTypeAndShapeInfo object
   1692   *
   1693   * \param[out] out Returns newly created ::OrtTensorTypeAndShapeInfo. Must be
   1694   * freed with OrtApi::ReleaseTensorTypeAndShapeInfo
   1695   *
   1696   * \snippet{doc} snippets.dox OrtStatus Return Value
   1697   */
   1698  ORT_API2_STATUS(CreateTensorTypeAndShapeInfo,
   1699                  _Outptr_ OrtTensorTypeAndShapeInfo** out);
   1700 
   1701  /** \brief Set element type in ::OrtTensorTypeAndShapeInfo
   1702   *
   1703   * \param[in] info
   1704   * \param[in] type
   1705   *
   1706   * \snippet{doc} snippets.dox OrtStatus Return Value
   1707   */
   1708  ORT_API2_STATUS(SetTensorElementType, _Inout_ OrtTensorTypeAndShapeInfo* info,
   1709                  enum ONNXTensorElementDataType type);
   1710 
   1711  /** \brief Set shape information in ::OrtTensorTypeAndShapeInfo
   1712   *
   1713   * \param[in] info
   1714   * \param[in] dim_values Array with `dim_count` elements. Can contain negative
   1715   * values.
   1716   * \param[in] dim_count Number of elements in `dim_values`
   1717   *
   1718   * \snippet{doc} snippets.dox OrtStatus Return Value
   1719   */
   1720  ORT_API2_STATUS(SetDimensions, OrtTensorTypeAndShapeInfo* info,
   1721                  _In_ const int64_t* dim_values, size_t dim_count);
   1722 
   1723  /** \brief Get element type in ::OrtTensorTypeAndShapeInfo
   1724   *
   1725   * \see OrtApi::SetTensorElementType
   1726   *
   1727   * \param[in] info
   1728   * \param[out] out
   1729   *
   1730   * \snippet{doc} snippets.dox OrtStatus Return Value
   1731   */
   1732  ORT_API2_STATUS(GetTensorElementType,
   1733                  _In_ const OrtTensorTypeAndShapeInfo* info,
   1734                  _Out_ enum ONNXTensorElementDataType* out);
   1735 
   1736  /** \brief Get dimension count in ::OrtTensorTypeAndShapeInfo
   1737   *
   1738   * \see OrtApi::GetDimensions
   1739   *
   1740   * \param[in] info
   1741   * \param[out] out
   1742   *
   1743   * \snippet{doc} snippets.dox OrtStatus Return Value
   1744   */
   1745  ORT_API2_STATUS(GetDimensionsCount,
   1746                  _In_ const OrtTensorTypeAndShapeInfo* info,
   1747                  _Out_ size_t* out);
   1748 
   1749  /** \brief Get dimensions in ::OrtTensorTypeAndShapeInfo
   1750   *
   1751   * \param[in] info
   1752   * \param[out] dim_values Array with `dim_values_length` elements. On return,
   1753   * filled with the dimensions stored in the ::OrtTensorTypeAndShapeInfo
   1754   * \param[in] dim_values_length Number of elements in `dim_values`. Use
   1755   * OrtApi::GetDimensionsCount to get this value
   1756   *
   1757   * \snippet{doc} snippets.dox OrtStatus Return Value
   1758   */
   1759  ORT_API2_STATUS(GetDimensions, _In_ const OrtTensorTypeAndShapeInfo* info,
   1760                  _Out_ int64_t* dim_values, size_t dim_values_length);
   1761 
   1762  /** \brief Get symbolic dimension names in ::OrtTensorTypeAndShapeInfo
   1763   *
   1764   * \param[in] info
   1765   * \param[in] dim_params Array with `dim_params_length` elements. On return
   1766   * filled with pointers to null terminated strings of the dimension names
   1767   * \param[in] dim_params_length Number of elements in `dim_params`. Use
   1768   * OrtApi::GetDimensionsCount to get this value
   1769   *
   1770   * \snippet{doc} snippets.dox OrtStatus Return Value
   1771   */
   1772  ORT_API2_STATUS(GetSymbolicDimensions,
   1773                  _In_ const OrtTensorTypeAndShapeInfo* info,
   1774                  _Out_writes_all_(dim_params_length) const char* dim_params[],
   1775                  size_t dim_params_length);
   1776 
   1777  /** \brief Get total number of elements in a tensor shape from an
   1778   * ::OrtTensorTypeAndShapeInfo
   1779   *
   1780   * Return the number of elements specified by the tensor shape (all dimensions
   1781   * multiplied by each other). For 0 dimensions, 1 is returned. If any
   1782   * dimension is less than 0, the result is always -1.
   1783   *
   1784   * Examples:<br>
   1785   * [] = 1<br>
   1786   * [1,3,4] = 12<br>
   1787   * [2,0,4] = 0<br>
   1788   * [-1,3,4] = -1<br>
   1789   *
   1790   * \param[in] info
   1791   * \param[out] out Number of elements
   1792   *
   1793   * \snippet{doc} snippets.dox OrtStatus Return Value
   1794   */
   1795  ORT_API2_STATUS(GetTensorShapeElementCount,
   1796                  _In_ const OrtTensorTypeAndShapeInfo* info,
   1797                  _Out_ size_t* out);
   1798 
   1799  /// @}
   1800  /// \name OrtValue
   1801  /// @{
   1802 
   1803  /** \brief Get type and shape information from a tensor ::OrtValue
   1804   *
   1805   * \param[in] value Must be a tensor (not a map/sequence/etc) or will return
   1806   * failure
   1807   * \param[out] out Newly created ::OrtTensorTypeAndShapeInfo. Must be freed
   1808   * with OrtApi::ReleaseTensorTypeAndShapeInfo
   1809   *
   1810   * \snippet{doc} snippets.dox OrtStatus Return Value
   1811   */
   1812  ORT_API2_STATUS(GetTensorTypeAndShape, _In_ const OrtValue* value,
   1813                  _Outptr_ OrtTensorTypeAndShapeInfo** out);
   1814 
   1815  /** \brief Get type information of an OrtValue
   1816   *
   1817   * \param[in] value
   1818   * \param[out] out Newly created ::OrtTypeInfo. Must be freed with
   1819   * OrtApi::ReleaseTypeInfo
   1820   *
   1821   * \snippet{doc} snippets.dox OrtStatus Return Value
   1822   */
   1823  ORT_API2_STATUS(GetTypeInfo, _In_ const OrtValue* value,
   1824                  _Outptr_result_maybenull_ OrtTypeInfo** out);
   1825 
   1826  /** \brief Get ONNXType of an ::OrtValue
   1827   *
   1828   * \param[in] value
   1829   * \param[out] out
   1830   *
   1831   * \snippet{doc} snippets.dox OrtStatus Return Value
   1832   */
   1833  ORT_API2_STATUS(GetValueType, _In_ const OrtValue* value,
   1834                  _Out_ enum ONNXType* out);
   1835 
   1836  /// @}
   1837  /// \name OrtMemoryInfo
   1838  /// @{
   1839 
   1840  /** \brief Create an ::OrtMemoryInfo
   1841   *
   1842   * \param[in] name
   1843   * \param[in] type
   1844   * \param[in] id
   1845   * \param[in] mem_type
   1846   * \param[out] out Newly created ::OrtMemoryInfo. Must be freed with
   1847   * OrtAPi::ReleaseMemoryInfo
   1848   *
   1849   * \snippet{doc} snippets.dox OrtStatus Return Value
   1850   */
   1851  ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name,
   1852                  enum OrtAllocatorType type, int id, enum OrtMemType mem_type,
   1853                  _Outptr_ OrtMemoryInfo** out);
   1854 
   1855  /** \brief Create an ::OrtMemoryInfo for CPU memory
   1856   *
   1857   * Special case version of OrtApi::CreateMemoryInfo for CPU based memory. Same
   1858   * as using OrtApi::CreateMemoryInfo with name = "Cpu" and id = 0.
   1859   *
   1860   * \param[in] type
   1861   * \param[in] mem_type
   1862   * \param[out] out
   1863   *
   1864   * \snippet{doc} snippets.dox OrtStatus Return Value
   1865   */
   1866  ORT_API2_STATUS(CreateCpuMemoryInfo, enum OrtAllocatorType type,
   1867                  enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out);
   1868 
   1869  /** \brief Compare ::OrtMemoryInfo objects for equality
   1870   *
   1871   * Compares all settings of each ::OrtMemoryInfo for equality
   1872   *
   1873   * \param[in] info1
   1874   * \param[in] info2
   1875   * \param[out] out Set to 0 if equal, -1 if not equal
   1876   *
   1877   * \snippet{doc} snippets.dox OrtStatus Return Value
   1878   */
   1879  ORT_API2_STATUS(CompareMemoryInfo, _In_ const OrtMemoryInfo* info1,
   1880                  _In_ const OrtMemoryInfo* info2, _Out_ int* out);
   1881 
   1882  /** \brief Get name from ::OrtMemoryInfo
   1883   *
   1884   * \param[in] ptr
   1885   * \param[out] out Writes null terminated string to this pointer. Do NOT free
   1886   * the returned pointer. It is valid for the lifetime of the ::OrtMemoryInfo
   1887   *
   1888   * \snippet{doc} snippets.dox OrtStatus Return Value
   1889   */
   1890  ORT_API2_STATUS(MemoryInfoGetName, _In_ const OrtMemoryInfo* ptr,
   1891                  _Out_ const char** out);
   1892 
   1893  /** \brief Get the id from ::OrtMemoryInfo
   1894   */
   1895  ORT_API2_STATUS(MemoryInfoGetId, _In_ const OrtMemoryInfo* ptr,
   1896                  _Out_ int* out);
   1897 
   1898  /** \brief Get the ::OrtMemType from ::OrtMemoryInfo
   1899   */
   1900  ORT_API2_STATUS(MemoryInfoGetMemType, _In_ const OrtMemoryInfo* ptr,
   1901                  _Out_ OrtMemType* out);
   1902 
   1903  /** \brief Get the ::OrtAllocatorType from ::OrtMemoryInfo
   1904   */
   1905  ORT_API2_STATUS(MemoryInfoGetType, _In_ const OrtMemoryInfo* ptr,
   1906                  _Out_ OrtAllocatorType* out);
   1907 
   1908  /// @}
   1909  /// \name OrtAllocator
   1910  /// @{
   1911 
   1912  /// \brief Calls OrtAllocator::Alloc function
   1913  ORT_API2_STATUS(AllocatorAlloc, _Inout_ OrtAllocator* ort_allocator,
   1914                  size_t size, _Outptr_ void** out);
   1915  /// \brief Calls OrtAllocator::Free function
   1916  ORT_API2_STATUS(AllocatorFree, _Inout_ OrtAllocator* ort_allocator, void* p);
   1917  /// \brief Calls OrtAllocator::Info function
   1918  ORT_API2_STATUS(AllocatorGetInfo, _In_ const OrtAllocator* ort_allocator,
   1919                  _Outptr_ const struct OrtMemoryInfo** out);
   1920 
   1921  /** \brief Get the default allocator
   1922   *
   1923   * The default allocator is a CPU based, non-arena. Always returns the same
   1924   * pointer to the same default allocator.
   1925   *
   1926   * \param[out] out Returned value should NOT be freed
   1927   *
   1928   * \snippet{doc} snippets.dox OrtStatus Return Value
   1929   */
   1930  ORT_API2_STATUS(GetAllocatorWithDefaultOptions, _Outptr_ OrtAllocator** out);
   1931 
   1932  /// @}
   1933  /// \name OrtSessionOptions
   1934  /// @{
   1935 
   1936  /** \brief Override session symbolic dimensions
   1937   *
   1938   * Override symbolic dimensions (by specific denotation strings) with actual
   1939   * values if known at session initialization time to enable optimizations that
   1940   * can take advantage of fixed values (such as memory planning, etc)
   1941   *
   1942   * \param[in] options
   1943   * \param[in] dim_denotation
   1944   * \param[in] dim_value
   1945   *
   1946   * \snippet{doc} snippets.dox OrtStatus Return Value
   1947   */
   1948  ORT_API2_STATUS(AddFreeDimensionOverride, _Inout_ OrtSessionOptions* options,
   1949                  _In_ const char* dim_denotation, _In_ int64_t dim_value);
   1950 
   1951  /// @}
   1952  /// \name OrtValue
   1953  /// @{
   1954 
   1955  /* Internal information (not seen in Doxygen)
   1956   *
   1957   * APIs to support non-tensor types - map and sequence.
   1958   * Currently only the following types are supported
   1959   * Note: the following types should be kept in sync with data_types.h
   1960   * Map types
   1961   * =========
   1962   * std::map<std::string, std::string>
   1963   * std::map<std::string, int64_t>
   1964   * std::map<std::string, float>
   1965   * std::map<std::string, double>
   1966   * std::map<int64_t, std::string>
   1967   * std::map<int64_t, int64_t>
   1968   * std::map<int64_t, float>
   1969   * std::map<int64_t, double>
   1970   *
   1971   * Sequence types
   1972   * ==============
   1973   * std::vector<std::string>
   1974   * std::vector<int64_t>
   1975   * std::vector<float>
   1976   * std::vector<double>
   1977   * std::vector<std::map<std::string, float>>
   1978   * std::vector<std::map<int64_t, float>
   1979   */
   1980 
   1981  /** \brief Get non tensor data from an ::OrtValue
   1982   *
   1983   * If `value` is of type ONNX_TYPE_MAP, you need to retrieve the keys and
   1984   * values separately. Use index=0 to retrieve keys and index=1 to retrieve
   1985   * values. If `value` is of type ONNX_TYPE_SEQUENCE, use index to retrieve the
   1986   * index'th element of the sequence.
   1987   *
   1988   * \param[in] value
   1989   * \param[in] index See above for usage based on `value` type
   1990   * \param[in] allocator Allocator used to allocate ::OrtValue
   1991   * \param[out] out Created ::OrtValue that holds the element requested. Must
   1992   * be freed with OrtApi::ReleaseValue
   1993   *
   1994   * \snippet{doc} snippets.dox OrtStatus Return Value
   1995   */
   1996  ORT_API2_STATUS(GetValue, _In_ const OrtValue* value, int index,
   1997                  _Inout_ OrtAllocator* allocator, _Outptr_ OrtValue** out);
   1998 
   1999  /** \brief Get non tensor value count from an ::OrtValue
   2000   *
   2001   * If `value` is of type ONNX_TYPE_MAP 2 will always be returned. For
   2002   * ONNX_TYPE_SEQUENCE the number of elements in the sequence will be returned
   2003   *
   2004   * \param[in] value
   2005   * \param[out] out
   2006   *
   2007   * \snippet{doc} snippets.dox OrtStatus Return Value
   2008   */
   2009  ORT_API2_STATUS(GetValueCount, _In_ const OrtValue* value, _Out_ size_t* out);
   2010 
   2011  /** \brief Create a map or sequence ::OrtValue
   2012   *
   2013   * To construct a map (ONNX_TYPE_MAP), use num_values = 2 and `in` should be
   2014   * an array of 2 ::OrtValue%s representing keys and values.<br>
   2015   *
   2016   * To construct a sequence (ONNX_TYPE_SEQUENCE), use num_values = N where N is
   2017   * the number of the elements in the sequence. 'in' should be an array of N
   2018   * ::OrtValue%s.
   2019   *
   2020   * \param[in] in See above for details
   2021   * \param[in] num_values
   2022   * \param[in] value_type Must be either ONNX_TYPE_MAP or ONNX_TYPE_SEQUENCE
   2023   * \param[out] out Newly created ::OrtValue. Must be freed with
   2024   * OrtApi::ReleaseValue
   2025   *
   2026   * \snippet{doc} snippets.dox OrtStatus Return Value
   2027   */
   2028  ORT_API2_STATUS(CreateValue, _In_reads_(num_values) const OrtValue* const* in,
   2029                  size_t num_values, enum ONNXType value_type,
   2030                  _Outptr_ OrtValue** out);
   2031 
   2032  /** \brief Create an opaque (custom user defined type) ::OrtValue
   2033   *
   2034   * Constructs an ::OrtValue that contains a value of non-standard type created
   2035   * for experiments or while awaiting standardization. ::OrtValue in this case
   2036   * would contain an internal representation of the Opaque type. Opaque types
   2037   * are distinguished from each other by two strings 1) domain and 2) type
   2038   * name. The combination of the two must be unique, so the type representation
   2039   * is properly identified internally. The combination must be properly
   2040   * registered from within ORT at both compile/run time or by another API.
   2041   *
   2042   * To construct the ::OrtValue pass domain and type names, also a pointer to a
   2043   * data container the type of which must be known to both ORT and the client
   2044   * program. That data container may or may not match the internal
   2045   * representation of the Opaque type. The sizeof(data_container) is passed for
   2046   * verification purposes.
   2047   *
   2048   * \param[in] domain_name Null terminated string of the domain name
   2049   * \param[in] type_name Null terminated string of the type name
   2050   * \param[in] data_container User pointer Data to populate ::OrtValue
   2051   * \param[in] data_container_size Size in bytes of what `data_container`
   2052   * points to
   2053   * \param[out] out Newly created ::OrtValue. Must be freed with
   2054   * OrtApi::ReleaseValue
   2055   *
   2056   * \snippet{doc} snippets.dox OrtStatus Return Value
   2057   */
   2058  ORT_API2_STATUS(CreateOpaqueValue, _In_z_ const char* domain_name,
   2059                  _In_z_ const char* type_name, _In_ const void* data_container,
   2060                  size_t data_container_size, _Outptr_ OrtValue** out);
   2061 
   2062  /** \brief Get internal data from an opaque (custom user defined type)
   2063   * ::OrtValue
   2064   *
   2065   * Copies internal data from an opaque value into a user provided buffer
   2066   *
   2067   * \see OrtApi::CreateOpaqueValue
   2068   *
   2069   * \param[in] domain_name Null terminated string of the domain name
   2070   * \param[in] type_name Null terminated string of the type name
   2071   * \param[in] in The opaque ::OrtValue
   2072   * \param[out] data_container Buffer to copy data into
   2073   * \param[out] data_container_size Size in bytes of the buffer pointed to by
   2074   * data_container. Must match the size of the internal buffer.
   2075   *
   2076   * \snippet{doc} snippets.dox OrtStatus Return Value
   2077   */
   2078  ORT_API2_STATUS(GetOpaqueValue, _In_ const char* domain_name,
   2079                  _In_ const char* type_name, _In_ const OrtValue* in,
   2080                  _Out_ void* data_container, size_t data_container_size);
   2081 
   2082  /// @}
   2083  /// \name OrtKernelInfo
   2084  /// Custom operator APIs.
   2085  /// @{
   2086 
   2087  /** \brief Get a float stored as an attribute in the graph node
   2088   *
   2089   * \param[in] info ::OrtKernelInfo instance
   2090   * \param[in] name Null terminated string of the name of the attribute
   2091   * \param[out] out Pointer to memory where the attribute will be stored
   2092   *
   2093   * \snippet{doc} snippets.dox OrtStatus Return Value
   2094   */
   2095  ORT_API2_STATUS(KernelInfoGetAttribute_float, _In_ const OrtKernelInfo* info,
   2096                  _In_ const char* name, _Out_ float* out);
   2097 
   2098  /** \brief Fetch a 64-bit int stored as an attribute in the graph node
   2099   *
   2100   * \param[in] info ::OrtKernelInfo instance
   2101   * \param[in] name Null terminated string of the name of the attribute
   2102   * \param[out] out Pointer to memory where the attribute will be stored
   2103   *
   2104   * \snippet{doc} snippets.dox OrtStatus Return Value
   2105   */
   2106  ORT_API2_STATUS(KernelInfoGetAttribute_int64, _In_ const OrtKernelInfo* info,
   2107                  _In_ const char* name, _Out_ int64_t* out);
   2108 
   2109  /** \brief Fetch a string stored as an attribute in the graph node
   2110   *
   2111   * If `out` is nullptr, the value of `size` is set to the true size of the
   2112   * string attribute, and a success status is returned.
   2113   *
   2114   * If the `size` parameter is greater than or equal to the actual string
   2115   * attribute's size, the value of `size` is set to the true size of the string
   2116   * attribute, the provided memory is filled with the attribute's contents, and
   2117   * a success status is returned.
   2118   *
   2119   * If the `size` parameter is less than the actual string attribute's size and
   2120   * `out` is not nullptr, the value of `size` is set to the true size of the
   2121   * string attribute and a failure status is returned.)
   2122   *
   2123   * \param[in] info ::OrtKernelInfo instance
   2124   * \param[in] name Null terminated string of the name of the attribute
   2125   * \param[out] out Pointer to memory where the attribute will be stored
   2126   * \param[in,out] size See above comments for details
   2127   *
   2128   * \snippet{doc} snippets.dox OrtStatus Return Value
   2129   */
   2130  ORT_API2_STATUS(KernelInfoGetAttribute_string, _In_ const OrtKernelInfo* info,
   2131                  _In_ const char* name, _Out_ char* out, _Inout_ size_t* size);
   2132 
   2133  /// @}
   2134  /// \name OrtKernelContext
   2135  /// Custom operator APIs.
   2136  /// @{
   2137 
   2138  /** \brief Used for custom operators, get the input count of a kernel
   2139   *
   2140   * \see ::OrtCustomOp
   2141   */
   2142  ORT_API2_STATUS(KernelContext_GetInputCount,
   2143                  _In_ const OrtKernelContext* context, _Out_ size_t* out);
   2144 
   2145  /** \brief Used for custom operators, get the output count of a kernel
   2146   *
   2147   * \see ::OrtCustomOp
   2148   */
   2149  ORT_API2_STATUS(KernelContext_GetOutputCount,
   2150                  _In_ const OrtKernelContext* context, _Out_ size_t* out);
   2151 
   2152  /** \brief Used for custom operators, get an input of a kernel
   2153   *
   2154   * The function attempts fetches the input of the kernel. If the input is
   2155   * optional and not present, the function returns success and out is set to
   2156   * nullptr.
   2157   *
   2158   * \param[in] context ::OrtKernelContext instance
   2159   * \param[in] index See KernelContext_GetInputCount for boundaries check.
   2160   * \param[out] out OrtValue if the input is present otherwise is set nullptr
   2161   *
   2162   * \snippet{doc} snippets.dox OrtStatus Return Value
   2163   */
   2164  ORT_API2_STATUS(KernelContext_GetInput, _In_ const OrtKernelContext* context,
   2165                  _In_ size_t index, _Out_ const OrtValue** out);
   2166 
   2167  /** \brief Used for custom operators, get an output of a kernel
   2168   *
   2169   * The function attempts fetches the output of the kernel. If the output is
   2170   * optional and not present, the function returns success and out is set to
   2171   * nullptr.
   2172   *
   2173   * \param[in] context ::OrtKernelContext instance
   2174   * \param[in] index See KernelContext_GetOutputCount for boundaries check.
   2175   * \param[in] dim_values output dimensions
   2176   * \param[in] dim_count number of dimensions
   2177   * \param[out] out a ptr to OrtValue to output otherwise set to nullptr
   2178   *
   2179   * \snippet{doc} snippets.dox OrtStatus Return Value
   2180   */
   2181  ORT_API2_STATUS(KernelContext_GetOutput, _Inout_ OrtKernelContext* context,
   2182                  _In_ size_t index, _In_ const int64_t* dim_values,
   2183                  size_t dim_count, _Outptr_ OrtValue** out);
   2184 
   2185  /// @}
   2186  /// \name OrtEnv
   2187  /// @{
   2188  ORT_CLASS_RELEASE(Env);
   2189  /// @}
   2190  /// \name OrtStatus
   2191  /// @{
   2192  ORT_CLASS_RELEASE(Status);
   2193  /// @}
   2194  /// \name OrtMemoryInfo
   2195  /// @{
   2196  ORT_CLASS_RELEASE(MemoryInfo);
   2197  /// @}
   2198  /// \name OrtSession
   2199  /// @{
   2200  ORT_CLASS_RELEASE(Session);  // Don't call ReleaseSession from Dllmain
   2201                               // (because session owns a thread pool)
   2202  /// @}
   2203  /// \name OrtValue
   2204  /// @{
   2205  ORT_CLASS_RELEASE(Value);
   2206  /// @}
   2207  /// \name OrtRunOptions
   2208  /// @{
   2209  ORT_CLASS_RELEASE(RunOptions);
   2210  /// @}
   2211  /// \name OrtTypeInfo
   2212  /// @{
   2213  ORT_CLASS_RELEASE(TypeInfo);
   2214  /// @}
   2215  /// \name OrtTensorTypeAndShapeInfo
   2216  /// @{
   2217  ORT_CLASS_RELEASE(TensorTypeAndShapeInfo);
   2218  /// @}
   2219  /// \name OrtSessionOptions
   2220  /// @{
   2221  ORT_CLASS_RELEASE(SessionOptions);
   2222  /// @}
   2223  /// \name OrtCustomOpDomain
   2224  /// @{
   2225  ORT_CLASS_RELEASE(CustomOpDomain);
   2226 
   2227  /// @}
   2228  /// \name OrtTypeInfo
   2229  /// @{
   2230 
   2231  /** \brief Get denotation from type information
   2232   *
   2233   * Augments ::OrtTypeInfo to return denotations on the type.
   2234   *
   2235   * This is used by WinML to determine if an input/output is intended to be an
   2236   * Image or a Tensor.
   2237   *
   2238   * \param[in] type_info
   2239   * \param[out] denotation Pointer to the null terminated denotation string is
   2240   * written to this pointer. This pointer is valid until the object is
   2241   * destroyed or the name is changed, do not free.
   2242   * \param[out] len Length in bytes of the string returned in `denotation`
   2243   *
   2244   * \snippet{doc} snippets.dox OrtStatus Return Value
   2245   */
   2246  ORT_API2_STATUS(GetDenotationFromTypeInfo, _In_ const OrtTypeInfo* type_info,
   2247                  _Out_ const char** const denotation, _Out_ size_t* len);
   2248 
   2249  /** \brief Get detailed map information from an ::OrtTypeInfo
   2250   *
   2251   * This augments ::OrtTypeInfo to return an ::OrtMapTypeInfo when the type is
   2252   * a map. The OrtMapTypeInfo has additional information about the map's key
   2253   * type and value type.
   2254   *
   2255   * This is used by WinML to support model reflection APIs.
   2256   *
   2257   * \param[out] type_info
   2258   * \param[out] out A pointer to the ::OrtMapTypeInfo. Do not free this value.
   2259   * If type_info does not contain a map, this value will be set to nullptr.
   2260   *
   2261   * \snippet{doc} snippets.dox OrtStatus Return Value
   2262   */
   2263  ORT_API2_STATUS(CastTypeInfoToMapTypeInfo, _In_ const OrtTypeInfo* type_info,
   2264                  _Outptr_result_maybenull_ const OrtMapTypeInfo** out);
   2265 
   2266  /** \brief Cast ::OrtTypeInfo to an ::OrtSequenceTypeInfo
   2267   *
   2268   * This api augments ::OrtTypeInfo to return an ::OrtSequenceTypeInfo when the
   2269   * type is a sequence. The ::OrtSequenceTypeInfo has additional information
   2270   * about the sequence's element type.
   2271   *
   2272   * This is used by WinML to support model reflection APIs.
   2273   *
   2274   * \param[in] type_info
   2275   * \param[out] out A pointer to the OrtSequenceTypeInfo. Do not free this
   2276   * value. If type_info doesn not contain a sequence, this value will be set to
   2277   * nullptr.
   2278   *
   2279   * \snippet{doc} snippets.dox OrtStatus Return Value
   2280   */
   2281  ORT_API2_STATUS(CastTypeInfoToSequenceTypeInfo,
   2282                  _In_ const OrtTypeInfo* type_info,
   2283                  _Outptr_result_maybenull_ const OrtSequenceTypeInfo** out);
   2284 
   2285  /// @}
   2286  /// \name OrtMapTypeInfo
   2287  /// @{
   2288 
   2289  /** \brief Get key type from an ::OrtMapTypeInfo
   2290   *
   2291   * Key types are restricted to being scalar types.
   2292   *
   2293   * This is used by WinML to support model reflection APIs.
   2294   *
   2295   * \param[in] map_type_info
   2296   * \param[out] out
   2297   *
   2298   * \snippet{doc} snippets.dox OrtStatus Return Value
   2299   */
   2300  ORT_API2_STATUS(GetMapKeyType, _In_ const OrtMapTypeInfo* map_type_info,
   2301                  _Out_ enum ONNXTensorElementDataType* out);
   2302 
   2303  /** \brief Get the value type from an ::OrtMapTypeInfo
   2304   *
   2305   * \param[in] map_type_info
   2306   * \param[out] type_info A copy of the OrtTypeInfo for the map value type.
   2307   *                       The user must free this value with ReleaseTypeInfo.
   2308   *
   2309   * \snippet{doc} snippets.dox OrtStatus Return Value
   2310   */
   2311  ORT_API2_STATUS(GetMapValueType, _In_ const OrtMapTypeInfo* map_type_info,
   2312                  _Outptr_ OrtTypeInfo** type_info);
   2313 
   2314  /// @}
   2315  /// \name OrtSequenceTypeInfo
   2316  /// @{
   2317 
   2318  /** \brief Get element type from an ::OrtSequenceTypeInfo
   2319   *
   2320   * This is used by WinML to support model reflection APIs.
   2321   *
   2322   * \param[in] sequence_type_info
   2323   * \param[out] type_info A copy of the OrtTypeInfo for the sequence element
   2324   * type. The user must free this value with ReleaseTypeInfo.
   2325   *
   2326   * \snippet{doc} snippets.dox OrtStatus Return Value
   2327   */
   2328  ORT_API2_STATUS(GetSequenceElementType,
   2329                  _In_ const OrtSequenceTypeInfo* sequence_type_info,
   2330                  _Outptr_ OrtTypeInfo** type_info);
   2331 
   2332  /// @}
   2333  /// \name OrtMapTypeInfo
   2334  /// @{
   2335  ORT_CLASS_RELEASE(MapTypeInfo);
   2336  /// @}
   2337  /// \name OrtSequenceTypeInfo
   2338  /// @{
   2339  ORT_CLASS_RELEASE(SequenceTypeInfo);
   2340 
   2341  /// @}
   2342  /// \name OrtSession
   2343  /// @{
   2344 
   2345  /** \brief End profiling and return filename of the profile data
   2346   *
   2347   * Profiling is turned on through OrtApi::EnableProfiling
   2348   *
   2349   * \param[in] session
   2350   * \param[in] allocator
   2351   * \param[out] out Null terminated string of the filename, allocated using
   2352   * `allocator`. Must be freed using `allocator`
   2353   *
   2354   * \snippet{doc} snippets.dox OrtStatus Return Value
   2355   */
   2356  ORT_API2_STATUS(SessionEndProfiling, _In_ OrtSession* session,
   2357                  _Inout_ OrtAllocator* allocator, _Outptr_ char** out);
   2358 
   2359  /** \brief Get ::OrtModelMetadata from an ::OrtSession
   2360   *
   2361   * \param[in] session
   2362   * \param[out] out Newly created ::OrtModelMetadata. Must be freed using
   2363   * OrtApi::ReleaseModelMetadata
   2364   *
   2365   * \snippet{doc} snippets.dox OrtStatus Return Value
   2366   */
   2367  ORT_API2_STATUS(SessionGetModelMetadata, _In_ const OrtSession* session,
   2368                  _Outptr_ OrtModelMetadata** out);
   2369 
   2370  /// @}
   2371  /// \name OrtModelMetadata
   2372  /// @{
   2373 
   2374  /** \brief Get `producer name` from an ::OrtModelMetadata
   2375   *
   2376   * \param[in] model_metadata
   2377   * \param[in] allocator
   2378   * \param[out] value Set to a null terminated string allocated using
   2379   * `allocator`. Must be freed using `allocator`
   2380   *
   2381   * \snippet{doc} snippets.dox OrtStatus Return Value
   2382   */
   2383  ORT_API2_STATUS(ModelMetadataGetProducerName,
   2384                  _In_ const OrtModelMetadata* model_metadata,
   2385                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   2386 
   2387  /** \brief Get `graph name` from an ::OrtModelMetadata
   2388   *
   2389   * \param[in] model_metadata
   2390   * \param[in] allocator
   2391   * \param[out] value Set to a null terminated string allocated using
   2392   * `allocator`. Must be freed using `allocator`
   2393   *
   2394   * \snippet{doc} snippets.dox OrtStatus Return Value
   2395   */
   2396  ORT_API2_STATUS(ModelMetadataGetGraphName,
   2397                  _In_ const OrtModelMetadata* model_metadata,
   2398                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   2399 
   2400  /** \brief Get `domain` from an ::OrtModelMetadata
   2401   *
   2402   * \param[in] model_metadata
   2403   * \param[in] allocator
   2404   * \param[out] value Set to a null terminated string allocated using
   2405   * `allocator`. Must be freed using `allocator`
   2406   *
   2407   * \snippet{doc} snippets.dox OrtStatus Return Value
   2408   */
   2409  ORT_API2_STATUS(ModelMetadataGetDomain,
   2410                  _In_ const OrtModelMetadata* model_metadata,
   2411                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   2412 
   2413  /** \brief Get `description` from an ::OrtModelMetadata
   2414   *
   2415   * \param[in] model_metadata
   2416   * \param[in] allocator
   2417   * \param[out] value Set to a null terminated string allocated using
   2418   * `allocator`. Must be freed using `allocator`
   2419   *
   2420   * \snippet{doc} snippets.dox OrtStatus Return Value
   2421   */
   2422  ORT_API2_STATUS(ModelMetadataGetDescription,
   2423                  _In_ const OrtModelMetadata* model_metadata,
   2424                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   2425 
   2426  /** \brief Return data for a key in the custom metadata map in an
   2427   * ::OrtModelMetadata
   2428   *
   2429   * \param[in] model_metadata
   2430   * \param[in] allocator
   2431   * \param[in] key Null terminated string
   2432   * \param[out] value Set to a null terminated string allocated using
   2433   * `allocator`. Must be freed using `allocator` `value` will be set to nullptr
   2434   * if the given key is not found in the custom metadata map.
   2435   *
   2436   * \snippet{doc} snippets.dox OrtStatus Return Value
   2437   */
   2438  ORT_API2_STATUS(ModelMetadataLookupCustomMetadataMap,
   2439                  _In_ const OrtModelMetadata* model_metadata,
   2440                  _Inout_ OrtAllocator* allocator, _In_ const char* key,
   2441                  _Outptr_result_maybenull_ char** value);
   2442 
   2443  /** \brief Get version number from an ::OrtModelMetadata
   2444   *
   2445   * \param[in] model_metadata
   2446   * \param[out] value Set to the version number
   2447   *
   2448   * \snippet{doc} snippets.dox OrtStatus Return Value
   2449   */
   2450  ORT_API2_STATUS(ModelMetadataGetVersion,
   2451                  _In_ const OrtModelMetadata* model_metadata,
   2452                  _Out_ int64_t* value);
   2453 
   2454  ORT_CLASS_RELEASE(ModelMetadata);
   2455 
   2456  /// @}
   2457  /// \name OrtEnv
   2458  /// @{
   2459 
   2460  /** \brief Create an OrtEnv
   2461   *
   2462   * Create an environment with global threadpools that will be shared across
   2463   * sessions. Use this in conjunction with OrtApi::DisablePerSessionThreads or
   2464   * else the session will use its own thread pools.
   2465   *
   2466   * \param[in] log_severity_level The log severity level.
   2467   * \param[in] logid The log identifier.
   2468   * \param[in] tp_options
   2469   * \param[out] out Returned newly created OrtEnv. Must be freed with
   2470   * OrtApi::ReleaseEnv
   2471   *
   2472   * \snippet{doc} snippets.dox OrtStatus Return Value
   2473   */
   2474  ORT_API2_STATUS(CreateEnvWithGlobalThreadPools,
   2475                  OrtLoggingLevel log_severity_level, _In_ const char* logid,
   2476                  _In_ const OrtThreadingOptions* tp_options,
   2477                  _Outptr_ OrtEnv** out);
   2478 
   2479  /// @}
   2480  /// \name OrtSessionOptions
   2481  /// @{
   2482 
   2483  /** \brief Use global thread pool on a session
   2484   *
   2485   * Disable using per session thread pool and use the shared global threadpool.
   2486   * This should be used in conjunction with
   2487   * OrtApi::CreateEnvWithGlobalThreadPools.
   2488   *
   2489   * \param[in] options
   2490   *
   2491   * \snippet{doc} snippets.dox OrtStatus Return Value
   2492   */
   2493  ORT_API2_STATUS(DisablePerSessionThreads, _Inout_ OrtSessionOptions* options);
   2494 
   2495  /// @}
   2496  /// \name OrtThreadingOptions
   2497  /// @{
   2498 
   2499  /** \brief Create an ::OrtThreadingOptions
   2500   *
   2501   * \param[out] out Newly created ::OrtThreadingOptions. Must be freed with
   2502   * OrtApi::ReleaseThreadingOptions
   2503   * \snippet{doc} snippets.dox OrtStatus Return Value
   2504   */
   2505  ORT_API2_STATUS(CreateThreadingOptions, _Outptr_ OrtThreadingOptions** out);
   2506 
   2507  ORT_CLASS_RELEASE(ThreadingOptions);
   2508 
   2509  /// @}
   2510  /// \name OrtModelMetadata
   2511  /// @{
   2512 
   2513  /**
   2514   *
   2515   * \param[in] model_metadata
   2516   * \param[in] allocator
   2517   * \param[out] keys Array of null terminated strings (array count = num_keys)
   2518   * allocated using `allocator`. The strings and the pointer array must be
   2519   * freed using `allocator` `keys` will be set to nullptr if the custom
   2520   * metadata map is empty.
   2521   * \param[out] num_keys Set to the number of elements in the `keys` array
   2522   *
   2523   * \snippet{doc} snippets.dox OrtStatus Return Value
   2524   */
   2525  ORT_API2_STATUS(ModelMetadataGetCustomMetadataMapKeys,
   2526                  _In_ const OrtModelMetadata* model_metadata,
   2527                  _Inout_ OrtAllocator* allocator,
   2528                  _Outptr_result_buffer_maybenull_(*num_keys) char*** keys,
   2529                  _Out_ int64_t* num_keys);
   2530 
   2531  /// @}
   2532  /// \name OrtSessionOptions
   2533  /// @{
   2534 
   2535  /**
   2536   *
   2537   * Override symbolic dimensions (by specific name strings) with actual values
   2538   * if known at session initialization time to enable optimizations that can
   2539   * take advantage of fixed values (such as memory planning, etc)
   2540   *
   2541   */
   2542  ORT_API2_STATUS(AddFreeDimensionOverrideByName,
   2543                  _Inout_ OrtSessionOptions* options, _In_ const char* dim_name,
   2544                  _In_ int64_t dim_value);
   2545 
   2546  /// @}
   2547  /// \name Misc
   2548  /// @{
   2549 
   2550  /** \brief Get the names of all available providers
   2551   *
   2552   * \note The providers in the list are not guaranteed to be usable. They may
   2553   * fail to load due to missing system dependencies. For example, if the
   2554   * CUDA/cuDNN libraries are not installed, the CUDA provider will report an
   2555   * error when it is added to the session options.
   2556   *
   2557   * \param[out] out_ptr Set to a pointer to an array of null terminated strings
   2558   * of the available providers. The entries and the array itself must be freed
   2559   * using OrtApi::ReleaseAvailableProviders
   2560   * \param[out] provider_length Set to the number of entries in the `out_ptr`
   2561   * array
   2562   *
   2563   * \snippet{doc} snippets.dox OrtStatus Return Value
   2564   */
   2565  ORT_API2_STATUS(GetAvailableProviders, _Outptr_ char*** out_ptr,
   2566                  _Out_ int* provider_length);
   2567 
   2568  /** \brief Release data from OrtApi::GetAvailableProviders. This API will
   2569   * never fail so you can rely on it in a noexcept code.
   2570   *
   2571   * \param[in] ptr The `out_ptr` result from OrtApi::GetAvailableProviders.
   2572   * \param[in] providers_length The `provider_length` result from
   2573   * OrtApi::GetAvailableProviders
   2574   *
   2575   * \snippet{doc} snippets.dox OrtStatus Return Value
   2576   */
   2577  ORT_API2_STATUS(ReleaseAvailableProviders, _In_ char** ptr,
   2578                  _In_ int providers_length);
   2579 
   2580  /// @}
   2581  /// \name OrtValue
   2582  /// @{
   2583 
   2584  /** \brief Get the length of a single string in a string tensor
   2585   *
   2586   * \param[in] value A string tensor
   2587   * \param[in] index Index of the string in the tensor
   2588   * \param[out] out Set to number of bytes of the string element
   2589   *
   2590   * \snippet{doc} snippets.dox OrtStatus Return Value
   2591   */
   2592  ORT_API2_STATUS(GetStringTensorElementLength, _In_ const OrtValue* value,
   2593                  size_t index, _Out_ size_t* out);
   2594 
   2595  /** \brief Get a single string from a string tensor
   2596   *
   2597   * \param[in] value A string tensor
   2598   * \param[in] s_len Number of bytes in the `s` buffer. Must match the value
   2599   * returned by OrtApi::GetStringTensorElementLength.
   2600   * \param[in] index Index of the string in the tensor
   2601   * \param[out] s The string element contents in UTF-8 encoding. The string is
   2602   * NOT null-terminated.
   2603   *
   2604   * \snippet{doc} snippets.dox OrtStatus Return Value
   2605   */
   2606  ORT_API2_STATUS(GetStringTensorElement, _In_ const OrtValue* value,
   2607                  size_t s_len, size_t index,
   2608                  _Out_writes_bytes_all_(s_len) void* s);
   2609 
   2610  /** \brief Set a single string in a string tensor
   2611   *
   2612   * \param[in] value A string tensor
   2613   * \param[in] s A null terminated UTF-8 encoded string
   2614   * \param[in] index Index of the string in the tensor to set
   2615   *
   2616   * \snippet{doc} snippets.dox OrtStatus Return Value
   2617   */
   2618  ORT_API2_STATUS(FillStringTensorElement, _Inout_ OrtValue* value,
   2619                  _In_ const char* s, size_t index);
   2620 
   2621  /// @}
   2622  /// \name OrtSessionOptions
   2623  /// @{
   2624 
   2625  /** \brief Set a session configuration entry as a pair of strings
   2626   *
   2627   * If a configuration with same key exists, this will overwrite the
   2628   * configuration with the given config_value.
   2629   *
   2630   * The config_key and the format of config_value are defined in
   2631   * onnxruntime_session_options_config_keys.h
   2632   *
   2633   * \param[in] options
   2634   * \param[in] config_key A null terminated string representation of the config
   2635   * key
   2636   * \param[in] config_value A null terminated string representation of the
   2637   * config value
   2638   *
   2639   * \snippet{doc} snippets.dox OrtStatus Return Value
   2640   */
   2641  ORT_API2_STATUS(AddSessionConfigEntry, _Inout_ OrtSessionOptions* options,
   2642                  _In_z_ const char* config_key,
   2643                  _In_z_ const char* config_value);
   2644 
   2645  /// @}
   2646  /// \name OrtAllocator
   2647  /// @{
   2648 
   2649  /** \brief Create an allocator for an ::OrtSession following an
   2650   * ::OrtMemoryInfo
   2651   *
   2652   * \param[in] session
   2653   * \param[in] mem_info valid ::OrtMemoryInfo instance
   2654   * \param[out] out Newly created ::OrtAllocator. Must be freed with
   2655   * OrtApi::ReleaseAllocator
   2656   *
   2657   * \snippet{doc} snippets.dox OrtStatus Return Value
   2658   */
   2659  ORT_API2_STATUS(CreateAllocator, _In_ const OrtSession* session,
   2660                  _In_ const OrtMemoryInfo* mem_info,
   2661                  _Outptr_ OrtAllocator** out);
   2662 
   2663  /** \brief Release an ::OrtAllocator obtained from OrtApi::CreateAllocator
   2664   */
   2665  ORT_CLASS_RELEASE(Allocator);
   2666 
   2667  /// @}
   2668  /// \name OrtSession
   2669  /// @{
   2670 
   2671  /** \brief Run a model using Io Bindings for the inputs & outputs
   2672   *
   2673   * \see OrtApi::Run
   2674   *
   2675   * \param[in] session
   2676   * \param[in] run_options
   2677   * \param[in] binding_ptr
   2678   *
   2679   * \snippet{doc} snippets.dox OrtStatus Return Value
   2680   */
   2681  ORT_API2_STATUS(RunWithBinding, _Inout_ OrtSession* session,
   2682                  _In_ const OrtRunOptions* run_options,
   2683                  _In_ const OrtIoBinding* binding_ptr);
   2684 
   2685  /** \brief Create an ::OrtIoBinding instance
   2686   *
   2687   * An IoBinding object allows one to bind pre-allocated ::OrtValue%s to input
   2688   * names. Thus if you want to use a raw on device buffer as input or output
   2689   * you can avoid extra copy during runtime.
   2690   *
   2691   * \param[in] session
   2692   * \param[out] out Newly created ::OrtIoBinding. Must be freed with
   2693   * OrtApi::ReleaseIoBinding
   2694   *
   2695   * \snippet{doc} snippets.dox OrtStatus Return Value
   2696   */
   2697  ORT_API2_STATUS(CreateIoBinding, _Inout_ OrtSession* session,
   2698                  _Outptr_ OrtIoBinding** out);
   2699 
   2700  /// @}
   2701  /// \name OrtIoBinding
   2702  /// @{
   2703 
   2704  /** \brief Release an ::OrtIoBinding obtained from OrtApi::CreateIoBinding
   2705   */
   2706  ORT_CLASS_RELEASE(IoBinding);
   2707 
   2708  /** \brief Bind an ::OrtValue to an ::OrtIoBinding input
   2709   *
   2710   * When using OrtApi::RunWithBinding this value is used for the named input
   2711   *
   2712   * \param[in] binding_ptr
   2713   * \param[in] name Name for the model input
   2714   * \param[in] val_ptr ::OrtValue of Tensor type.
   2715   *
   2716   * \snippet{doc} snippets.dox OrtStatus Return Value
   2717   */
   2718  ORT_API2_STATUS(BindInput, _Inout_ OrtIoBinding* binding_ptr,
   2719                  _In_ const char* name, _In_ const OrtValue* val_ptr);
   2720 
   2721  /** \brief Bind an ::OrtValue to an ::OrtIoBinding output
   2722   *
   2723   * When using OrtApi::RunWithBinding this value is used for the named output
   2724   *
   2725   * \param[in] binding_ptr
   2726   * \param[in] name Null terminated string of the model output name
   2727   * \param[in] val_ptr ::OrtValue of Tensor type.
   2728   *
   2729   * \snippet{doc} snippets.dox OrtStatus Return Value
   2730   */
   2731  ORT_API2_STATUS(BindOutput, _Inout_ OrtIoBinding* binding_ptr,
   2732                  _In_ const char* name, _In_ const OrtValue* val_ptr);
   2733 
   2734  /** \brief Bind an ::OrtIoBinding output to a device
   2735   *
   2736   * Binds the ::OrtValue to a device which is specified by ::OrtMemoryInfo.
   2737   * You can either create an instance of ::OrtMemoryInfo with a device id or
   2738   * obtain one from the allocator that you have created/are using This is
   2739   * useful when one or more outputs have dynamic shapes and, it is hard to
   2740   * pre-allocate and bind a chunk of memory within ::OrtValue ahead of time.
   2741   *
   2742   * \see OrtApi::RunWithBinding
   2743   *
   2744   * \param[in] binding_ptr
   2745   * \param[in] name Null terminated string of the device name
   2746   * \param[in] mem_info_ptr
   2747   *
   2748   * \snippet{doc} snippets.dox OrtStatus Return Value
   2749   */
   2750  ORT_API2_STATUS(BindOutputToDevice, _Inout_ OrtIoBinding* binding_ptr,
   2751                  _In_ const char* name,
   2752                  _In_ const OrtMemoryInfo* mem_info_ptr);
   2753 
   2754  /** \brief Get the names of an ::OrtIoBinding's outputs
   2755   *
   2756   * Returns the names of the outputs in the order they were bound. This is
   2757   * useful after running the model with bound outputs because the returned
   2758   * names are in order in which output ::OrtValue are returned. This is useful
   2759   * if the order of outputs and their names is not known.
   2760   *
   2761   * \param[in] binding_ptr
   2762   * \param[in] allocator Allocator used to allocate continuous buffers for
   2763   * output strings and lengths.
   2764   * \param[out] buffer Returns an array of non-null terminated UTF-8 strings.
   2765   * The number of strings stored is returned in the count parameter. This
   2766   * buffer is allocated using `allocator` and must be freed using it.
   2767   * \param[out] lengths Returns an array of `count` lengths of the strings
   2768   * returned in `buffer` This buffer is allocated using `allocator` and must be
   2769   * freed using it.
   2770   * \param[out] count Number of strings returned. If `binding_ptr` has no bound
   2771   * outputs, zero is returned, no memory allocation is performed and buffer and
   2772   * lengths are set to nullptr.
   2773   *
   2774   * \snippet{doc} snippets.dox OrtStatus Return Value
   2775   */
   2776  ORT_API2_STATUS(GetBoundOutputNames, _In_ const OrtIoBinding* binding_ptr,
   2777                  _In_ OrtAllocator* allocator, _Out_ char** buffer,
   2778                  _Out_writes_all_(count) size_t** lengths,
   2779                  _Out_ size_t* count);
   2780 
   2781  /** \brief Get the output ::OrtValue objects from an ::OrtIoBinding
   2782   *
   2783   * Returns an array of pointers to individually allocated ::OrtValue%s that
   2784   * contain results of a model execution with OrtApi::RunWithBinding The array
   2785   * contains the same number of ::OrtValue%s and they are in the same order as
   2786   * they were bound with OrtApi::BindOutput or OrtApi::BindOutputToDevice.
   2787   *
   2788   * The returned ::OrtValue%s must be released using OrtApi::ReleaseValue after
   2789   * they are no longer needed. The array is allocated using the specified
   2790   * instance of the allocator and must be freed using the same allocator after
   2791   * all the ::OrtValue%s contained therein are individually released.
   2792   *
   2793   * \param[in] binding_ptr
   2794   * \param[in] allocator Allocator used to allocate output array
   2795   * \param[out] output Set to the allocated array of allocated ::OrtValue
   2796   * outputs. Set to nullptr if there are 0 outputs.
   2797   * \param[out] output_count Set to number of ::OrtValue%s returned
   2798   *
   2799   * \snippet{doc} snippets.dox OrtStatus Return Value
   2800   */
   2801  ORT_API2_STATUS(GetBoundOutputValues, _In_ const OrtIoBinding* binding_ptr,
   2802                  _In_ OrtAllocator* allocator,
   2803                  _Out_writes_all_(output_count) OrtValue*** output,
   2804                  _Out_ size_t* output_count);
   2805 
   2806  /** \brief Clears any previously set Inputs for an ::OrtIoBinding
   2807   */
   2808  void(ORT_API_CALL* ClearBoundInputs)(_Inout_ OrtIoBinding* binding_ptr)
   2809      NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
   2810 
   2811  /** \brief Clears any previously set Outputs for an ::OrtIoBinding
   2812   */
   2813  void(ORT_API_CALL* ClearBoundOutputs)(_Inout_ OrtIoBinding* binding_ptr)
   2814      NO_EXCEPTION ORT_ALL_ARGS_NONNULL;
   2815 
   2816  /// @}
   2817  /// \name OrtValue
   2818  /// @{
   2819 
   2820  /** \brief Direct memory access to a specified tensor element
   2821   *
   2822   * For example, given a tensor with shape of [3,224,224], a pointer to the
   2823   * element at location [2,150,128] can be retrieved
   2824   *
   2825   * This function only works for numeric type tensors (No strings, etc).
   2826   * This is a no-copy method whose returned pointer is valid until the passed
   2827   * in ::OrtValue is free'd.
   2828   *
   2829   * \param[in] value
   2830   * \param[in] location_values Pointer to an array of index values that specify
   2831   * an element's location relative to its shape
   2832   * \param[in] location_values_count Number of elements in location_values.
   2833   * Must match the number of elements in the tensor's shape.
   2834   * \param[out] out Set to a pointer to the element specified
   2835   *
   2836   * \snippet{doc} snippets.dox OrtStatus Return Value
   2837   */
   2838  ORT_API2_STATUS(TensorAt, _Inout_ OrtValue* value,
   2839                  const int64_t* location_values, size_t location_values_count,
   2840                  _Outptr_ void** out);
   2841 
   2842  /// @}
   2843  /// \name OrtEnv
   2844  /// @{
   2845 
   2846  /** \brief Create an allocator and register it with the ::OrtEnv
   2847   *
   2848   * Enables sharing the allocator between multiple sessions that use the same
   2849   * env instance. Lifetime of the created allocator will be valid for the
   2850   * duration of the environment. Returns an error if an allocator with the same
   2851   * ::OrtMemoryInfo is already registered.
   2852   *
   2853   * See https://onnxruntime.ai/docs/get-started/with-c.html for details.
   2854   *
   2855   * \param[in] env ::OrtEnv instance
   2856   * \param[in] mem_info
   2857   * \param[in] arena_cfg Pass nullptr for defaults
   2858   *
   2859   * \snippet{doc} snippets.dox OrtStatus Return Value
   2860   */
   2861  ORT_API2_STATUS(CreateAndRegisterAllocator, _Inout_ OrtEnv* env,
   2862                  _In_ const OrtMemoryInfo* mem_info,
   2863                  _In_ const OrtArenaCfg* arena_cfg);
   2864 
   2865  /** \brief Set language projection
   2866   *
   2867   * Set the language projection for collecting telemetry data when Env is
   2868   * created.
   2869   *
   2870   * The default is ORT_PROJECTION_C, which means it will classify the language
   2871   * not in the list to C also.
   2872   *
   2873   * \param[in] ort_env
   2874   * \param[in] projection
   2875   *
   2876   * \snippet{doc} snippets.dox OrtStatus Return Value
   2877   */
   2878  ORT_API2_STATUS(SetLanguageProjection, _In_ const OrtEnv* ort_env,
   2879                  _In_ OrtLanguageProjection projection);
   2880 
   2881  /// @}
   2882  /// \name OrtSession
   2883  /// @{
   2884 
   2885  /** \brief Return the time that profiling was started
   2886   *
   2887   * \note The timer precision varies per platform. On Windows and MacOS, the
   2888   * precision will be ~100ns
   2889   *
   2890   * \param[in] session
   2891   * \param[out] out nanoseconds of profiling's start time
   2892   *
   2893   * \snippet{doc} snippets.dox OrtStatus Return Value
   2894   */
   2895  ORT_API2_STATUS(SessionGetProfilingStartTimeNs,
   2896                  _In_ const OrtSession* session, _Outptr_ uint64_t* out);
   2897 
   2898  /// @}
   2899  /// \name OrtThreadingOptions
   2900  /// @{
   2901 
   2902  /** \brief Set global intra-op thread count
   2903   *
   2904   * This configures the global thread pool options to be used in the call to
   2905   * OrtApi::CreateEnvWithGlobalThreadPools
   2906   *
   2907   * \param[in] tp_options
   2908   * \param[in] intra_op_num_threads Number of threads, special values:<br>
   2909   *    0 = Use default thread count<br>
   2910   *    1 = The invoking thread will be used; no threads will be created in the
   2911   * thread pool.
   2912   *
   2913   * \snippet{doc} snippets.dox OrtStatus Return Value
   2914   */
   2915  ORT_API2_STATUS(SetGlobalIntraOpNumThreads,
   2916                  _Inout_ OrtThreadingOptions* tp_options,
   2917                  int intra_op_num_threads);
   2918 
   2919  /** \brief Set global inter-op thread count
   2920   *
   2921   * This configures the global thread pool options to be used in the call to
   2922   * OrtApi::CreateEnvWithGlobalThreadPools
   2923   *
   2924   * \param[in] tp_options
   2925   * \param[in] inter_op_num_threads Number of threads, special values:<br>
   2926   *    0 = Use default thread count<br>
   2927   *    1 = The invoking thread will be used; no threads will be created in the
   2928   * thread pool.
   2929   *
   2930   * \snippet{doc} snippets.dox OrtStatus Return Value
   2931   */
   2932  ORT_API2_STATUS(SetGlobalInterOpNumThreads,
   2933                  _Inout_ OrtThreadingOptions* tp_options,
   2934                  int inter_op_num_threads);
   2935 
   2936  /** \brief Set global spin control options
   2937   *
   2938   * This will configure the global thread pool options to be used in the call
   2939   * to OrtApi::CreateEnvWithGlobalThreadPools. Allow spinning of thread pools
   2940   * when their queues are empty. This will set the value for both inter_op and
   2941   * intra_op threadpools.
   2942   *
   2943   * \param[in] tp_options
   2944   * \param[in] allow_spinning Valid values are 0 or 1.<br>
   2945   *   0 = It won't spin (recommended if CPU usage is high)<br>
   2946   *   1 = Threadpool will spin to wait for queue to become non-empty
   2947   *
   2948   * \snippet{doc} snippets.dox OrtStatus Return Value
   2949   */
   2950  ORT_API2_STATUS(SetGlobalSpinControl, _Inout_ OrtThreadingOptions* tp_options,
   2951                  int allow_spinning);
   2952 
   2953  /// @}
   2954  /// \name OrtSessionOptions
   2955  /// @{
   2956 
   2957  /** \brief Add a pre-allocated initializer to a session
   2958   *
   2959   * If a model contains an initializer with a name that is same as the name
   2960   * passed to this call, ORT will use this initializer instance instead of
   2961   * deserializing one from the model file. This is useful when you want to
   2962   * share the same initializer across sessions.
   2963   *
   2964   * \param[in] options
   2965   * \param[in] name Null terminated string of the initializer name
   2966   * \param[in] val ::OrtValue containing the initializer. Its lifetime and the
   2967   * underlying initializer buffer must be managed by the user (created using
   2968   * the OrtApi::CreateTensorWithDataAsOrtValue) and it must outlive the session
   2969   * object to which it is added.
   2970   *
   2971   * \snippet{doc} snippets.dox OrtStatus Return Value
   2972   */
   2973  ORT_API2_STATUS(AddInitializer, _Inout_ OrtSessionOptions* options,
   2974                  _In_z_ const char* name, _In_ const OrtValue* val);
   2975 
   2976  /// @}
   2977  /// \name OrtEnv
   2978  /// @{
   2979 
   2980  /**
   2981   * Create a custom environment with global threadpools and logger that will be
   2982   * shared across sessions. Use this in conjunction with
   2983   * OrtApi::DisablePerSessionThreads or else the session will use its own
   2984   * thread pools.
   2985   *
   2986   * \param[in] logging_function A pointer to a logging function.
   2987   * \param[in] logger_param A pointer to arbitrary data passed as the
   2988   * ::OrtLoggingFunction `param` parameter to `logging_function`.
   2989   * \param[in] log_severity_level The log severity level.
   2990   * \param[in] logid The log identifier.
   2991   * \param[in] tp_options
   2992   * \param[out] out Newly created OrtEnv. Must be freed with OrtApi::ReleaseEnv
   2993   *
   2994   * \snippet{doc} snippets.dox OrtStatus Return Value
   2995   */
   2996  ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools,
   2997                  OrtLoggingFunction logging_function,
   2998                  _In_opt_ void* logger_param,
   2999                  OrtLoggingLevel log_severity_level, _In_ const char* logid,
   3000                  _In_ const struct OrtThreadingOptions* tp_options,
   3001                  _Outptr_ OrtEnv** out);
   3002 
   3003  /// @}
   3004  /// \name OrtSessionOptions
   3005  /// @{
   3006 
   3007  /** \brief Append CUDA provider to session options
   3008   *
   3009   * If CUDA is not available (due to a non CUDA enabled build, or if CUDA is
   3010   * not installed on the system), this function will return failure.
   3011   *
   3012   * \param[in] options
   3013   * \param[in] cuda_options
   3014   *
   3015   * \snippet{doc} snippets.dox OrtStatus Return Value
   3016   */
   3017  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CUDA,
   3018                  _In_ OrtSessionOptions* options,
   3019                  _In_ const OrtCUDAProviderOptions* cuda_options);
   3020 
   3021  /** \brief Append ROCM execution provider to the session options
   3022   *
   3023   * If ROCM is not available (due to a non ROCM enabled build, or if ROCM is
   3024   * not installed on the system), this function will return failure.
   3025   *
   3026   * \param[in] options
   3027   * \param[in] rocm_options
   3028   *
   3029   * \snippet{doc} snippets.dox OrtStatus Return Value
   3030   */
   3031  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_ROCM,
   3032                  _In_ OrtSessionOptions* options,
   3033                  _In_ const OrtROCMProviderOptions* rocm_options);
   3034 
   3035  /** \brief Append OpenVINO execution provider to the session options
   3036   *
   3037   * If OpenVINO is not available (due to a non OpenVINO enabled build, or if
   3038   * OpenVINO is not installed on the system), this function will fail.
   3039   *
   3040   * \param[in] options
   3041   * \param[in] provider_options
   3042   *
   3043   * \snippet{doc} snippets.dox OrtStatus Return Value
   3044   */
   3045  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_OpenVINO,
   3046                  _In_ OrtSessionOptions* options,
   3047                  _In_ const OrtOpenVINOProviderOptions* provider_options);
   3048 
   3049  /// @}
   3050  /// \name OrtThreadingOptions
   3051  /// @{
   3052 
   3053  /** \brief Set threading flush-to-zero and denormal-as-zero
   3054   *
   3055   * Sets global thread pool options to be used in the call to
   3056   * OrtApi::CreateEnvWithGlobalThreadPools. Flush-to-zero and denormal-as-zero
   3057   * are applied to threads in both intra and inter global thread pool.
   3058   * \note This option is not needed if the models used have no denormals.
   3059   * Having no denormals is recommended as this option may hurt model accuracy.
   3060   *
   3061   * \param[in] tp_options
   3062   *
   3063   * \snippet{doc} snippets.dox OrtStatus Return Value
   3064   */
   3065  ORT_API2_STATUS(SetGlobalDenormalAsZero,
   3066                  _Inout_ OrtThreadingOptions* tp_options);
   3067 
   3068  /// @}
   3069  /// \name OrtArenaCfg
   3070  /// @{
   3071 
   3072  /** \deprecated Use OrtApi::CreateArenaCfgV2
   3073   *
   3074   * This will create the configuration of an arena that can eventually be used
   3075   * to define an arena based allocator's behavior
   3076   *
   3077   * \param[in] max_mem Use 0 to allow ORT to choose the default
   3078   * \param[in] arena_extend_strategy Use -1 to allow ORT to choose the default,
   3079   * 0 = kNextPowerOfTwo, 1 = kSameAsRequested
   3080   * \param[in] initial_chunk_size_bytes Use -1 to allow ORT to choose the
   3081   * default
   3082   * \param[in] max_dead_bytes_per_chunk Use -1 to allow ORT to choose the
   3083   * default
   3084   * \param[in] out A pointer to an OrtArenaCfg instance
   3085   *
   3086   * \snippet{doc} snippets.dox OrtStatus Return Value
   3087   */
   3088  ORT_API2_STATUS(CreateArenaCfg, _In_ size_t max_mem,
   3089                  int arena_extend_strategy, int initial_chunk_size_bytes,
   3090                  int max_dead_bytes_per_chunk, _Outptr_ OrtArenaCfg** out);
   3091 
   3092  ORT_CLASS_RELEASE(ArenaCfg);
   3093 
   3094  /// @}
   3095  /// \name OrtModelMetadata
   3096  /// @{
   3097 
   3098  /**
   3099   * Use this to obtain the description of the graph present in the model
   3100   * (doc_string field of the GraphProto message within the ModelProto message).
   3101   * If it doesn't exist, an empty string will be returned.
   3102   *
   3103   * \param[in] model_metadata An instance of ::OrtModelMetadata
   3104   * \param[in] allocator Allocator used to allocate the string that will be
   3105   * returned back
   3106   * \param[out] value Set to a null terminated string allocated using
   3107   * `allocator`.  The caller is responsible for freeing it using `allocator`
   3108   *
   3109   * \snippet{doc} snippets.dox OrtStatus Return Value
   3110   */
   3111  ORT_API2_STATUS(ModelMetadataGetGraphDescription,
   3112                  _In_ const OrtModelMetadata* model_metadata,
   3113                  _Inout_ OrtAllocator* allocator, _Outptr_ char** value);
   3114 
   3115  /// @}
   3116  /// \name OrtSessionOptions
   3117  /// @{
   3118 
   3119  /** \brief Append TensorRT provider to session options
   3120   *
   3121   * If TensorRT is not available (due to a non TensorRT enabled build, or if
   3122   * TensorRT is not installed on the system), this function will return
   3123   * failure.
   3124   *
   3125   * \param[in] options
   3126   * \param[in] tensorrt_options
   3127   *
   3128   * \snippet{doc} snippets.dox OrtStatus Return Value
   3129   */
   3130  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT,
   3131                  _In_ OrtSessionOptions* options,
   3132                  _In_ const OrtTensorRTProviderOptions* tensorrt_options);
   3133 
   3134  /// @}
   3135  /// \name Misc
   3136  /// @{
   3137 
   3138  /** \brief Set current GPU device ID
   3139   *
   3140   * Set the current device id of the GPU execution provider
   3141   * (CUDA/tensorrt/rocm). The device id should be less than the total number of
   3142   * devices available. This is only useful when multiple-GPUs are installed and
   3143   * it is required to restrict execution to a single GPU.
   3144   *
   3145   * \param[in] device_id
   3146   *
   3147   * \snippet{doc} snippets.dox OrtStatus Return Value
   3148   */
   3149  ORT_API2_STATUS(SetCurrentGpuDeviceId, _In_ int device_id);
   3150 
   3151  /** \brief Get current GPU device ID
   3152   *
   3153   * Get the current device id of the GPU execution provider
   3154   * (CUDA/tensorrt/rocm).
   3155   *
   3156   * \see OrtApi::SetCurrentGpuDeviceId
   3157   *
   3158   * \param[out] device_id
   3159   *
   3160   * \snippet{doc} snippets.dox OrtStatus Return Value
   3161   */
   3162  ORT_API2_STATUS(GetCurrentGpuDeviceId, _In_ int* device_id);
   3163 
   3164  /// @}
   3165  /// \name OrtKernelInfo
   3166  /// Custom operator APIs.
   3167  /// @{
   3168 
   3169  /** \brief Fetch an array of int64_t values stored as an attribute in the
   3170   * graph node
   3171   *
   3172   *
   3173   * If `out` is nullptr, the value of `size` is set to the true size of the
   3174   * attribute array's size, and a success status is returned.
   3175   *
   3176   * If the `size` parameter is greater than or equal to the actual attribute
   3177   * array's size, the value of `size` is set to the true size of the attribute
   3178   * array's size, the provided memory is filled with the attribute's contents,
   3179   * and a success status is returned.
   3180   *
   3181   * If the `size` parameter is less than the actual attribute array's size and
   3182   * `out` is not nullptr, the value of `size` is set to the true size of the
   3183   * attribute array's size and a failure status is returned.)
   3184   *
   3185   * \param[in] info instance
   3186   * \param[in] name name of the attribute to be parsed
   3187   * \param[out] out pointer to memory where the attribute's contents are to be
   3188   * stored
   3189   * \param[in, out] size actual size of attribute array
   3190   *
   3191   * \snippet{doc} snippets.dox OrtStatus Return Value
   3192   */
   3193  ORT_API2_STATUS(KernelInfoGetAttributeArray_float,
   3194                  _In_ const OrtKernelInfo* info, _In_ const char* name,
   3195                  _Out_ float* out, _Inout_ size_t* size);
   3196 
   3197  /** \brief Fetch an array of int64_t values stored as an attribute in the
   3198   * graph node
   3199   *
   3200   * If `out` is nullptr, the value of `size` is set to the true size of the
   3201   * attribute array's size, and a success status is returned.
   3202   *
   3203   * If the `size` parameter is greater than or equal to the actual attribute
   3204   * array's size, the value of `size` is set to the true size of the attribute
   3205   * array's size, the provided memory is filled with the attribute's contents,
   3206   * and a success status is returned.
   3207   *
   3208   * If the `size` parameter is less than the actual attribute array's size and
   3209   * `out` is not nullptr, the value of `size` is set to the true size of the
   3210   * attribute array's size and a failure status is returned.)
   3211   *
   3212   * \param[in] info instance
   3213   * \param[in] name name of the attribute to be parsed
   3214   * \param[out] out pointer to memory where the attribute's contents are to be
   3215   * stored
   3216   * \param[in, out] size actual size of attribute array
   3217   *
   3218   * \snippet{doc} snippets.dox OrtStatus Return Value
   3219   */
   3220  ORT_API2_STATUS(KernelInfoGetAttributeArray_int64,
   3221                  _In_ const OrtKernelInfo* info, _In_ const char* name,
   3222                  _Out_ int64_t* out, _Inout_ size_t* size);
   3223 
   3224  /// @}
   3225  /// \name OrtArenaCfg
   3226  /// @{
   3227 
   3228  /** \brief Create an ::OrtArenaCfg
   3229   *
   3230   * Create the configuration of an arena that can eventually be used to define
   3231   * an arena based allocator's behavior.
   3232   *
   3233   * Supported keys are (See https://onnxruntime.ai/docs/get-started/with-c.html
   3234   * for details on what the following parameters mean and how to choose these
   3235   * values.): "max_mem": Maximum memory that can be allocated by the arena
   3236   * based allocator. Use 0 for ORT to pick the best value. Default is 0.
   3237   * "arena_extend_strategy": 0 = kNextPowerOfTwo, 1 = kSameAsRequested.
   3238   *  Use -1 to allow ORT to choose the default.
   3239   * "initial_chunk_size_bytes": (Possible) Size of the first allocation in the
   3240   * arena. Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1 to
   3241   * allow ORT to choose the default. Ultimately, the first allocation size is
   3242   * determined by the allocation memory request. "max_dead_bytes_per_chunk":
   3243   * Threshold of unused memory in an allocated chunk of arena memory after
   3244   *  crossing which the current chunk is chunked into 2.
   3245   * "initial_growth_chunk_size_bytes": (Possible) Size of the second allocation
   3246   * in the arena. Only relevant if arena strategy is `kNextPowerOfTwo`. Use -1
   3247   * to allow ORT to choose the default. "max_power_of_two_extend_bytes": The
   3248   * maximum enxtend size if arena strategy is `kNextPowerOfTwo`. It is not an
   3249   * allocation limit, it is only a limit for extension when requested byte is
   3250   * less than the limit. When requested bytes is more than the limit, allocator
   3251   * will still return as requested. Use -1 to allow ORT to choose the default
   3252   * 1GB for max_power_of_two_extend_bytes. Ultimately, the allocation size is
   3253   * determined by the allocation memory request. Further allocation sizes are
   3254   * governed by the arena extend strategy.
   3255   *
   3256   * \param[in] arena_config_keys Keys to configure the arena
   3257   * \param[in] arena_config_values Values to configure the arena
   3258   * \param[in] num_keys Number of keys in `arena_config_keys` and
   3259   * `arena_config_values`
   3260   * \param[out] out Newly created ::OrtArenaCfg. Must be freed with
   3261   * OrtApi::ReleaseArenaCfg
   3262   *
   3263   * \snippet{doc} snippets.dox OrtStatus Return Value
   3264   */
   3265  ORT_API2_STATUS(CreateArenaCfgV2,
   3266                  _In_reads_(num_keys) const char* const* arena_config_keys,
   3267                  _In_reads_(num_keys) const size_t* arena_config_values,
   3268                  _In_ size_t num_keys, _Outptr_ OrtArenaCfg** out);
   3269 
   3270  /// @}
   3271  /// \name OrtRunOptions
   3272  /// @{
   3273 
   3274  /** \brief Set a single run configuration entry as a pair of strings
   3275   *
   3276   * If a configuration with same key exists, this will overwrite the
   3277   * configuration with the given config_value
   3278   *
   3279   * The config_key and the format of config_value are defined in
   3280   * onnxruntime_run_options_config_keys.h
   3281   *
   3282   * \param[in] options
   3283   * \param[in] config_key A null terminated string representation of the config
   3284   * key
   3285   * \param[in] config_value  A null terminated string representation of the
   3286   * config value
   3287   *
   3288   * \snippet{doc} snippets.dox OrtStatus Return Value
   3289   */
   3290  ORT_API2_STATUS(AddRunConfigEntry, _Inout_ OrtRunOptions* options,
   3291                  _In_z_ const char* config_key,
   3292                  _In_z_ const char* config_value);
   3293 
   3294  /// @}
   3295  /// \name OrtPrepackedWeightsContainer
   3296  /// @{
   3297 
   3298  /** \brief Create an ::OrtPrepackedWeightsContainer
   3299   *
   3300   * This container will hold pre-packed buffers of shared initializers for
   3301   * sharing between sessions (i.e.) if there are shared initializers that can
   3302   * be shared between sessions, the pre-packed buffers of these (if any) may
   3303   * possibly be shared to provide memory footprint savings. Pass this container
   3304   * to sessions that you would like to share pre-packed buffers of shared
   3305   * initializers at session creation time.
   3306   *
   3307   *  \param[out] out Newly created ::OrtPrepackedWeightsContainer. Must be
   3308   * freed with OrtApi::ReleasePrepackedWeightsContainer
   3309   *
   3310   * \snippet{doc} snippets.dox OrtStatus Return Value
   3311   */
   3312  ORT_API2_STATUS(CreatePrepackedWeightsContainer,
   3313                  _Outptr_ OrtPrepackedWeightsContainer** out);
   3314 
   3315  /** \brief Release OrtPrepackedWeightsContainer instance
   3316   *
   3317   * \note instance must not be released until the sessions using it are
   3318   * released
   3319   */
   3320  ORT_CLASS_RELEASE(PrepackedWeightsContainer);
   3321 
   3322  /// @}
   3323  /// \name OrtSession
   3324  /// @{
   3325 
   3326  /** \brief Create session with prepacked weights container
   3327   *
   3328   * Same functionality offered by OrtApi::CreateSession except that a container
   3329   * that contains pre-packed weights' buffers is written into/read from by the
   3330   * created session. This is useful when used in conjunction with
   3331   * OrtApi::AddInitializer which injects shared initializer info into sessions.
   3332   * Wherever possible, the pre-packed versions of these shared initializers are
   3333   * cached in this container so that multiple sessions can just re-use these
   3334   * instead of duplicating these in memory.
   3335   *
   3336   * \param[in] env OrtEnv instance instance
   3337   * \param[in] model_path Null terminated string of the path (wchar on Windows,
   3338   * char otherwise)
   3339   * \param[in] options
   3340   * \param[in] prepacked_weights_container
   3341   * \param[out] out Newly created ::OrtSession. Must be freed with
   3342   * OrtApi::ReleaseSession
   3343   *
   3344   * \snippet{doc} snippets.dox OrtStatus Return Value
   3345   */
   3346  ORT_API2_STATUS(
   3347      CreateSessionWithPrepackedWeightsContainer, _In_ const OrtEnv* env,
   3348      _In_ const ORTCHAR_T* model_path, _In_ const OrtSessionOptions* options,
   3349      _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
   3350      _Outptr_ OrtSession** out);
   3351 
   3352  /** \brief Create session from memory with prepacked weights container
   3353   *
   3354   * Same functionality offered by OrtApi::CreateSessionFromArray except that a
   3355   * container that contains pre-packed weights' buffers is written into/read
   3356   * from by the created session. This is useful when used in conjunction with
   3357   * OrtApi::AddInitializer which injects shared initializer info into sessions.
   3358   * Wherever possible, the pre-packed versions of these shared initializers are
   3359   * cached in this container so that multiple sessions can just re-use these
   3360   * instead of duplicating these in memory.
   3361   *
   3362   * \param[in] env
   3363   * \param[in] model_data Array of bytes holding the model
   3364   * \param[in] model_data_length Number of bytes in `model_data_model`
   3365   * \param[in] options
   3366   * \param[in] prepacked_weights_container
   3367   * \param[out] out Newly created ::OrtSession. Must be freed with
   3368   * OrtApi::ReleaseSession
   3369   *
   3370   * \snippet{doc} snippets.dox OrtStatus Return Value
   3371   */
   3372  ORT_API2_STATUS(
   3373      CreateSessionFromArrayWithPrepackedWeightsContainer,
   3374      _In_ const OrtEnv* env, _In_ const void* model_data,
   3375      size_t model_data_length, _In_ const OrtSessionOptions* options,
   3376      _Inout_ OrtPrepackedWeightsContainer* prepacked_weights_container,
   3377      _Outptr_ OrtSession** out);
   3378 
   3379  /// @}
   3380  /// \name OrtSessionOptions
   3381  /// @{
   3382 
   3383  /** \brief Append TensorRT execution provider to the session options
   3384   *
   3385   * If TensorRT is not available (due to a non TensorRT enabled build), this
   3386   * function will return failure.
   3387   *
   3388   * This is slightly different from
   3389   * OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, it takes an
   3390   * ::OrtTensorRTProviderOptions which is publicly defined. This takes an
   3391   * opaque ::OrtTensorRTProviderOptionsV2 which must be created with
   3392   * OrtApi::CreateTensorRTProviderOptions.
   3393   *
   3394   * For OrtApi::SessionOptionsAppendExecutionProvider_TensorRT, the user needs
   3395   * to instantiate ::OrtTensorRTProviderOptions as well as allocate/release
   3396   * buffers for some members of ::OrtTensorRTProviderOptions. Here,
   3397   * OrtApi::CreateTensorRTProviderOptions and
   3398   * Ortapi::ReleaseTensorRTProviderOptions will do the memory management for
   3399   * you.
   3400   *
   3401   * \param[in] options
   3402   * \param[in] tensorrt_options
   3403   *
   3404   * \snippet{doc} snippets.dox OrtStatus Return Value
   3405   */
   3406  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_TensorRT_V2,
   3407                  _In_ OrtSessionOptions* options,
   3408                  _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options);
   3409 
   3410  /// @}
   3411  /// \name OrtTensorRTProviderOptionsV2
   3412  /// @{
   3413 
   3414  /** \brief Create an OrtTensorRTProviderOptionsV2
   3415   *
   3416   * \param[out] out Newly created ::OrtTensorRTProviderOptionsV2. Must be
   3417   * released with OrtApi::ReleaseTensorRTProviderOptions
   3418   *
   3419   * \snippet{doc} snippets.dox OrtStatus Return Value
   3420   */
   3421  ORT_API2_STATUS(CreateTensorRTProviderOptions,
   3422                  _Outptr_ OrtTensorRTProviderOptionsV2** out);
   3423 
   3424  /** \brief Set options in a TensorRT Execution Provider.
   3425   *
   3426   * Please refer to
   3427   * https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#cc
   3428   * to know the available keys and values. Key should be in null terminated
   3429   * string format of the member of ::OrtTensorRTProviderOptionsV2 and value
   3430   * should be its related range. Recreates the options and only sets the
   3431   * supplied values.
   3432   *
   3433   * For example, key="trt_max_workspace_size" and value="2147483648"
   3434   *
   3435   * \param[in] tensorrt_options
   3436   * \param[in] provider_options_keys Array of UTF-8 null-terminated string for
   3437   * provider options keys
   3438   * \param[in] provider_options_values Array of UTF-8 null-terminated string
   3439   * for provider options values
   3440   * \param[in] num_keys Number of elements in the `provider_option_keys` and
   3441   * `provider_options_values` arrays
   3442   *
   3443   * \snippet{doc} snippets.dox OrtStatus Return Value
   3444   */
   3445  ORT_API2_STATUS(UpdateTensorRTProviderOptions,
   3446                  _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options,
   3447                  _In_reads_(num_keys) const char* const* provider_options_keys,
   3448                  _In_reads_(num_keys)
   3449                      const char* const* provider_options_values,
   3450                  _In_ size_t num_keys);
   3451 
   3452  /** \brief Get serialized TensorRT provider options string.
   3453   *
   3454   * For example,
   3455   * "trt_max_workspace_size=2147483648;trt_max_partition_iterations=10;trt_int8_enable=1;......"
   3456   *
   3457   * \param tensorrt_options - OrtTensorRTProviderOptionsV2 instance
   3458   * \param allocator - a ptr to an instance of OrtAllocator obtained with
   3459   * OrtApi::CreateAllocator or OrtApi::GetAllocatorWithDefaultOptions the
   3460   * specified allocator will be used to allocate continuous buffers for output
   3461   * strings and lengths.
   3462   * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'.
   3463   * The caller is responsible for using the same allocator to free it.
   3464   *
   3465   * \snippet{doc} snippets.dox OrtStatus Return Value
   3466   */
   3467  ORT_API2_STATUS(GetTensorRTProviderOptionsAsString,
   3468                  _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options,
   3469                  _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
   3470 
   3471  /** \brief Release an ::OrtTensorRTProviderOptionsV2
   3472   *
   3473   * \note This is an exception in the naming convention of other Release*
   3474   * functions, as the name of the method does not have the V2 suffix, but the
   3475   * type does
   3476   */
   3477  void(ORT_API_CALL* ReleaseTensorRTProviderOptions)(
   3478      _Frees_ptr_opt_ OrtTensorRTProviderOptionsV2* input);
   3479 
   3480  /// @}
   3481  /// \name OrtSessionOptions
   3482  /// @{
   3483 
   3484  /** \brief Enable custom operators
   3485   *
   3486   * See onnxruntime-extensions:
   3487   * https://github.com/microsoft/onnxruntime-extensions.git
   3488   *
   3489   * \snippet{doc} snippets.dox OrtStatus Return Value
   3490   */
   3491  ORT_API2_STATUS(EnableOrtCustomOps, _Inout_ OrtSessionOptions* options);
   3492 
   3493  /// @}
   3494  /// \name OrtAllocator
   3495  /// @{
   3496 
   3497  /** \brief Register a custom allocator
   3498   *
   3499   * Enables sharing between multiple sessions that use the same env instance.
   3500   * Returns an error if an allocator with the same ::OrtMemoryInfo is already
   3501   * registered.
   3502   *
   3503   * The behavior of this is exactly the same as
   3504   * OrtApi::CreateAndRegisterAllocator except instead of ORT creating an
   3505   * allocator based on provided info, in this case ORT uses the user-provided
   3506   * custom allocator. See https://onnxruntime.ai/docs/get-started/with-c.html
   3507   * for details.
   3508   *
   3509   * \param[in] env
   3510   * \param[in] allocator User provided allocator
   3511   *
   3512   * \snippet{doc} snippets.dox OrtStatus Return Value
   3513   */
   3514  ORT_API2_STATUS(RegisterAllocator, _Inout_ OrtEnv* env,
   3515                  _In_ OrtAllocator* allocator);
   3516 
   3517  /** \brief Unregister a custom allocator
   3518   *
   3519   * It is an error if you provide an ::OrtMemoryInfo not corresponding to any
   3520   * registered allocators for sharing.
   3521   *
   3522   * \param[in] env
   3523   * \param[in] mem_info
   3524   *
   3525   * \snippet{doc} snippets.dox OrtStatus Return Value
   3526   */
   3527  ORT_API2_STATUS(UnregisterAllocator, _Inout_ OrtEnv* env,
   3528                  _In_ const OrtMemoryInfo* mem_info);
   3529 
   3530  /// @}
   3531  /// \name OrtValue
   3532  /// @{
   3533 
   3534  /** \brief Sets *out to 1 iff an ::OrtValue is a SparseTensor, and 0 otherwise
   3535   *
   3536   * \param[in] value existing ::OrtValue
   3537   * \param[out] out unless an error occurs, contains 1 iff the value contains
   3538   * an instance of sparse tensor or 0 otherwise.
   3539   *
   3540   * \snippet{doc} snippets.dox OrtStatus Return Value
   3541   */
   3542  ORT_API2_STATUS(IsSparseTensor, _In_ const OrtValue* value, _Out_ int* out);
   3543 
   3544  /** \brief Create an ::OrtValue with a sparse tensor that is empty.
   3545   *
   3546   * Use FillSparseTensor<Format>() functions to populate sparse tensor with
   3547   * non-zero values and format specific indices data. Use ReleaseValue to
   3548   * destroy the sparse tensor, this will also release the buffer inside the
   3549   * output value if any was allocated.
   3550   * \param[in,out] allocator allocator to use when performing an allocation.
   3551   * Allocation will be performed by FillSparseTensor<Format>() APIs. The
   3552   * lifespan of the allocator instance must eclipse the lifespan this sparse
   3553   * tensor instance as the same allocator will be used to free memory.
   3554   * \param[in] dense_shape shape of the original dense tensor
   3555   * \param[in] dense_shape_len number of shape dimensions being passed
   3556   * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx
   3557   * \param[out] out Should be freed by calling ReleaseValue
   3558   *
   3559   * \snippet{doc} snippets.dox OrtStatus Return Value
   3560   */
   3561  ORT_API2_STATUS(CreateSparseTensorAsOrtValue, _Inout_ OrtAllocator* allocator,
   3562                  _In_ const int64_t* dense_shape, size_t dense_shape_len,
   3563                  ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
   3564 
   3565  /**
   3566   * This fills populates an empty tensor that was created using
   3567   * OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory
   3568   * and copy the supplied NNZ values and COO indices into that memory
   3569   * allocation. Memory allocation is performed using the allocator that was
   3570   * specified with OrtApi::CreateSparseTensorAsOrtValue.
   3571   *
   3572   * \param[in,out] ort_value ::OrtValue to populate with data
   3573   * \param[in] data_mem_info serves to identify the location of the data to be
   3574   * copied. If the allocator specified at the creation time has memory info
   3575   * that is not the same as mem_info argument to this function a X-device copy
   3576   * will be performed. String data is assumed to be on CPU and will only be
   3577   * copied into a CPU allocated buffer.
   3578   * \param[in] values_shape pointer to values shape array
   3579   * \param[in] values_shape_len length of the values_shape
   3580   * \param[in] values pointer to an array of values. For strings, pass const
   3581   * char**.
   3582   * \param[in] indices_data pointer to a location of COO indices
   3583   * \param[in] indices_num number of COO indices
   3584   *
   3585   * \snippet{doc} snippets.dox OrtStatus Return Value
   3586   */
   3587  ORT_API2_STATUS(FillSparseTensorCoo, _Inout_ OrtValue* ort_value,
   3588                  _In_ const OrtMemoryInfo* data_mem_info,
   3589                  _In_ const int64_t* values_shape, size_t values_shape_len,
   3590                  _In_ const void* values, _In_ const int64_t* indices_data,
   3591                  size_t indices_num);
   3592 
   3593  /**
   3594   * This fills populates an empty tensor that was created using
   3595   * OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory
   3596   * and copy the supplied NNZ values and CSR indices into that memory
   3597   * allocation. Memory allocation is performed using the allocator that was
   3598   * specified with OrtApi::CreateSparseTensorAsOrtValue.
   3599   *
   3600   * \param[in,out] ort_value ::OrtValue to populate with data
   3601   * \param[in] data_mem_info serves to identify the location of the data to be
   3602   * copied. If the allocator specified at the creation time has memory info
   3603   * that is not the same as mem_info argument to this function a X-device copy
   3604   * will be performed. String data is assumed to be on CPU and will only be
   3605   * copied into a CPU allocated buffer.
   3606   * \param[in] values_shape pointer to values shape array
   3607   * \param[in] values_shape_len length of the values_shape
   3608   * \param[in] values - pointer to an array of values. For strings, pass const
   3609   * char**.
   3610   * \param[in] inner_indices_data pointer to a location of CSR inner indices
   3611   * \param[in] inner_indices_num number of CSR inner indices
   3612   * \param[in] outer_indices_data pointer to a location of CSR outer indices
   3613   * \param[in] outer_indices_num number of CSR outer indices
   3614   *
   3615   * \snippet{doc} snippets.dox OrtStatus Return Value
   3616   */
   3617  ORT_API2_STATUS(FillSparseTensorCsr, _Inout_ OrtValue* ort_value,
   3618                  _In_ const OrtMemoryInfo* data_mem_info,
   3619                  _In_ const int64_t* values_shape, size_t values_shape_len,
   3620                  _In_ const void* values,
   3621                  _In_ const int64_t* inner_indices_data,
   3622                  size_t inner_indices_num,
   3623                  _In_ const int64_t* outer_indices_data,
   3624                  size_t outer_indices_num);
   3625 
   3626  /**
   3627   * This fills populates an empty tensor that was created using
   3628   * OrtApi::CreateSparseTensorAsOrtValue. This will allocate required memory
   3629   * and copy the supplied NNZ values and BlockSparse indices into that memory
   3630   * allocation. Memory allocation is performed using the allocator that was
   3631   * specified with OrtApi::CreateSparseTensorAsOrtValue.
   3632   *
   3633   * \param[in,out] ort_value ::OrtValue to populate with data
   3634   * \param[in] data_mem_info serves to identify the location of the data to be
   3635   * copied. If the allocator specified at the creation time has memory info
   3636   * that is not the same as mem_info argument to this function a X-device copy
   3637   * will be performed. String data is assumed to be on CPU and will only be
   3638   * copied into a CPU allocated buffer.
   3639   * \param[in] values_shape
   3640   * \param[in] values_shape_len
   3641   * \param[in] values structure with values information
   3642   * \param[in] indices_shape_data pointer to a location of indices shape
   3643   * \param[in] indices_shape_len length of the block sparse indices shape
   3644   * \param[in] indices_data pointer to a location of indices data. Shape will
   3645   * determine the length of the indices data.
   3646   *
   3647   * \snippet{doc} snippets.dox OrtStatus Return Value
   3648   */
   3649  ORT_API2_STATUS(FillSparseTensorBlockSparse, _Inout_ OrtValue* ort_value,
   3650                  _In_ const OrtMemoryInfo* data_mem_info,
   3651                  _In_ const int64_t* values_shape, size_t values_shape_len,
   3652                  _In_ const void* values,
   3653                  _In_ const int64_t* indices_shape_data,
   3654                  size_t indices_shape_len, _In_ const int32_t* indices_data);
   3655 
   3656  /**
   3657   * Create an ::OrtValue with a sparse tensor. This is the first step.
   3658   * Next, use Use<Format>Indices() functions to supply sparse tensor with
   3659   * format specific indices data and set its sparse format to a specific enum
   3660   * value. This will not perform memory allocations. It will use supplied user
   3661   * buffer which should outlive the created sparse tensor. Use
   3662   * OrtApi::ReleaseValue to destroy the sparse tensor. It would not release the
   3663   * supplied values buffer. This function can not be used to map strings from
   3664   * the user allocated memory. Strings must always be copied and have UTF-8
   3665   * encoding. Therefore, use OrtApi::CreateSparseTensorAsOrtValue above and
   3666   * then fill it with data using appropriate Make*() function.
   3667   *
   3668   * \param[in] info memory info where sparse values reside.
   3669   * \param[in,out] p_data pointer to a user allocated buffer with values. To
   3670   * create a full sparse tensor with no non-zero values, pass nullptr
   3671   * \param[in] dense_shape shape of the original dense tensor
   3672   * \param[in] dense_shape_len number of shape dimensions being passed
   3673   * \param[in] values_shape shape of the values data. To create a fully sparse
   3674   * tensor with no non-zero values, pass {0} shape.
   3675   * \param[in] values_shape_len number of values shape dimensions
   3676   * \param[in] type must be one of TENSOR_ELEMENT_DATA_TYPE_xxxx
   3677   * \param[out] out Should be freed by calling ReleaseValue
   3678   *
   3679   * \snippet{doc} snippets.dox OrtStatus Return Value
   3680   */
   3681  ORT_API2_STATUS(CreateSparseTensorWithValuesAsOrtValue,
   3682                  _In_ const OrtMemoryInfo* info, _Inout_ void* p_data,
   3683                  _In_ const int64_t* dense_shape, size_t dense_shape_len,
   3684                  _In_ const int64_t* values_shape, size_t values_shape_len,
   3685                  ONNXTensorElementDataType type, _Outptr_ OrtValue** out);
   3686 
   3687  /**
   3688   * This assigns Coo format indices to the SparseTensor that was created by
   3689   * OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets
   3690   * OrtSparseFormat to ORT_SPARSE_COO. This will not allocate any additional
   3691   * memory for data. The life span of indices_data buffer should eclipse the
   3692   * life span of this ::OrtValue.
   3693   *
   3694   * \param[in,out] ort_value ::OrtValue instance constructed with
   3695   * OrtApi::CreateSparseTensorWithValuesAsOrtValue
   3696   * \param[in,out] indices_data pointer to a user pre-allocated buffer or
   3697   * nullptr for fully sparse tensors.
   3698   * \param[in] indices_num  number of COO indices. Should either be 0 for fully
   3699   * sparse tensors, be equal to the number of nnz values specified to
   3700   * OrtApi::CreateSparseTensorWithValuesAsOrtValue for 1-D {nnz} indices or be
   3701   * twice as number of nnz values for a  2-D indices {nnz, 2}
   3702   *
   3703   * \snippet{doc} snippets.dox OrtStatus Return Value
   3704   */
   3705  ORT_API2_STATUS(UseCooIndices, _Inout_ OrtValue* ort_value,
   3706                  _Inout_ int64_t* indices_data, size_t indices_num);
   3707 
   3708  /**
   3709   * The assigns CSR format indices to the SparseTensor that was created by
   3710   * OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets
   3711   * OrtSparseFormat to ORT_SPARSE_CSRC. This will not allocate any additional
   3712   * memory for data. The life spans of inner_data and outer_data buffers should
   3713   * eclipse the life span of this ::OrtValue.
   3714   *
   3715   * \param[in,out] ort_value ::OrtValue instance constructed with
   3716   * OrtApi::CreateSparseTensorWithValuesAsOrtValue
   3717   * \param[in,out] inner_data pointer to a user pre-allocated buffer or nullptr
   3718   * for fully sparse tensors.
   3719   * \param[in] inner_num  number of inner CSR indices. Should either be 0 for
   3720   * fully sparse tensors or be equal to the number of nnz values specified to
   3721   * OrtApi::CreateSparseTensorWithValuesAsOrtValue.
   3722   * \param[in,out] outer_data pointer to user pre-allocated buffer or nullptr
   3723   * for fully sparse tensors.
   3724   * \param[in] outer_num number of CSR outer indices. Should either be 0 for
   3725   * fully sparse tensors or equal to rows + 1 of the dense shape.
   3726   *
   3727   * \snippet{doc} snippets.dox OrtStatus Return Value
   3728   */
   3729  ORT_API2_STATUS(UseCsrIndices, _Inout_ OrtValue* ort_value,
   3730                  _Inout_ int64_t* inner_data, size_t inner_num,
   3731                  _Inout_ int64_t* outer_data, size_t outer_num);
   3732 
   3733  /**
   3734   * The assigns BlockSparse format indices to the SparseTensor that was created
   3735   * by OrtApi::CreateSparseTensorWithValuesAsOrtValue above. It also sets
   3736   * OrtSparseFormat to ORT_SPARSE_BLOCK_SPARSE. This will not allocate any
   3737   * additional memory for data. The life span of indices_data buffer must
   3738   * eclipse the lifespan of this ::OrtValue.
   3739   *
   3740   * \param[in,out] ort_value OrtValue instance constructed with
   3741   * OrtApi::CreateSparseTensorWithValuesAsOrtValue
   3742   * \param[in] indices_shape pointer to indices shape. Use {0} for fully sparse
   3743   * tensors
   3744   * \param[in] indices_shape_len length of the indices shape
   3745   * \param[in,out] indices_data pointer to user pre-allocated buffer or nullptr
   3746   * for fully sparse tensors.
   3747   *
   3748   * \snippet{doc} snippets.dox OrtStatus Return Value
   3749   */
   3750  ORT_API2_STATUS(UseBlockSparseIndices, _Inout_ OrtValue* ort_value,
   3751                  const int64_t* indices_shape, size_t indices_shape_len,
   3752                  _Inout_ int32_t* indices_data);
   3753 
   3754  /** \brief Returns sparse tensor format enum iff a given ort value contains an
   3755   * instance of sparse tensor.
   3756   *
   3757   * \param[in] ort_value ::OrtValue that contains an instance of sparse tensor
   3758   * \param[out] out pointer to out parameter
   3759   *
   3760   * \snippet{doc} snippets.dox OrtStatus Return Value
   3761   */
   3762  ORT_API2_STATUS(GetSparseTensorFormat, _In_ const OrtValue* ort_value,
   3763                  _Out_ enum OrtSparseFormat* out);
   3764 
   3765  /** \brief Returns data type and shape of sparse tensor values (nnz) iff
   3766   * ::OrtValue contains a SparseTensor.
   3767   *
   3768   * \param[in] ort_value An ::OrtValue that contains a fully constructed sparse
   3769   * tensor
   3770   * \param[out] out Must be freed by OrtApi::ReleaseTensorTypeAndShapeInfo
   3771   *
   3772   * \snippet{doc} snippets.dox OrtStatus Return Value
   3773   */
   3774  ORT_API2_STATUS(GetSparseTensorValuesTypeAndShape,
   3775                  _In_ const OrtValue* ort_value,
   3776                  _Outptr_ OrtTensorTypeAndShapeInfo** out);
   3777 
   3778  /** \brief Returns numeric data for sparse tensor values (nnz). For string
   3779   * values use GetStringTensor*().
   3780   *
   3781   * \param[in] ort_value an instance of ::OrtValue containing sparse tensor
   3782   * \param[out] out returns a pointer to values data.  Do not attempt to free
   3783   * this ptr.
   3784   *
   3785   * \snippet{doc} snippets.dox OrtStatus Return Value
   3786   */
   3787  ORT_API2_STATUS(GetSparseTensorValues, _In_ const OrtValue* ort_value,
   3788                  _Outptr_ const void** out);
   3789 
   3790  /** \brief Returns data type, shape for the type of indices specified by
   3791   * indices_format.
   3792   *
   3793   * \param[in] ort_value ::OrtValue containing sparse tensor.
   3794   * \param[in] indices_format One of the indices formats. It is an error to
   3795   * request a format that the sparse tensor does not contain.
   3796   * \param[out] out an instance of ::OrtTensorTypeAndShapeInfo. Must be freed
   3797   * by OrtApi::ReleaseTensorTypeAndShapeInfo
   3798   *
   3799   * \snippet{doc} snippets.dox OrtStatus Return Value
   3800   */
   3801  ORT_API2_STATUS(GetSparseTensorIndicesTypeShape,
   3802                  _In_ const OrtValue* ort_value,
   3803                  enum OrtSparseIndicesFormat indices_format,
   3804                  _Outptr_ OrtTensorTypeAndShapeInfo** out);
   3805 
   3806  /** \brief Returns indices data for the type of the indices specified by
   3807   * indices_format
   3808   *
   3809   * \param[in] ort_value ::OrtValue containing sparse tensor.
   3810   * \param[in] indices_format One of the indices formats. It is an error to
   3811   * request a format that the sparse tensor does not contain.
   3812   * \param[out] num_indices Pointer to where the number of indices entries is
   3813   * returned
   3814   * \param[out] indices Returned pointer to the indices data. Do not free the
   3815   * returned pointer as it refers to internal data owned by the ::OrtValue
   3816   *
   3817   * \snippet{doc} snippets.dox OrtStatus Return Value
   3818   */
   3819  ORT_API2_STATUS(GetSparseTensorIndices, _In_ const OrtValue* ort_value,
   3820                  enum OrtSparseIndicesFormat indices_format,
   3821                  _Out_ size_t* num_indices, _Outptr_ const void** indices);
   3822  /// @}
   3823  /// \name OrtSessionOptions
   3824  /// @{
   3825 
   3826  /**
   3827   * \brief Sets out to 1 iff an optional type OrtValue has an element, 0
   3828   otherwise (OrtValue is None)
   3829   * Use this API to find if the optional type OrtValue is None or not.
   3830   * If the optional type OrtValue is not None, use the OrtValue just like any
   3831   other OrtValue.
   3832   * For example, if you get an OrtValue that corresponds to Optional(tensor)
   3833   and
   3834   * if HasValue() returns true, use it as tensor and so on.
   3835 
   3836   * \param[in] value Input OrtValue.
   3837   * \param[out] out indicating if the input OrtValue contains data (1) or if it
   3838   is a None (0)
   3839   *
   3840   * \snippet{doc} snippets.dox OrtStatus Return Value
   3841   */
   3842  ORT_API2_STATUS(HasValue, _In_ const OrtValue* value, _Out_ int* out);
   3843 
   3844  /// @}
   3845  /// \name OrtKernelContext
   3846  /// Custom operator APIs.
   3847  /// @{
   3848 
   3849  /** \brief Used for custom operators, gets the GPU compute stream to use to
   3850   * launch the custom a GPU kernel
   3851   *   \see ::OrtCustomOp
   3852   * \param[in]  context OrtKernelContext instance
   3853   * \param[out] out Returns pointer to a GPU compute stream that can be used to
   3854   * launch the custom GPU kernel. If retrieving the GPU compute stream is not
   3855   * relevant (GPU not enabled in the build, kernel partitioned to some other
   3856   * EP), then a nullptr is returned as the output param. Do not free or mutate
   3857   * the returned pointer as it refers to internal data owned by the underlying
   3858   * session. Only use it for custom kernel launching.
   3859   *
   3860   * \snippet{doc} snippets.dox OrtStatus Return Value
   3861   */
   3862  ORT_API2_STATUS(KernelContext_GetGPUComputeStream,
   3863                  _In_ const OrtKernelContext* context, _Outptr_ void** out);
   3864 
   3865  /// @}
   3866  /// \name GetTensorMemoryInfo
   3867  /// @{
   3868  /** \brief Returns a pointer to the ::OrtMemoryInfo of a Tensor
   3869   * \param[in] value ::OrtValue containing tensor.
   3870   * \param[out] mem_info ::OrtMemoryInfo of the tensor. Do NOT free the
   3871   * returned pointer. It is valid for the lifetime of the ::OrtValue
   3872   *
   3873   * \snippet{doc} snippets.dox OrtStatus Return Value
   3874   */
   3875  ORT_API2_STATUS(GetTensorMemoryInfo, _In_ const OrtValue* value,
   3876                  _Out_ const OrtMemoryInfo** mem_info);
   3877 
   3878  /// @}
   3879  /// \name GetExecutionProviderApi
   3880  /// @{
   3881  /** \brief Get a pointer to the requested version of the Execution Provider
   3882   * specific API extensions to the OrtApi
   3883   * \param[in] provider_name The name of the execution provider name. Currently
   3884   * only the following values are supported: "DML".
   3885   * \param[in] version Must be ::ORT_API_VERSION.
   3886   * \param[out] provider_api A void pointer containing a reference to the
   3887   * execution provider versioned api structure. For example, the provider_api
   3888   * pointer can be cast to the OrtDmlApi* when the provider_name is "DML".
   3889   *
   3890   * \snippet{doc} snippets.dox OrtStatus Return Value
   3891   */
   3892  ORT_API2_STATUS(GetExecutionProviderApi, _In_ const char* provider_name,
   3893                  _In_ uint32_t version, _Outptr_ const void** provider_api);
   3894 
   3895  /// @}
   3896 
   3897  /// \name SessionOptions
   3898  /// @{
   3899  /** \brief Set custom thread creation function
   3900   *
   3901   * \param[in] options Session options
   3902   * \param[in] ort_custom_create_thread_fn Custom thread creation function
   3903   *
   3904   * \snippet{doc} snippets.dox OrtStatus Return Value
   3905   */
   3906  ORT_API2_STATUS(SessionOptionsSetCustomCreateThreadFn,
   3907                  _Inout_ OrtSessionOptions* options,
   3908                  _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn);
   3909 
   3910  /** \brief Set creation options for custom thread
   3911   *
   3912   * \param[in] options Session options
   3913   * \param[in] ort_custom_thread_creation_options Custom thread creation
   3914   * options (can be nullptr)
   3915   *
   3916   * \snippet{doc} snippets.dox OrtStatus Return Value
   3917   */
   3918  ORT_API2_STATUS(SessionOptionsSetCustomThreadCreationOptions,
   3919                  _Inout_ OrtSessionOptions* options,
   3920                  _In_ void* ort_custom_thread_creation_options);
   3921 
   3922  /** \brief Set custom thread join function
   3923   *
   3924   * \param[in] options Session options
   3925   * \param[in] ort_custom_join_thread_fn Custom join thread function, must not
   3926   * be nullptr when ort_custom_create_thread_fn is set
   3927   *
   3928   * \snippet{doc} snippets.dox OrtStatus Return Value
   3929   */
   3930  ORT_API2_STATUS(SessionOptionsSetCustomJoinThreadFn,
   3931                  _Inout_ OrtSessionOptions* options,
   3932                  _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn);
   3933  /// @}
   3934 
   3935  /// \name OrtThreadingOptions
   3936  /// @{
   3937  /** \brief Set custom thread creation function for global thread pools
   3938   *
   3939   * \param[inout] tp_options
   3940   * \param[in] ort_custom_create_thread_fn Custom thread creation function
   3941   *
   3942   * \snippet{doc} snippets.dox OrtStatus Return Value
   3943   */
   3944  ORT_API2_STATUS(SetGlobalCustomCreateThreadFn,
   3945                  _Inout_ OrtThreadingOptions* tp_options,
   3946                  _In_ OrtCustomCreateThreadFn ort_custom_create_thread_fn);
   3947 
   3948  /** \brief Set custom thread creation options for global thread pools
   3949   *
   3950   * \param[inout] tp_options
   3951   * \param[in] ort_custom_thread_creation_options Custom thread creation
   3952   * options (can be nullptr)
   3953   *
   3954   * \snippet{doc} snippets.dox OrtStatus Return Value
   3955   */
   3956  ORT_API2_STATUS(SetGlobalCustomThreadCreationOptions,
   3957                  _Inout_ OrtThreadingOptions* tp_options,
   3958                  _In_ void* ort_custom_thread_creation_options);
   3959 
   3960  /** \brief Set custom thread join function for global thread pools
   3961   *
   3962   * \param[inout] tp_options
   3963   * \param[in] ort_custom_join_thread_fn Custom thread join function, must not
   3964   * be nullptr when global ort_custom_create_thread_fn is set
   3965   *
   3966   * \snippet{doc} snippets.dox OrtStatus Return Value
   3967   */
   3968  ORT_API2_STATUS(SetGlobalCustomJoinThreadFn,
   3969                  _Inout_ OrtThreadingOptions* tp_options,
   3970                  _In_ OrtCustomJoinThreadFn ort_custom_join_thread_fn);
   3971  /// @}
   3972 
   3973  /** \brief Synchronize bound inputs. The call may be necessary for some
   3974   * providers, such as cuda, in case the system that allocated bound memory
   3975   * operated on a different stream. However, the operation is provider specific
   3976   * and could be a no-op.
   3977   *
   3978   * \param[inout] binding_ptr
   3979   *
   3980   * \snippet{doc} snippets.dox OrtStatus Return Value
   3981   */
   3982  ORT_API2_STATUS(SynchronizeBoundInputs, _Inout_ OrtIoBinding* binding_ptr);
   3983 
   3984  /** \brief Synchronize bound outputs. The call may be necessary for some
   3985   * providers, such as cuda, in case the system that allocated bound memory
   3986   * operated on a different stream. However, the operation is provider specific
   3987   * and could be a no-op.
   3988   *
   3989   * \param[inout] binding_ptr
   3990   *
   3991   * \snippet{doc} snippets.dox OrtStatus Return Value
   3992   */
   3993  ORT_API2_STATUS(SynchronizeBoundOutputs, _Inout_ OrtIoBinding* binding_ptr);
   3994 
   3995  /// \name OrtSessionOptions
   3996  /// @{
   3997 
   3998  /** \brief Append CUDA execution provider to the session options
   3999   *
   4000   * If CUDA is not available (due to a non CUDA enabled build), this function
   4001   * will return failure.
   4002   *
   4003   * This is slightly different from
   4004   * OrtApi::SessionOptionsAppendExecutionProvider_CUDA, it takes an
   4005   * ::OrtCUDAProviderOptions which is publicly defined. This takes an opaque
   4006   * ::OrtCUDAProviderOptionsV2 which must be created with
   4007   * OrtApi::CreateCUDAProviderOptions.
   4008   *
   4009   * For OrtApi::SessionOptionsAppendExecutionProvider_CUDA, the user needs to
   4010   * instantiate ::OrtCUDAProviderOptions as well as allocate/release buffers
   4011   * for some members of ::OrtCUDAProviderOptions. Here,
   4012   * OrtApi::CreateCUDAProviderOptions and Ortapi::ReleaseCUDAProviderOptions
   4013   * will do the memory management for you.
   4014   *
   4015   * \param[in] options
   4016   * \param[in] cuda_options
   4017   *
   4018   * \snippet{doc} snippets.dox OrtStatus Return Value
   4019   *
   4020   * \since Version 1.11.
   4021   */
   4022  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CUDA_V2,
   4023                  _In_ OrtSessionOptions* options,
   4024                  _In_ const OrtCUDAProviderOptionsV2* cuda_options);
   4025 
   4026  /// @}
   4027  /// \name OrtCUDAProviderOptionsV2
   4028  /// @{
   4029 
   4030  /** \brief Create an OrtCUDAProviderOptionsV2
   4031   *
   4032   * \param[out] out Newly created ::OrtCUDAProviderOptionsV2. Must be released
   4033   * with OrtApi::ReleaseCudaProviderOptions
   4034   *
   4035   * \snippet{doc} snippets.dox OrtStatus Return Value
   4036   *
   4037   * \since Version 1.11.
   4038   */
   4039  ORT_API2_STATUS(CreateCUDAProviderOptions,
   4040                  _Outptr_ OrtCUDAProviderOptionsV2** out);
   4041 
   4042  /** \brief Set options in a CUDA Execution Provider.
   4043   *
   4044   * Please refer to
   4045   * https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#configuration-options
   4046   * to know the available keys and values. Key should be in null terminated
   4047   * string format of the member of ::OrtCUDAProviderOptionsV2 and value should
   4048   * be its related range. Recreates the options and only sets the supplied
   4049   * values.
   4050   *
   4051   * For example, key="device_id" and value="0"
   4052   *
   4053   * \param[in] cuda_options
   4054   * \param[in] provider_options_keys Array of UTF-8 null-terminated string for
   4055   * provider options keys
   4056   * \param[in] provider_options_values Array of UTF-8 null-terminated string
   4057   * for provider options values
   4058   * \param[in] num_keys Number of elements in the `provider_option_keys` and
   4059   * `provider_options_values` arrays
   4060   *
   4061   * \snippet{doc} snippets.dox OrtStatus Return Value
   4062   *
   4063   * \since Version 1.11.
   4064   */
   4065  ORT_API2_STATUS(UpdateCUDAProviderOptions,
   4066                  _Inout_ OrtCUDAProviderOptionsV2* cuda_options,
   4067                  _In_reads_(num_keys) const char* const* provider_options_keys,
   4068                  _In_reads_(num_keys)
   4069                      const char* const* provider_options_values,
   4070                  _In_ size_t num_keys);
   4071 
   4072  /**
   4073   * Get serialized CUDA provider options string.
   4074   *
   4075   * For example, "device_id=0;arena_extend_strategy=0;......"
   4076   *
   4077   * \param cuda_options - OrtCUDAProviderOptionsV2 instance
   4078   * \param allocator - a ptr to an instance of OrtAllocator obtained with
   4079   * CreateAllocator() or GetAllocatorWithDefaultOptions() the specified
   4080   * allocator will be used to allocate continuous buffers for output strings
   4081   * and lengths.
   4082   * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'.
   4083   * The caller is responsible for using the same allocator to free it.
   4084   *
   4085   * \snippet{doc} snippets.dox OrtStatus Return Value
   4086   *
   4087   * \since Version 1.11.
   4088   */
   4089  ORT_API2_STATUS(GetCUDAProviderOptionsAsString,
   4090                  _In_ const OrtCUDAProviderOptionsV2* cuda_options,
   4091                  _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
   4092 
   4093  /** \brief Release an ::OrtCUDAProviderOptionsV2
   4094   *
   4095   * \note This is an exception in the naming convention of other Release*
   4096   * functions, as the name of the method does not have the V2 suffix, but the
   4097   * type does
   4098   *
   4099   * \since Version 1.11.
   4100   */
   4101  void(ORT_API_CALL* ReleaseCUDAProviderOptions)(
   4102      _Frees_ptr_opt_ OrtCUDAProviderOptionsV2* input);
   4103 
   4104  /// @}
   4105 
   4106  /** \brief Append MIGraphX provider to session options
   4107   *
   4108   * If MIGraphX is not available (due to a non MIGraphX enabled build, or if
   4109   * MIGraphX is not installed on the system), this function will return
   4110   * failure.
   4111   *
   4112   * \param[in] options
   4113   * \param[in] migraphx_options
   4114   *
   4115   * \snippet{doc} snippets.dox OrtStatus Return Value
   4116   *
   4117   * \since Version 1.11.
   4118   */
   4119  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_MIGraphX,
   4120                  _In_ OrtSessionOptions* options,
   4121                  _In_ const OrtMIGraphXProviderOptions* migraphx_options);
   4122 
   4123  /** \brief Replace initialized Tensors with external data with the data
   4124   * provided in initializers.
   4125   *
   4126   * The function will find the initialized TensorProtos with external data in
   4127   * the graph with the provided names and replace them with the provided
   4128   * tensors. The API verifies that the TensorProto being replaced has an
   4129   * external data reference and has the same name, dimensions and data type as
   4130   * its replacement. The replacement will occur before any of the optimizations
   4131   * take place. The data will be copied into the graph since TensorProto can't
   4132   * refer to the user provided buffers.
   4133   *
   4134   * Once the model has been loaded, the OrtValue(s) added to SessionOptions
   4135   * instance will be removed from the internal SessionOptions copy to save
   4136   * memory, the user provided buffers can then be deallocated and the
   4137   * SessionOptions instance that refers to them can be destroyed.
   4138   *
   4139   * \param[in] options
   4140   * \param[in] initializer_names Array of null terminated UTF-8 encoded strings
   4141   * of the initializers names.
   4142   * \param[in] initializers Array of ::OrtValue type
   4143   * \param[in] num_initializers Number of elements in the initializer_names and
   4144   * initializers
   4145   *
   4146   * \snippet{doc} snippets.dox OrtStatus Return Value
   4147   *
   4148   * \since Version 1.12.
   4149   */
   4150  ORT_API2_STATUS(AddExternalInitializers, _In_ OrtSessionOptions* options,
   4151                  _In_reads_(num_initializers)
   4152                      const char* const* initializer_names,
   4153                  _In_reads_(num_initializers)
   4154                      const OrtValue* const* initializers,
   4155                  size_t num_initializers);
   4156 
   4157  /** \brief: Create attribute of onnxruntime operator
   4158   *
   4159   * \param[in] name Name of the attribute
   4160   * \param[in] data Data content of the attribute
   4161   * \param[in] len Number of bytes stored in data
   4162   * \param[in] type Data type
   4163   * \param[out] op_attr Attribute that has been created, which must be released
   4164   * by OrtApi::ReleaseOpAttr
   4165   *
   4166   * \since Version 1.12.
   4167   */
   4168  ORT_API2_STATUS(CreateOpAttr, _In_ const char* name, _In_ const void* data,
   4169                  _In_ int len, _In_ OrtOpAttrType type,
   4170                  _Outptr_ OrtOpAttr** op_attr);
   4171 
   4172  /* \brief: Release op attribute
   4173   *
   4174   * \param[in] opAttr Attribute created by OrtApi::CreateOpAttr
   4175   *
   4176   * \since Version 1.12.
   4177   */
   4178  ORT_CLASS_RELEASE(OpAttr);
   4179 
   4180  /** \brief: Create onnxruntime native operator
   4181   *
   4182   * \param[in] info Kernel info
   4183   * \param[in] op_name Operator name
   4184   * \param[in] domain Operator domain
   4185   * \param[in] version Operator opset version
   4186   * \param[in] type_constraint_names Name of the type contraints, such as "T"
   4187   * or "T1"
   4188   * \param[in] type_constraint_values Type of each contraints
   4189   * \param[in] type_constraint_count Number of contraints
   4190   * \param[in] attr_values Attributes used to initialize the operator
   4191   * \param[in] attr_count Number of the attributes
   4192   * \param[in] input_count Number of inputs
   4193   * \param[in] output_count Number of outputs
   4194   * \param[out] ort_op Operator that has been created
   4195   *
   4196   * \since Version 1.12.
   4197   */
   4198  ORT_API2_STATUS(CreateOp, _In_ const OrtKernelInfo* info,
   4199                  _In_z_ const char* op_name, _In_z_ const char* domain,
   4200                  int version,
   4201                  _In_reads_(type_constraint_count)
   4202                      const char** type_constraint_names,
   4203                  _In_reads_(type_constraint_count)
   4204                      const ONNXTensorElementDataType* type_constraint_values,
   4205                  int type_constraint_count,
   4206                  _In_reads_(attr_count) const OrtOpAttr* const* attr_values,
   4207                  int attr_count, int input_count, int output_count,
   4208                  _Outptr_ OrtOp** ort_op);
   4209 
   4210  /** \brief: Invoke the operator created by OrtApi::CreateOp
   4211   * The inputs must follow the order as specified in onnx specification
   4212   *
   4213   * \param[in] context Kernel context
   4214   * \param[in] ort_op Operator that has been created
   4215   * \param[in] input_values Array of inputs
   4216   * \param[in] input_count Number of inputs
   4217   * \param[in] output_values Array of outputs
   4218   * \param[in] output_count Number of outputs
   4219   *
   4220   * \since Version 1.12.
   4221   */
   4222  ORT_API2_STATUS(InvokeOp, _In_ const OrtKernelContext* context,
   4223                  _In_ const OrtOp* ort_op,
   4224                  _In_ const OrtValue* const* input_values,
   4225                  _In_ int input_count, _Inout_ OrtValue* const* output_values,
   4226                  _In_ int output_count);
   4227 
   4228  /* \brief: Release an onnxruntime operator
   4229   *
   4230   * \param[in] Op Operator created by OrtApi::CreateOp
   4231   *
   4232   * \since Version 1.12.
   4233   */
   4234  ORT_CLASS_RELEASE(Op);
   4235 
   4236  /** \brief: Append execution provider to the session options.
   4237   * \param[in] options
   4238   * \param[in] provider_name - provider to add.
   4239   * \param[in] provider_options_keys - keys to configure the provider options
   4240   * \param[in] provider_options_values - values to configure the provider
   4241   * options
   4242   * \param[in] num_keys - number of keys passed in
   4243   *
   4244   * Currently supported providers:
   4245   *   QNN
   4246   *   SNPE
   4247   *   XNNPACK
   4248   *
   4249   * Note: If an execution provider has a dedicated
   4250   * SessionOptionsAppendExecutionProvider_<provider name> function that should
   4251   * be used to add it.
   4252   *
   4253   * QNN supported keys:
   4254   *   "backend_path": file path to QNN backend library.
   4255   *   "profiling_level": QNN profiling level, options: "off", "basic",
   4256   * "detailed". Default to off. "profiling_file_path": QNN profiling file path
   4257   * if ETW not enabled. "rpc_control_latency": QNN RPC control latency.
   4258   *   "vtcm_mb": QNN VTCM size in MB. default to 0(not set).
   4259   *   "htp_performance_mode": QNN performance mode, options: "burst",
   4260   * "balanced", "default", "high_performance", "high_power_saver",
   4261   * "low_balanced", "extreme_power_saver", "low_power_saver", "power_saver",
   4262   * "sustained_high_performance". Default to "default". "qnn_saver_path": File
   4263   * path to the QNN Saver backend library. If specified, QNN Saver will be
   4264   * enabled and will dump QNN API calls to disk for replay/debugging. QNN Saver
   4265   * produces incorrect model inference results and may alter model/EP
   4266   * partitioning. Use only for debugging. "qnn_context_priority": QNN context
   4267   * priority, options: "low", "normal", "normal_high", "high". Default to
   4268   * "normal". "htp_graph_finalization_optimization_mode": Set the optimization
   4269   * mode for graph finalization on the HTP backend. Available options:
   4270   *     - "0": Default.
   4271   *     - "1": Faster preparation time, less optimal graph.
   4272   *     - "2": Longer preparation time, more optimal graph.
   4273   *     - "3": Longest preparation time, most likely even more optimal graph.
   4274   * See QNN SDK documentation for specific details. "soc_model": The SoC model
   4275   * number. Refer to the QNN SDK documentation for valid values. Defaults to
   4276   * "0" (unknown). "htp_arch": The minimum HTP architecture the driver will use
   4277   * to select compatible QNN operators. Available options:
   4278   *     - "0": Default (none).
   4279   *     - "68"
   4280   *     - "69"
   4281   *     - "73"
   4282   *     - "75"
   4283   *   "device_id": The ID of the device to use when setting 'htp_arch'.
   4284   * Defaults to "0" (for single device). "enable_htp_fp16_precision": Used for
   4285   * float32 model for HTP backend. Enable the float32 model to be inferenced
   4286   * with fp16 precision. Otherwise, it will be fp32 precision.
   4287   *     - "0": With fp32 precision.
   4288   *     - "1": Default. With fp16 precision.
   4289   *   "offload_graph_io_quantization": Offload graph input quantization and
   4290   * graph output dequantization to another execution provider (typically CPU
   4291   * EP).
   4292   *     - "0": Disabled. QNN EP will handle quantization and dequantization of
   4293   * graph I/O.
   4294   *     - "1": Enabled. This is the default value.
   4295   *   "enable_htp_spill_fill_buffer": Enable HTP spill fill buffer setting. The
   4296   * flag is used while generating context binary.
   4297   *     - "0": Default. Disabled.
   4298   *     - "1": Enabled.
   4299   *   "enable_htp_shared_memory_allocator": Enable the QNN HTP shared memory
   4300   * allocator. Requires libcdsprpc.so/dll to be available.
   4301   *     - "0": Default. Disabled.
   4302   *     - "1": Enabled.
   4303   *   "dump_json_qnn_graph": Set to "1" to dump QNN graphs generated by QNN EP
   4304   * as JSON files. Each graph partition assigned to QNN EP is dumped to a
   4305   * separate file. "json_qnn_graph_dir": Directory in which to dump QNN JSON
   4306   * graphs. If not specified, QNN graphs are dumped in the program's current
   4307   * working directory. Ignored if "dump_json_qnn_graph" is not set.
   4308   *
   4309   * SNPE supported keys:
   4310   *   "runtime": SNPE runtime engine, options: "CPU", "CPU_FLOAT32", "GPU",
   4311   * "GPU_FLOAT32_16_HYBRID", "GPU_FLOAT16", "DSP", "DSP_FIXED8_TF",
   4312   * "AIP_FIXED_TF", "AIP_FIXED8_TF". Mapping to SNPE Runtime_t definition: CPU,
   4313   * CPU_FLOAT32 => zdl::DlSystem::Runtime_t::CPU; GPU, GPU_FLOAT32_16_HYBRID =>
   4314   * zdl::DlSystem::Runtime_t::GPU; GPU_FLOAT16 =>
   4315   * zdl::DlSystem::Runtime_t::GPU_FLOAT16; DSP, DSP_FIXED8_TF =>
   4316   * zdl::DlSystem::Runtime_t::DSP. AIP_FIXED_TF, AIP_FIXED8_TF =>
   4317   * zdl::DlSystem::Runtime_t::AIP_FIXED_TF. "priority": execution priority,
   4318   * options: "low", "normal". "buffer_type": ITensor or user buffers, options:
   4319   * "ITENSOR", user buffer with different types - "TF8", "TF16", "UINT8",
   4320   * "FLOAT". "ITENSOR" -- default, ITensor which is float only. "TF8" --
   4321   * quantized model required, "FLOAT" -- for both quantized or non-quantized
   4322   * model "enable_init_cache": enable SNPE init caching feature, set to 1 to
   4323   * enabled it. Disabled by default. If SNPE is not available (due to a non
   4324   * Snpe enabled build or its dependencies not being installed), this function
   4325   * will fail.
   4326   *
   4327   * XNNPACK supported keys:
   4328   *   "intra_op_num_threads": number of thread-pool size to use for XNNPACK
   4329   * execution provider. default value is 0, which means to use the session
   4330   * thread-pool size.
   4331   *
   4332   * \since Version 1.12.
   4333   */
   4334  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider,
   4335                  _In_ OrtSessionOptions* options,
   4336                  _In_ const char* provider_name,
   4337                  _In_reads_(num_keys) const char* const* provider_options_keys,
   4338                  _In_reads_(num_keys)
   4339                      const char* const* provider_options_values,
   4340                  _In_ size_t num_keys);
   4341 
   4342  /* \brief: Get a copy of kernel info
   4343   *
   4344   * \param[in] info Kernel info
   4345   * \param[out] info_copy Copy of kernel info
   4346   *
   4347   * \since Version 1.12.
   4348   */
   4349  ORT_API2_STATUS(CopyKernelInfo, _In_ const OrtKernelInfo* info,
   4350                  _Outptr_ OrtKernelInfo** info_copy);
   4351 
   4352  /* \brief: Release kernel info
   4353   *
   4354   * \param[in] KernelInfo A copy of kernel info returned by CopyKernelInfo
   4355   *
   4356   * \since Version 1.12.
   4357   */
   4358  ORT_CLASS_RELEASE(KernelInfo);
   4359 
   4360  /// \name Ort Training
   4361  /// @{
   4362  /** \brief Gets the Training C Api struct
   4363   *
   4364   * Call this function to access the ::OrtTrainingApi structure that holds
   4365   * pointers to functions that enable training with onnxruntime.
   4366   * \note A NULL pointer will be returned and no error message will be printed
   4367   * if the training api is not supported with this build. A NULL pointer will
   4368   * be returned and an error message will be printed if the provided version is
   4369   * unsupported, for example when using a runtime older than the version
   4370   * created with this header file.
   4371   *
   4372   * \param[in] version Must be ::ORT_API_VERSION
   4373   * \return The ::OrtTrainingApi struct for the version requested.
   4374   *
   4375   * \since Version 1.13
   4376   */
   4377  const OrtTrainingApi*(ORT_API_CALL* GetTrainingApi)(uint32_t version)
   4378      NO_EXCEPTION;
   4379 
   4380  /// @}
   4381 
   4382  /** \brief Append CANN provider to session options
   4383   *
   4384   * If CANN is not available (due to a non CANN enabled build, or if CANN is
   4385   * not installed on the system), this function will return failure.
   4386   *
   4387   * \param[in] options
   4388   * \param[in] cann_options
   4389   *
   4390   * \snippet{doc} snippets.dox OrtStatus Return Value
   4391   *
   4392   * \since Version 1.13.
   4393   */
   4394  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_CANN,
   4395                  _In_ OrtSessionOptions* options,
   4396                  _In_ const OrtCANNProviderOptions* cann_options);
   4397 
   4398  /** \brief Create an OrtCANNProviderOptions
   4399   *
   4400   * \param[out] out created ::OrtCANNProviderOptions. Must be released with
   4401   * OrtApi::ReleaseCANNProviderOptions
   4402   *
   4403   * \snippet{doc} snippets.dox OrtStatus Return Value
   4404   *
   4405   * \since Version 1.13.
   4406   */
   4407  ORT_API2_STATUS(CreateCANNProviderOptions,
   4408                  _Outptr_ OrtCANNProviderOptions** out);
   4409 
   4410  /** \brief Set options in a CANN Execution Provider.
   4411   *
   4412   * \param[in] cann_options
   4413   * \param[in] provider_options_keys Array of UTF-8 null-terminated string for
   4414   * provider options keys
   4415   * \param[in] provider_options_values Array of UTF-8 null-terminated string
   4416   * for provider options values
   4417   * \param[in] num_keys Number of elements in the `provider_option_keys` and
   4418   * `provider_options_values` arrays
   4419   *
   4420   * \snippet{doc} snippets.dox OrtStatus Return Value
   4421   *
   4422   * \since Version 1.13.
   4423   */
   4424  ORT_API2_STATUS(UpdateCANNProviderOptions,
   4425                  _Inout_ OrtCANNProviderOptions* cann_options,
   4426                  _In_reads_(num_keys) const char* const* provider_options_keys,
   4427                  _In_reads_(num_keys)
   4428                      const char* const* provider_options_values,
   4429                  _In_ size_t num_keys);
   4430 
   4431  /** \brief Get serialized CANN provider options string.
   4432   *
   4433   * \param[in] cann_options OrtCANNProviderOptions instance
   4434   * \param[in] allocator a ptr to an instance of OrtAllocator obtained with
   4435   * CreateAllocator() or GetAllocatorWithDefaultOptions(), the specified
   4436   * allocator will be used to allocate continuous buffers for output strings
   4437   * and lengths.
   4438   * \param[out] ptr is a UTF-8 null terminated string allocated using
   4439   * 'allocator'. The caller is responsible for using the same allocator to free
   4440   * it.
   4441   *
   4442   * \snippet{doc} snippets.dox OrtStatus Return Value
   4443   *
   4444   * \since Version 1.13.
   4445   */
   4446  ORT_API2_STATUS(GetCANNProviderOptionsAsString,
   4447                  _In_ const OrtCANNProviderOptions* cann_options,
   4448                  _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
   4449 
   4450  /** \brief Release an OrtCANNProviderOptions
   4451   *
   4452   * \param[in] input The pointer of OrtCANNProviderOptions which will been
   4453   * deleted
   4454   *
   4455   * \since Version 1.13.
   4456   */
   4457  void(ORT_API_CALL* ReleaseCANNProviderOptions)(
   4458      _Frees_ptr_opt_ OrtCANNProviderOptions* input);
   4459 
   4460  /*  \brief Get OrtDevice type from MemoryInfo
   4461   *
   4462   *  \since Version 1.14
   4463   */
   4464  void(ORT_API_CALL* MemoryInfoGetDeviceType)(
   4465      _In_ const OrtMemoryInfo* ptr, _Out_ OrtMemoryInfoDeviceType* out);
   4466 
   4467  /* \brief Update the OrtEnv instance with custom log severity level
   4468   *
   4469   * \param[in] ort_env The OrtEnv instance being used
   4470   * \param[in] log_severity_level The log severity level.
   4471   *
   4472   * \since Version 1.14.
   4473   */
   4474  ORT_API2_STATUS(UpdateEnvWithCustomLogLevel, _In_ OrtEnv* ort_env,
   4475                  OrtLoggingLevel log_severity_level);
   4476 
   4477  /*  \brief Set affinities for intra op threads
   4478   *
   4479   * Affinity string follows format:
   4480   * logical_processor_id,logical_processor_id;logical_processor_id,logical_processor_id
   4481   * Semicolon isolates configurations among threads, while comma split
   4482   * processors where ith thread expected to attach to. e.g. 1,2,3;4,5 specifies
   4483   * affinities for two threads, with the 1st thread attach to the 1st, 2nd, and
   4484   * 3rd processor, and 2nd thread to the 4th and 5th. To ease the
   4485   * configuration, an "interval" is also allowed: e.g. 1-8;8-16;17-24 orders
   4486   * that the 1st thread runs on first eight processors, 2nd thread runs on next
   4487   * eight processors, and so forth. Note:
   4488   * 1. Once set, the number of thread affinities must equal to
   4489   * intra_op_num_threads - 1, ort does not set affinity on the main thread
   4490   * which is started and managed by the calling app;
   4491   * 2. For windows, ort will infer the group id from a logical processor id,
   4492   * for example, assuming there are two groups with each has 64 logical
   4493   * processors, an id of 64 will be inferred as the last processor of the 1st
   4494   * group, while 65 will be interpreted as the 1st processor of the second
   4495   * group. Hence 64-65 is an invalid configuration, because a windows thread
   4496   * cannot be attached to processors across group boundary.
   4497   *
   4498   *  \since Version 1.14
   4499   */
   4500  ORT_API2_STATUS(SetGlobalIntraOpThreadAffinity,
   4501                  _Inout_ OrtThreadingOptions* tp_options,
   4502                  const char* affinity_string);
   4503 
   4504  /** \brief Register custom ops from a shared library.
   4505   *
   4506   * Loads a shared library (.dll on windows, .so on linux, etc) named
   4507   *'library_name' and looks for this entry point: OrtStatus*
   4508   *RegisterCustomOps(OrtSessionOptions * options, const OrtApiBase* api); It
   4509   *then passes in the provided session options to this function along with the
   4510   *api base.
   4511   *
   4512   * The handle to the loaded library is automatically released by ORT when the
   4513   *last OrtSession that references the library handle is released. If no
   4514   *OrtSession is created, then the library handle is released when the provided
   4515   * OrtSessionOptions is released.
   4516   *
   4517   * \param[in] options The session options.
   4518   * \param[in] library_name The name of the shared library to load and
   4519   *register. Refer to OS-specific dynamic library loading utilities (e.g.,
   4520   *LoadLibraryEx on Windows or dlopen on Linux/MacOS) for information on the
   4521   *format of library names and search paths.
   4522   *
   4523   * \snippet{doc} snippets.dox OrtStatus Return Value
   4524   * \since Version 1.14
   4525   */
   4526  ORT_API2_STATUS(RegisterCustomOpsLibrary_V2,
   4527                  _Inout_ OrtSessionOptions* options,
   4528                  _In_ const ORTCHAR_T* library_name);
   4529 
   4530  /** \brief Register custom ops by calling a RegisterCustomOpsFn function.
   4531   *
   4532   * Searches for registration_func_name and if found calls it.
   4533   *
   4534   * The library containing the function must either be linked against or
   4535   * previously loaded by the executable.
   4536   *
   4537   * If you want ONNX Runtime to load the library and manage its lifetime, use
   4538   * RegisterCustomOpsLibrary_V2.
   4539   *
   4540   * RegisterCustomOpsUsingFunction can be used in scenarios where it may not be
   4541   * possible for ONNX Runtime to load the library from a path. e.g. mobile
   4542   * platforms where the library must be linked into the app.
   4543   *
   4544   * The registration function must have the signature of RegisterCustomOpsFn:
   4545   *    OrtStatus* (*fn)(OrtSessionOptions* options, const OrtApiBase* api);
   4546   *
   4547   * See https://onnxruntime.ai/docs/reference/operators/add-custom-op.html for
   4548   * details on how the registration function should be implemented.
   4549   *
   4550   * \param[in] options OrtSessionOptions that is passed through as the first
   4551   * argument in the call to the registration function.
   4552   * \param[in] registration_func_name Name of registration function to use.
   4553   *
   4554   * \snippet{doc} snippets.dox OrtStatus Return Value
   4555   * \since Version 1.14
   4556   */
   4557  ORT_API2_STATUS(RegisterCustomOpsUsingFunction,
   4558                  _Inout_ OrtSessionOptions* options,
   4559                  _In_ const char* registration_func_name);
   4560 
   4561  /// \name OrtKernelInfo
   4562  /// Custom operator APIs.
   4563  /// @{
   4564 
   4565  /** \brief Get the number of inputs from ::OrtKernelInfo.
   4566   *
   4567   * Used in the CreateKernel callback of an OrtCustomOp to query the number of
   4568   * inputs during kernel/session creation.
   4569   *
   4570   * \param[in] info Instance of ::OrtKernelInfo.
   4571   * \param[out] out Pointer to variable assigned with the result on success.
   4572   *
   4573   * \snippet{doc} snippets.dox OrtStatus Return Value
   4574   * \since Version 1.14
   4575   */
   4576  ORT_API2_STATUS(KernelInfo_GetInputCount, _In_ const OrtKernelInfo* info,
   4577                  _Out_ size_t* out);
   4578 
   4579  /** \brief Get the number of outputs from ::OrtKernelInfo.
   4580   *
   4581   * Used in the CreateKernel callback of an OrtCustomOp to query the number of
   4582   * outputs during kernel/session creation.
   4583   *
   4584   * \param[in] info Instance of ::OrtKernelInfo.
   4585   * \param[out] out Pointer to variable assigned with the result on success.
   4586   *
   4587   * \snippet{doc} snippets.dox OrtStatus Return Value
   4588   * \since Version 1.14
   4589   */
   4590  ORT_API2_STATUS(KernelInfo_GetOutputCount, _In_ const OrtKernelInfo* info,
   4591                  _Out_ size_t* out);
   4592 
   4593  /** \brief Get the name of a ::OrtKernelInfo's input.
   4594   *
   4595   * Used in the CreateKernel callback of an OrtCustomOp to query an input's
   4596   * name during kernel/session creation.
   4597   *
   4598   * If `out` is nullptr, the value of `size` is set to the size of the name
   4599   * string (including null-terminator), and a success status is returned.
   4600   *
   4601   * If the `size` parameter is greater than or equal to the name string's size,
   4602   * the value of `size` is set to the true size of the string (including
   4603   * null-terminator), the provided memory is filled with the string's contents,
   4604   * and a success status is returned.
   4605   *
   4606   * If the `size` parameter is less than the actual string's size and `out`
   4607   * is not nullptr, the value of `size` is set to the true size of the string
   4608   * and a failure status is returned.
   4609   *
   4610   * \param[in] info An instance of ::OrtKernelInfo.
   4611   * \param[in] index The index of the input name to get. Returns a failure
   4612   * status if out-of-bounds.
   4613   * \param[out] out Memory location into which to write the UTF-8
   4614   * null-terminated string representing the input's name.
   4615   * \param[in,out] size Pointer to the size of the `out` buffer. See above
   4616   * comments for details.
   4617   *
   4618   * \snippet{doc} snippets.dox OrtStatus Return Value
   4619   * \since Version 1.14
   4620   */
   4621  ORT_API2_STATUS(KernelInfo_GetInputName, _In_ const OrtKernelInfo* info,
   4622                  size_t index, _Out_ char* out, _Inout_ size_t* size);
   4623 
   4624  /** \brief Get the name of a ::OrtKernelInfo's output.
   4625   *
   4626   * Used in the CreateKernel callback of an OrtCustomOp to query an output's
   4627   * name during kernel/session creation.
   4628   *
   4629   * If `out` is nullptr, the value of `size` is set to the size of the name
   4630   * string (including null-terminator), and a success status is returned.
   4631   *
   4632   * If the `size` parameter is greater than or equal to the name string's size,
   4633   * the value of `size` is set to the true size of the string (including
   4634   * null-terminator), the provided memory is filled with the string's contents,
   4635   * and a success status is returned.
   4636   *
   4637   * If the `size` parameter is less than the actual string's size and `out`
   4638   * is not nullptr, the value of `size` is set to the true size of the string
   4639   * and a failure status is returned.
   4640   *
   4641   * \param[in] info An instance of ::OrtKernelInfo.
   4642   * \param[in] index The index of the output name to get. Returns a failure
   4643   * status if out-of-bounds.
   4644   * \param[out] out Memory location into which to write the UTF-8
   4645   * null-terminated string representing the output's name.
   4646   * \param[in,out] size Pointer to the size of the `out` buffer. See above
   4647   * comments for details.
   4648   *
   4649   * \snippet{doc} snippets.dox OrtStatus Return Value
   4650   * \since Version 1.14
   4651   */
   4652  ORT_API2_STATUS(KernelInfo_GetOutputName, _In_ const OrtKernelInfo* info,
   4653                  size_t index, _Out_ char* out, _Inout_ size_t* size);
   4654 
   4655  /** \brief Get the type information for a ::OrtKernelInfo's input.
   4656   *
   4657   * Used in the CreateKernel callback of an OrtCustomOp to query the shape and
   4658   * type information of an input during kernel/session creation.
   4659   *
   4660   * \param[in] info An instance of ::OrtKernelInfo.
   4661   * \param[in] index Which input to get the type information for
   4662   * \param[out] type_info Pointer set to the resulting ::OrtTypeInfo. Must be
   4663   * freed with OrtApi::ReleaseTypeInfo.
   4664   *
   4665   * \snippet{doc} snippets.dox OrtStatus Return Value
   4666   * \since Version 1.14
   4667   */
   4668  ORT_API2_STATUS(KernelInfo_GetInputTypeInfo, _In_ const OrtKernelInfo* info,
   4669                  size_t index, _Outptr_ OrtTypeInfo** type_info);
   4670 
   4671  /** \brief Get the type information for a ::OrtKernelInfo's output.
   4672   *
   4673   * Used in the CreateKernel callback of an OrtCustomOp to query the shape and
   4674   * type information of an output during kernel/session creation.
   4675   *
   4676   * \param[in] info An instance of ::OrtKernelInfo.
   4677   * \param[in] index Which input to get the type information for
   4678   * \param[out] type_info Pointer set to the resulting ::OrtTypeInfo. Must be
   4679   * freed with OrtApi::ReleaseTypeInfo.
   4680   *
   4681   * \snippet{doc} snippets.dox OrtStatus Return Value
   4682   * \since Version 1.14
   4683   */
   4684  ORT_API2_STATUS(KernelInfo_GetOutputTypeInfo, _In_ const OrtKernelInfo* info,
   4685                  size_t index, _Outptr_ OrtTypeInfo** type_info);
   4686 
   4687  /** \brief Get a ::OrtValue tensor stored as an attribute in the graph node.
   4688   *
   4689   * Used in the CreateKernel callback of an OrtCustomOp to get a tensor
   4690   * attribute.
   4691   *
   4692   * \param[in] info ::OrtKernelInfo instance.
   4693   * \param[in] name UTF-8 null-terminated string representing the attribute's
   4694   * name.
   4695   * \param[in] allocator Allocator used to allocate the internal tensor state.
   4696   * \param[out] out Returns newly created ::OrtValue. Must be freed with
   4697   * OrtApi::ReleaseValue, which will also free internal tensor state allocated
   4698   * with the provided allocator.
   4699   *
   4700   * \snippet{doc} snippets.dox OrtStatus Return Value
   4701   */
   4702  ORT_API2_STATUS(KernelInfoGetAttribute_tensor, _In_ const OrtKernelInfo* info,
   4703                  _In_z_ const char* name, _Inout_ OrtAllocator* allocator,
   4704                  _Outptr_ OrtValue** out);
   4705 
   4706  /// @}
   4707  /// \name OrtSessionOptions
   4708  /// Custom operator APIs
   4709  /// @{
   4710 
   4711  /** \brief Checks if the given session configuration entry exists.
   4712   *
   4713   * The config_key formats are defined in
   4714   * onnxruntime_session_options_config_keys.h
   4715   *
   4716   * Can be used in a custom operator library to check for session configuration
   4717   * entries that target one or more custom operators in the library. Example:
   4718   * The config entry custom_op.myop.some_key targets a custom op named "myop".
   4719   *
   4720   * \param[in] options The ::OrtSessionOptions instance.
   4721   * \param[in] config_key A null-terminated UTF-8 string representation of the
   4722   * configuration key.
   4723   * \param[out] out Pointer set to 1 if the entry exists and 0 otherwise.
   4724   *
   4725   * \snippet{doc} snippets.dox OrtStatus Return Value
   4726   * \since Version 1.14
   4727   */
   4728  ORT_API2_STATUS(HasSessionConfigEntry, _In_ const OrtSessionOptions* options,
   4729                  _In_z_ const char* config_key, _Out_ int* out);
   4730 
   4731  /** \brief Get a session configuration value.
   4732   *
   4733   * Returns a failure status if the configuration key does not exist.
   4734   * The config_key and the format of config_value are defined in
   4735   * onnxruntime_session_options_config_keys.h
   4736   *
   4737   * If `config_value` is nullptr, the value of `size` is set to the true size
   4738   * of the string value (including null-terminator), and a success status is
   4739   * returned.
   4740   *
   4741   * If the `size` parameter is greater than or equal to the actual string
   4742   * value's size, the value of `size` is set to the true size of the string
   4743   * value, the provided memory is filled with the value's contents, and a
   4744   * success status is returned.
   4745   *
   4746   * If the `size` parameter is less than the actual string value's size and
   4747   * `config_value` is not nullptr, the value of `size` is set to the true size
   4748   * of the string value and a failure status is returned.
   4749   *
   4750   * Can be used in a custom operator library to get session configuration
   4751   * entries that target one or more custom operators in the library. Example:
   4752   * The config entry custom_op.myop.some_key targets a custom op named "myop".
   4753   *
   4754   * \param[in] options The session options.
   4755   * \param[in] config_key A null-terminated UTF-8 string representation of the
   4756   * config key.
   4757   * \param[in] config_value Pointer to memory where the null-terminated UTF-8
   4758   * string value will be stored.
   4759   * \param[in,out] size Pointer to the size of the `config_value` buffer. See
   4760   * above comments for details.
   4761   *
   4762   * \snippet{doc} snippets.dox OrtStatus Return Value
   4763   * \since Version 1.14
   4764   */
   4765  ORT_API2_STATUS(GetSessionConfigEntry, _In_ const OrtSessionOptions* options,
   4766                  _In_z_ const char* config_key, _Out_ char* config_value,
   4767                  _Inout_ size_t* size);
   4768 
   4769  /// @}
   4770 
   4771  /** \brief Append dnnl provider to session options
   4772   *
   4773   * If oneDNN is not available, this function will return failure.
   4774   *
   4775   * \param[in] options
   4776   * \param[in] dnnl_options
   4777   *
   4778   * \snippet{doc} snippets.dox OrtStatus Return Value
   4779   *
   4780   * \since Version 1.15.
   4781   */
   4782  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_Dnnl,
   4783                  _In_ OrtSessionOptions* options,
   4784                  _In_ const OrtDnnlProviderOptions* dnnl_options);
   4785 
   4786  /** \brief Create an OrtDnnlProviderOptions
   4787   *
   4788   * \param[out] out Newly created ::OrtDnnlProviderOptions. Must be released
   4789   * with OrtApi::ReleaseDnnlProviderOptions
   4790   *
   4791   * \snippet{doc} snippets.dox OrtStatus Return Value
   4792   *
   4793   * \since Version 1.15.
   4794   */
   4795  ORT_API2_STATUS(CreateDnnlProviderOptions,
   4796                  _Outptr_ OrtDnnlProviderOptions** out);
   4797 
   4798  /** \brief Set options in a oneDNN Execution Provider.
   4799   *
   4800   * Key should be in null terminated string format of the member of
   4801   * ::OrtDnnlProviderOptions and value should be its related range.
   4802   *
   4803   * For example, key="use_arena" and value="1"
   4804   *
   4805   * \param[in] dnnl_options
   4806   * \param[in] provider_options_keys Array of UTF-8 null-terminated string for
   4807   * provider options keys
   4808   * \param[in] provider_options_values Array of UTF-8 null-terminated string
   4809   * for provider options values
   4810   * \param[in] num_keys Number of elements in the `provider_option_keys` and
   4811   * `provider_options_values` arrays
   4812   *
   4813   * \snippet{doc} snippets.dox OrtStatus Return Value
   4814   *
   4815   * \since Version 1.15.
   4816   */
   4817  ORT_API2_STATUS(UpdateDnnlProviderOptions,
   4818                  _Inout_ OrtDnnlProviderOptions* dnnl_options,
   4819                  _In_reads_(num_keys) const char* const* provider_options_keys,
   4820                  _In_reads_(num_keys)
   4821                      const char* const* provider_options_values,
   4822                  _In_ size_t num_keys);
   4823 
   4824  /**
   4825   * Get serialized oneDNN provider options string.
   4826   *
   4827   * For example, "use_arena=1;......"
   4828   *
   4829   * \param dnnl_options - OrtDnnlProviderOptions instance
   4830   * \param allocator - a ptr to an instance of OrtAllocator obtained with
   4831   * CreateAllocator() or GetAllocatorWithDefaultOptions() the specified
   4832   * allocator will be used to allocate continuous buffers for output strings
   4833   * and lengths.
   4834   * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'.
   4835   * The caller is responsible for using the same allocator to free it.
   4836   *
   4837   * \snippet{doc} snippets.dox OrtStatus Return Value
   4838   *
   4839   * \since Version 1.15.
   4840   */
   4841  ORT_API2_STATUS(GetDnnlProviderOptionsAsString,
   4842                  _In_ const OrtDnnlProviderOptions* dnnl_options,
   4843                  _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
   4844 
   4845  /** \brief Release an ::OrtDnnlProviderOptions
   4846   *
   4847   * \since Version 1.15.
   4848   */
   4849  void(ORT_API_CALL* ReleaseDnnlProviderOptions)(
   4850      _Frees_ptr_opt_ OrtDnnlProviderOptions* input);
   4851 
   4852  /// \name OrtKernelInfo
   4853  /// Custom operator APIs.
   4854  /// @{
   4855 
   4856  /** \brief Get the graph node name from ::OrtKernelInfo.
   4857   *
   4858   * If `out` is nullptr, the value of `size` is set to the size of the name
   4859   * string (including null-terminator), and a success status is returned.
   4860   *
   4861   * If the `size` parameter is greater than or equal to the name string's size,
   4862   * the value of `size` is set to the true size of the string (including
   4863   * null-terminator), the provided memory is filled with the string's contents,
   4864   * and a success status is returned.
   4865   *
   4866   * If the `size` parameter is less than the actual string's size and `out`
   4867   * is not nullptr, the value of `size` is set to the true size of the string
   4868   * and a failure status is returned.
   4869   *
   4870   * Can be used in a custom operator's CreateKernel callback to get the name of
   4871   * the operator's node name in the graph.
   4872   *
   4873   * \param[in] info An instance of ::OrtKernelInfo.
   4874   * \param[out] out Memory location into which to write the UTF-8
   4875   * null-terminated string representing the name.
   4876   * \param[in,out] size Pointer to the size of the `out` buffer. See above
   4877   * comments for details.
   4878   *
   4879   * \snippet{doc} snippets.dox OrtStatus Return Value
   4880   * \since Version 1.15
   4881   */
   4882  ORT_API2_STATUS(KernelInfo_GetNodeName, _In_ const OrtKernelInfo* info,
   4883                  _Out_ char* out, _Inout_ size_t* size);
   4884 
   4885  /** \brief Get the session logger from ::OrtKernelInfo.
   4886   *
   4887   * Used in the CreateKernel callback of an OrtCustomOp to get a logger that
   4888   * can be used to log messages.
   4889   *
   4890   * \param[in] info An instance of ::OrtKernelInfo.
   4891   * \param[out] logger Pointer set to the session's ::OrtLogger. Owned by ONNX
   4892   * Runtime, so do not free.
   4893   *
   4894   * \snippet{doc} snippets.dox OrtStatus Return Value
   4895   * \since Version 1.15
   4896   */
   4897  ORT_API2_STATUS(KernelInfo_GetLogger, _In_ const OrtKernelInfo* info,
   4898                  _Outptr_ const OrtLogger** logger);
   4899 
   4900  /// @}
   4901  /// \name OrtKernelContext
   4902  /// Custom operator APIs.
   4903  /// @{
   4904 
   4905  /** \brief Get the runtime logger from ::OrtKernelContext.
   4906   *
   4907   * Used in the KernelCompute callback of an OrtCustomOp to get a logger that
   4908   * can be used to log messages during inference.
   4909   *
   4910   * \param[in] context An instance of ::OrtKernelContext.
   4911   * \param[out] logger Pointer set to the kernel context's ::OrtLogger. Owned
   4912   * by ONNX Runtime, so do not free.
   4913   *
   4914   * \snippet{doc} snippets.dox OrtStatus Return Value
   4915   * \since Version 1.15
   4916   */
   4917  ORT_API2_STATUS(KernelContext_GetLogger, _In_ const OrtKernelContext* context,
   4918                  _Outptr_ const OrtLogger** logger);
   4919 
   4920  /// @}
   4921  /// \name OrtLogger
   4922  /// Custom operator APIs.
   4923  /// @{
   4924 
   4925  /** \brief Logs a message at the given severity level using the provided
   4926   * ::OrtLogger.
   4927   *
   4928   * Only messages with a severity level equal or greater than the ::OrtLogger's
   4929   * logging severity level are logged. Use
   4930   * OrtApi::Logger_GetLoggingSeverityLevel to get the ::OrtLogger's logging
   4931   * severity level.
   4932   *
   4933   * Can be used in custom operators to log messages with the logger retrieved
   4934   * via OrtApi::KernelInfo_GetLogger.
   4935   *
   4936   * \param[in] logger The ::OrtLogger instance.
   4937   * \param[in] log_severity_level The message's severity level.
   4938   * \param[in] message The message to log.
   4939   * \param[in] file_path The filepath of the file in which the message is
   4940   * logged. Usually the value of ORT_FILE.
   4941   * \param[in] line_number The file line number in which the message is logged.
   4942   * Usually the value of __LINE__.
   4943   * \param[in] func_name The name of the function in which the message is
   4944   * logged. Usually the value of __FUNCTION__.
   4945   *
   4946   * \snippet{doc} snippets.dox OrtStatus Return Value
   4947   * \since Version 1.15
   4948   */
   4949  ORT_API2_STATUS(Logger_LogMessage, _In_ const OrtLogger* logger,
   4950                  OrtLoggingLevel log_severity_level,
   4951                  _In_z_ const char* message, _In_z_ const ORTCHAR_T* file_path,
   4952                  int line_number, _In_z_ const char* func_name);
   4953 
   4954  /** \brief Get the logging severity level of the ::OrtLogger.
   4955   *
   4956   * Can be used in a custom operator to get the logging serverity level of the
   4957   * ::OrtLogger associated with the ::OrtKernelInfo.
   4958   *
   4959   * \param[in] logger The ::OrtLogger instance.
   4960   * \param[out] out Pointer to variable assigned with the logging severity
   4961   * level on success.
   4962   *
   4963   * \snippet{doc} snippets.dox OrtStatus Return Value
   4964   * \since Version 1.15
   4965   */
   4966  ORT_API2_STATUS(Logger_GetLoggingSeverityLevel, _In_ const OrtLogger* logger,
   4967                  _Out_ OrtLoggingLevel* out);
   4968 
   4969  /// @}
   4970 
   4971  /** \brief Get a ::OrtValue tensor stored as a constant initializer in the
   4972   * graph node.
   4973   *
   4974   * Used in the CreateKernel callback of an OrtCustomOp to get a tensor value.
   4975   *
   4976   * \param[in] info ::OrtKernelInfo instance.
   4977   * \param[in] index The node index.
   4978   * \param[out] is_constant Is it a constant node input or not.
   4979   * \param[out] out The OrtValue tensor value.
   4980   *
   4981   * \snippet{doc} snippets.dox OrtStatus Return Value
   4982   *
   4983   * \since Version 1.15.
   4984   */
   4985  ORT_API2_STATUS(KernelInfoGetConstantInput_tensor,
   4986                  _In_ const OrtKernelInfo* info, size_t index,
   4987                  _Out_ int* is_constant, _Outptr_ const OrtValue** out);
   4988 
   4989  /** \brief Get Optional Type information from an ::OrtTypeInfo
   4990   *
   4991   * This augments ::OrtTypeInfo to return an ::OrtOptionalTypeInfo when the
   4992   * type is optional. The OrtOptionalTypeInfo also has a nested ::OrtTypeInfo
   4993   * that describes the type of the optional value.
   4994   * ::OrtOptionalTypeInfo type can only appear within model metadata to
   4995   * describe inputs/outputs. The actual OrtValues that are supplied in place of
   4996   * optional type inputs should contain specific type that is described by
   4997   * ::OrtOptionalTypeInfo.
   4998   *
   4999   * So the picture: ::OrtTypeInfo -> ::OrtOptionalTypeInfo -> ::OrtTypeInfo
   5000   * (describes the type that can be supplied in place of the optional type when
   5001   * creating the actual ::OrtValue).
   5002   *
   5003   * \param[in] type_info
   5004   * \param[out] out A pointer to the ::OrtOptionalTypeInfo. Do not free this
   5005   * value, it is owned by OrtTypeInfo instance. When the type_info does not
   5006   * represent optional type, nullptr is returned in out.
   5007   *
   5008   * \snippet{doc} snippets.dox OrtStatus Return Value
   5009   *
   5010   * \since Version 1.15.
   5011   */
   5012  ORT_API2_STATUS(CastTypeInfoToOptionalTypeInfo,
   5013                  _In_ const OrtTypeInfo* type_info,
   5014                  _Outptr_result_maybenull_ const OrtOptionalTypeInfo** out);
   5015 
   5016  /** \brief Get OrtTypeInfo for the allowed contained type from an
   5017   * ::OrtOptionalTypeInfo.
   5018   *
   5019   * This augments ::OrtOptionalTypeInfo to return an ::OrtTypeInfo for the
   5020   * contained type. The OrtOptionalTypeInfo has a nested ::OrtTypeInfo that
   5021   * describes the type of the optional value.
   5022   * ::OrtOptionalTypeInfo type can only appear within model metadata to
   5023   * describe inputs/outputs. The actual OrtValues that are supplied in place of
   5024   * optional type inputs should contain specific type that is described by the
   5025   * returned ::OrtTypeInfo.
   5026   *
   5027   * \param[in] optional_type_info
   5028   * \param[out] out A copy of ::OrtTypeInfo for what the optional value could
   5029   * be. The user must free this value with ReleaseTypeInfo.
   5030   *
   5031   * \snippet{doc} snippets.dox OrtStatus Return Value
   5032   *
   5033   * \since Version 1.15.
   5034   */
   5035  ORT_API2_STATUS(GetOptionalContainedTypeInfo,
   5036                  _In_ const OrtOptionalTypeInfo* optional_type_info,
   5037                  _Outptr_ OrtTypeInfo** out);
   5038 
   5039  /** \brief Set a single string in a string tensor
   5040   *  Do not zero terminate the string data.
   5041   *
   5042   * \param[in] value A string tensor
   5043   * \param[in] index - flat index of the element
   5044   * \param[in] length_in_bytes length of the buffer in utf-8 bytes (without the
   5045   * null terminator)
   5046   * \param[inout] buffer - address of return value
   5047   *
   5048   * \snippet{doc} snippets.dox OrtStatus Return Value
   5049   */
   5050  ORT_API2_STATUS(GetResizedStringTensorElementBuffer, _Inout_ OrtValue* value,
   5051                  _In_ size_t index, _In_ size_t length_in_bytes,
   5052                  _Inout_ char** buffer);
   5053 
   5054  /** \brief Get Allocator from KernelContext for a specific memoryInfo. Please
   5055   * use C API ReleaseAllocator to release out object
   5056   *
   5057   * \param[in] context OrtKernelContext instance
   5058   * \param[in] mem_info OrtMemoryInfo instance
   5059   * \param[out] out A pointer to OrtAllocator.
   5060   *
   5061   * \snippet{doc} snippets.dox OrtStatus Return Value
   5062   *
   5063   * \since Version 1.15.
   5064   */
   5065  ORT_API2_STATUS(KernelContext_GetAllocator,
   5066                  _In_ const OrtKernelContext* context,
   5067                  _In_ const OrtMemoryInfo* mem_info,
   5068                  _Outptr_ OrtAllocator** out);
   5069 
   5070  /** \brief Returns a null terminated string of the build info including git
   5071   * info and cxx flags
   5072   *
   5073   * \return UTF-8 encoded version string. Do not deallocate the returned
   5074   * buffer.
   5075   *
   5076   * \since Version 1.15.
   5077   */
   5078  const char*(ORT_API_CALL* GetBuildInfoString)(void);
   5079 
   5080  /// \name OrtROCMProviderOptions
   5081  /// @{
   5082 
   5083  /** \brief Create an OrtROCMProviderOptions
   5084   *
   5085   * \param[out] out Newly created ::OrtROCMProviderOptions. Must be released
   5086   * with OrtApi::ReleaseROCMProviderOptions
   5087   *
   5088   * \snippet{doc} snippets.dox OrtStatus Return Value
   5089   *
   5090   * \since Version 1.16.
   5091   */
   5092  ORT_API2_STATUS(CreateROCMProviderOptions,
   5093                  _Outptr_ OrtROCMProviderOptions** out);
   5094 
   5095  /** \brief Set options in a ROCm Execution Provider.
   5096   *
   5097   * Please refer to
   5098   * https://onnxruntime.ai/docs/execution-providers/ROCm-ExecutionProvider.html
   5099   * to know the available keys and values. Key should be in null terminated
   5100   * string format of the member of
   5101   * ::OrtROCMProviderOptions and value should be its related range.
   5102   *
   5103   * For example, key="device_id" and value="0"
   5104   *
   5105   * \param[in] rocm_options
   5106   * \param[in] provider_options_keys Array of UTF-8 null-terminated string for
   5107   * provider options keys
   5108   * \param[in] provider_options_values Array of UTF-8 null-terminated string
   5109   * for provider options values
   5110   * \param[in] num_keys Number of elements in the `provider_option_keys` and
   5111   * `provider_options_values` arrays
   5112   *
   5113   * \snippet{doc} snippets.dox OrtStatus Return Value
   5114   *
   5115   * \since Version 1.16.
   5116   */
   5117  ORT_API2_STATUS(UpdateROCMProviderOptions,
   5118                  _Inout_ OrtROCMProviderOptions* rocm_options,
   5119                  _In_reads_(num_keys) const char* const* provider_options_keys,
   5120                  _In_reads_(num_keys)
   5121                      const char* const* provider_options_values,
   5122                  _In_ size_t num_keys);
   5123 
   5124  /**
   5125   * Get serialized ROCm provider options string.
   5126   *
   5127   * For example, "device_id=0;arena_extend_strategy=0;......"
   5128   *
   5129   * \param rocm_options - OrtROCMProviderOptions instance
   5130   * \param allocator - a ptr to an instance of OrtAllocator obtained with
   5131   * CreateAllocator() or GetAllocatorWithDefaultOptions() the specified
   5132   * allocator will be used to allocate continuous buffers for output strings
   5133   * and lengths.
   5134   * \param ptr - is a UTF-8 null terminated string allocated using 'allocator'.
   5135   * The caller is responsible for using the same allocator to free it.
   5136   *
   5137   * \snippet{doc} snippets.dox OrtStatus Return Value
   5138   *
   5139   * \since Version 1.16.
   5140   */
   5141  ORT_API2_STATUS(GetROCMProviderOptionsAsString,
   5142                  _In_ const OrtROCMProviderOptions* rocm_options,
   5143                  _Inout_ OrtAllocator* allocator, _Outptr_ char** ptr);
   5144 
   5145  /** \brief Release an ::OrtROCMProviderOptions
   5146   *
   5147   * \note This is an exception in the naming convention of other Release*
   5148   * functions, as the name of the method does not have the V2 suffix, but the
   5149   * type does
   5150   *
   5151   * \since Version 1.16.
   5152   */
   5153  void(ORT_API_CALL* ReleaseROCMProviderOptions)(
   5154      _Frees_ptr_opt_ OrtROCMProviderOptions* input);
   5155 
   5156  /** \brief Create an allocator with specific type and register it with the
   5157   * ::OrtEnv This API enhance CreateAndRegisterAllocator that it can create an
   5158   * allocator with specific type, not just CPU allocator Enables sharing the
   5159   * allocator between multiple sessions that use the same env instance.
   5160   *  Lifetime of the created allocator will be valid for the duration of the
   5161   * environment. Returns an error if an allocator with the same ::OrtMemoryInfo
   5162   * is already registered.
   5163   *  \param[in] env OrtEnv instance
   5164   *  \param[in] provider_type ExecutionProvider type
   5165   *  \param[in] mem_info OrtMemoryInfo instance
   5166   *  \param[in] arena_cfg Arena configuration
   5167   *  \param[in] provider_options_keys key of the provider options map
   5168   *  \param[in] provider_options_values value of the provider options map
   5169   *  \param[in] num_keys Length of the provider options map
   5170   */
   5171  ORT_API2_STATUS(CreateAndRegisterAllocatorV2, _Inout_ OrtEnv* env,
   5172                  _In_ const char* provider_type,
   5173                  _In_ const OrtMemoryInfo* mem_info,
   5174                  _In_ const OrtArenaCfg* arena_cfg,
   5175                  _In_reads_(num_keys) const char* const* provider_options_keys,
   5176                  _In_reads_(num_keys)
   5177                      const char* const* provider_options_values,
   5178                  _In_ size_t num_keys);
   5179 
   5180  /** \brief Run the model asynchronously in a thread owned by intra op thread
   5181   * pool
   5182   *
   5183   * \param[in] session
   5184   * \param[in] run_options If nullptr, will use a default ::OrtRunOptions
   5185   * \param[in] input_names Array of null terminated UTF8 encoded strings of the
   5186   * input names
   5187   * \param[in] input Array of ::OrtValue%s of the input values
   5188   * \param[in] input_len Number of elements in the input_names and inputs
   5189   * arrays
   5190   * \param[in] output_names Array of null terminated UTF8 encoded strings of
   5191   * the output names
   5192   * \param[in] output_names_len Number of elements in the output_names and
   5193   * outputs array
   5194   * \param[out] output OrtValue* array of size output_names_len.
   5195   *             On calling RunAsync, output[i] could either be a null or a
   5196   * pointer to a preallocated OrtValue. Later, the output array will be passed
   5197   * to run_async_callback with all null(s) filled with valid OrtValue
   5198   * pointer(s) allocated by onnxruntime. NOTE: it is customer's duty to finally
   5199   * release the output array and each of its member, regardless of whether the
   5200   * member (OrtValue*) is allocated by onnxruntime or preallocated by the
   5201   * customer.
   5202   * \param[in] run_async_callback Callback function on model run completion
   5203   * \param[in] user_data User data that pass back to run_async_callback
   5204   */
   5205  ORT_API2_STATUS(RunAsync, _Inout_ OrtSession* session,
   5206                  _In_opt_ const OrtRunOptions* run_options,
   5207                  _In_reads_(input_len) const char* const* input_names,
   5208                  _In_reads_(input_len) const OrtValue* const* input,
   5209                  size_t input_len,
   5210                  _In_reads_(output_names_len) const char* const* output_names,
   5211                  size_t output_names_len,
   5212                  _Inout_updates_all_(output_names_len) OrtValue** output,
   5213                  _In_ RunAsyncCallbackFn run_async_callback,
   5214                  _In_opt_ void* user_data);
   5215 
   5216  /**
   5217   * Update TensorRT EP provider option where its data type is pointer, for
   5218   * example 'user_compute_stream'. If the data type of the provider option can
   5219   * be represented by string please use UpdateTensorRTProviderOptions.
   5220   *
   5221   * Note: It's caller's responsibility to properly manage the lifetime of the
   5222   * instance pointed by this pointer.
   5223   *
   5224   * \param tensorrt_options - OrtTensorRTProviderOptionsV2 instance
   5225   * \param key - Name of the provider option
   5226   * \param value - A pointer to the instance that will be assigned to this
   5227   * provider option
   5228   *
   5229   * \since Version 1.16.
   5230   */
   5231  ORT_API2_STATUS(UpdateTensorRTProviderOptionsWithValue,
   5232                  _Inout_ OrtTensorRTProviderOptionsV2* tensorrt_options,
   5233                  _In_ const char* key, _In_ void* value);
   5234 
   5235  /**
   5236   * Get TensorRT EP provider option where its data type is pointer.
   5237   * If the data type of the provider option can be represented by string please
   5238   * use GetTensorRTProviderOptionsAsString.
   5239   *
   5240   * \param tensorrt_options - OrtTensorRTProviderOptionsV2 instance
   5241   * \param key - Name of the provider option
   5242   * \param ptr - A pointer to the instance that is kept by the provider option
   5243   *
   5244   * \since Version 1.16.
   5245   */
   5246  ORT_API2_STATUS(GetTensorRTProviderOptionsByName,
   5247                  _In_ const OrtTensorRTProviderOptionsV2* tensorrt_options,
   5248                  _In_ const char* key, _Outptr_ void** ptr);
   5249 
   5250  /**
   5251   * Update CUDA EP provider option where its data type is pointer, for example
   5252   * 'user_compute_stream'. If the data type of the provider option can be
   5253   * represented by string please use UpdateCUDAProviderOptions.
   5254   *
   5255   * Note: It's caller's responsibility to properly manage the lifetime of the
   5256   * instance pointed by this pointer.
   5257   *
   5258   * \param cuda_options - OrtCUDAProviderOptionsV2 instance
   5259   * \param key - Name of the provider option
   5260   * \param value - A pointer to the instance that will be assigned to this
   5261   * provider option
   5262   *
   5263   * \since Version 1.16.
   5264   */
   5265  ORT_API2_STATUS(UpdateCUDAProviderOptionsWithValue,
   5266                  _Inout_ OrtCUDAProviderOptionsV2* cuda_options,
   5267                  _In_ const char* key, _In_ void* value);
   5268 
   5269  /**
   5270   * Get CUDA EP provider option where its data type is pointer.
   5271   * If the data type of the provider option can be represented by string please
   5272   * use GetCUDAProviderOptionsAsString.
   5273   *
   5274   * \param cuda_options - OrtCUDAProviderOptionsV2 instance
   5275   * \param key - Name of the provider option
   5276   * \param ptr - A pointer to the instance that is kept by the provider option
   5277   *
   5278   * \since Version 1.16.
   5279   */
   5280  ORT_API2_STATUS(GetCUDAProviderOptionsByName,
   5281                  _In_ const OrtCUDAProviderOptionsV2* cuda_options,
   5282                  _In_ const char* key, _Outptr_ void** ptr);
   5283 
   5284  /**
   5285   * Get a EP resource.
   5286   * E.g. a cuda stream or a cublas handle
   5287   *
   5288   * \param context - Kernel context
   5289   * \param resource_version - Version of the resource
   5290   * \param resource_id - Type of resource
   5291   * \param resource - A pointer to returned resource
   5292   *
   5293   * \since Version 1.16.
   5294   */
   5295  ORT_API2_STATUS(KernelContext_GetResource,
   5296                  _In_ const OrtKernelContext* context,
   5297                  _In_ int resource_version, _In_ int resource_id,
   5298                  _Outptr_ void** resource);
   5299 
   5300  /** \brief Set user logging function
   5301   *
   5302   *  By default the logger created by the CreateEnv* functions is used to
   5303   * create the session logger as well. This function allows a user to override
   5304   * this default session logger with a logger of their own choosing. This way
   5305   *  the user doesn't have to create a separate environment with a custom
   5306   * logger. This addresses the problem when the user already created an env but
   5307   * now wants to use a different logger for a specific session (for debugging
   5308   * or other reasons).
   5309   *
   5310   * \param[in] options
   5311   * \param[in] user_logging_function A pointer to a logging function.
   5312   * \param[in] user_logging_param A pointer to arbitrary data passed as the
   5313   * ::OrtLoggingFunction `param` parameter to `user_logging_function`. This
   5314   * parameter is optional.
   5315   *
   5316   * \snippet{doc} snippets.dox OrtStatus Return Value
   5317   *
   5318   * \since Version 1.17.
   5319   */
   5320  ORT_API2_STATUS(SetUserLoggingFunction, _Inout_ OrtSessionOptions* options,
   5321                  _In_ OrtLoggingFunction user_logging_function,
   5322                  _In_opt_ void* user_logging_param);
   5323 
   5324  /**
   5325   * Get number of input from OrtShapeInferContext
   5326   *
   5327   * \param[in] context
   5328   * \param[out] out The number of inputs
   5329   *
   5330   * \since Version 1.17.
   5331   */
   5332  ORT_API2_STATUS(ShapeInferContext_GetInputCount,
   5333                  _In_ const OrtShapeInferContext* context, _Out_ size_t* out);
   5334 
   5335  /**
   5336   * Get type and shape info of an input
   5337   *
   5338   * \param[in] context
   5339   * \param[in] index The index of the input
   5340   * \param[out] info Type shape info of the input
   5341   *
   5342   * \since Version 1.17.
   5343   */
   5344  ORT_API2_STATUS(ShapeInferContext_GetInputTypeShape,
   5345                  _In_ const OrtShapeInferContext* context, _In_ size_t index,
   5346                  _Outptr_ OrtTensorTypeAndShapeInfo** info);
   5347 
   5348  /**
   5349   * Get attribute from OrtShapeInferContext. Note that OrtShapeInferContext is
   5350   * a per-node context, one could only read attribute from current node.
   5351   *
   5352   * \param[in] context
   5353   * \param[in] attr_name Name of the attribute
   5354   * \param[out] attr Handle of the attribute fetched
   5355   *
   5356   * \since Version 1.17.
   5357   */
   5358  ORT_API2_STATUS(ShapeInferContext_GetAttribute,
   5359                  _In_ const OrtShapeInferContext* context,
   5360                  _In_ const char* attr_name, _Outptr_ const OrtOpAttr** attr);
   5361 
   5362  /**
   5363   * Set type and shape info of an output
   5364   *
   5365   * \param[in] context
   5366   * \param[in] index The index of the output
   5367   * \param[out] info Type shape info of the output
   5368   *
   5369   * \since Version 1.17.
   5370   */
   5371  ORT_API2_STATUS(ShapeInferContext_SetOutputTypeShape,
   5372                  _In_ const OrtShapeInferContext* context, _In_ size_t index,
   5373                  _In_ const OrtTensorTypeAndShapeInfo* info);
   5374 
   5375  /**
   5376   * Set symbolic shape to type shape info
   5377   *
   5378   * \param[in] info Type shape info
   5379   * \param[in] dim_params Symbolic strings
   5380   * \param[in] dim_params_length Number of strings
   5381   *
   5382   * \since Version 1.17.
   5383   */
   5384  ORT_API2_STATUS(SetSymbolicDimensions, _In_ OrtTensorTypeAndShapeInfo* info,
   5385                  _In_ const char* dim_params[], _In_ size_t dim_params_length);
   5386 
   5387  /**
   5388   * Read contents of an attribute to data
   5389   *
   5390   * \param[in] op_attr
   5391   * \param[in] type Attribute type
   5392   * \param[out] data Memory address to save raw content of the attribute
   5393   * \param[in] len Number of bytes allowed to store in data
   5394   * \param[out] out Number of bytes required to save the data when the call
   5395   * failed, or the real number of bytes saved to data on success
   5396   *
   5397   * \since Version 1.17.
   5398   */
   5399  ORT_API2_STATUS(ReadOpAttr, _In_ const OrtOpAttr* op_attr,
   5400                  _In_ OrtOpAttrType type, _Inout_ void* data, _In_ size_t len,
   5401                  _Out_ size_t* out);
   5402 
   5403  /** \brief Set whether to use deterministic compute.
   5404   *
   5405   * Default is false. If set to true, this will enable deterministic compute
   5406   * for GPU kernels where possible. Note that this most likely will have a
   5407   * performance cost.
   5408   *
   5409   * \param[in] options
   5410   * \param[in] value
   5411   *
   5412   * \since Version 1.17.
   5413   */
   5414  ORT_API2_STATUS(SetDeterministicCompute, _Inout_ OrtSessionOptions* options,
   5415                  bool value);
   5416 
   5417  /**
   5418   * Run fn in parallel
   5419   *
   5420   * \param[in] context
   5421   * \param[in] fn Function accepting usr_data and an integer as iterator
   5422   * \param[in] total The number of times fn is to be invoked
   5423   * \param[in] num_batch Number of batches by which the "total" is to be
   5424   * divided in maximum. When zero, there is no limit
   5425   * \param[in] usr_data User data to be passed back to fn
   5426   *
   5427   * \since Version 1.17.
   5428   */
   5429  ORT_API2_STATUS(KernelContext_ParallelFor,
   5430                  _In_ const OrtKernelContext* context,
   5431                  _In_ void (*fn)(void*, size_t), _In_ size_t total,
   5432                  _In_ size_t num_batch, _In_ void* usr_data);
   5433 
   5434  /** \brief Append OpenVINO execution provider to the session options
   5435   *
   5436   * If OpenVINO is not available (due to a non OpenVINO enabled build, or if
   5437   * OpenVINO is not installed on the system), this function will fail.
   5438   *
   5439   * \param[in] options
   5440   * \param[in] provider_options_keys
   5441   * \param[in] provider_options_values
   5442   * \param[in] num_keys
   5443   *
   5444   * \snippet{doc} snippets.dox OrtStatus Return Value
   5445   *
   5446   * \since Version 1.17.
   5447   */
   5448  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_OpenVINO_V2,
   5449                  _In_ OrtSessionOptions* options,
   5450                  _In_reads_(num_keys) const char* const* provider_options_keys,
   5451                  _In_reads_(num_keys)
   5452                      const char* const* provider_options_values,
   5453                  _In_ size_t num_keys);
   5454 
   5455  /** \brief Append VitisAI provider to session options
   5456   *
   5457   * If VitisAI is not available (due to a non VitisAI enabled build, or if
   5458   * VitisAI is not installed on the system), this function will return failure.
   5459   *
   5460   * \param[in] options
   5461   * \param[in] provider_options_keys
   5462   * \param[in] provider_options_values
   5463   * \param[in] num_keys
   5464   *
   5465   * \snippet{doc} snippets.dox OrtStatus Return Value
   5466   *
   5467   * \since Version 1.18.
   5468   */
   5469  ORT_API2_STATUS(SessionOptionsAppendExecutionProvider_VitisAI,
   5470                  _In_ OrtSessionOptions* options,
   5471                  _In_reads_(num_keys) const char* const* provider_options_keys,
   5472                  _In_reads_(num_keys)
   5473                      const char* const* provider_options_values,
   5474                  _In_ size_t num_keys);
   5475 
   5476  /** \brief Get scratch buffer from the corresponding allocator under the
   5477   * sepcific OrtMemoryInfo object. NOTE: callers are responsible to release
   5478   * this scratch buffer from the corresponding allocator
   5479   *  \param[in] context OrtKernelContext instance
   5480   *  \param[in] mem_info OrtMemoryInfo instance
   5481   *  \param[in] count_or_bytes How many bytes is this scratch buffer
   5482   *  \param[out] out A pointer to the scrach buffer
   5483   *
   5484   *  \snippet{doc} snippets.dox OrtStatus Return Value
   5485   *
   5486   * \since Version 1.18.
   5487   */
   5488  ORT_API2_STATUS(KernelContext_GetScratchBuffer,
   5489                  _In_ const OrtKernelContext* context,
   5490                  _In_ const OrtMemoryInfo* mem_info,
   5491                  _In_ size_t count_or_bytes, _Outptr_ void** out);
   5492 
   5493  /** \brief Get allocator from KernelInfo for a specific memory type. Please
   5494   * use C API ReleaseAllocator to release out object
   5495   *
   5496   * \param[in] info OrtKernelInfo instance
   5497   * \param[in] mem_type OrtMemType object
   5498   * \param[out] out A pointer to OrtAllocator
   5499   *
   5500   * \snippet{doc} snippets.dox OrtStatus Return Value
   5501   *
   5502   * \since Version 1.18.
   5503   */
   5504  ORT_API2_STATUS(KernelInfoGetAllocator, _In_ const OrtKernelInfo* info,
   5505                  _In_ OrtMemType mem_type, _Outptr_ OrtAllocator** out);
   5506 
   5507  /** \brief Replace initialized Tensors with external data with the provided
   5508   * files in memory
   5509   *
   5510   * The function will find the initialized TensorProtos with external data in
   5511   * the graph with the provided external file names and the file content in
   5512   * memory. The API gets the external file name, offset, data length from
   5513   * TensorProto, and locate the tensor data from the file in memory buffer. It
   5514   * creates a Tensor to replace the existing Tensor in graph. The replacement
   5515   * will occur before any of the optimizations take place. The data will be
   5516   * copied into the graph since TensorProto can't refer to the user provided
   5517   * buffers.
   5518   *
   5519   * \param[in] options
   5520   * \param[in] external_initializer_file_names Array of null terminated UTF-8
   5521   * encoded strings of the file names which holds the external initializers.
   5522   * \param[in] external_initializer_file_buffer_array Array of pointers to the
   5523   * buffer of the file content. The buffer can be freed after session creation.
   5524   * \param[in] external_initializer_file_lengths Array of size_t to indicate
   5525   * the length of file content
   5526   * \param[in] num_external_initializer_files Number of external files
   5527   *
   5528   * \snippet{doc} snippets.dox OrtStatus Return Value
   5529   *
   5530   * \since Version 1.18.
   5531   */
   5532  ORT_API2_STATUS(AddExternalInitializersFromFilesInMemory,
   5533                  _In_ OrtSessionOptions* options,
   5534                  _In_reads_(num_external_initializer_files)
   5535                      const ORTCHAR_T* const* external_initializer_file_names,
   5536                  _In_reads_(num_external_initializer_files) char* const*
   5537                      external_initializer_file_buffer_array,
   5538                  _In_reads_(num_external_initializer_files)
   5539                      const size_t* external_initializer_file_lengths,
   5540                  size_t num_external_initializer_files);
   5541 
   5542  /** \brief Create an OrtLoraAdapter
   5543   *
   5544   * The function attempts to locate file specified by adapter_file_path, read
   5545   * it and create an OrtLoraAdapter instance. The adapter_file_path should be a
   5546   * valid path to a file that contains a valid Lora Adapter format. The
   5547   * function attempts to validate the format at load time. The file will always
   5548   * be memory mapped, unless the platform does not support memory mapping, in
   5549   * which case the file will be read into memory.
   5550   *
   5551   * \param[in] adapter_file_path adapter file path.
   5552   * \param[in] allocator optional pointer to a device allocator. If specified
   5553   *            data is copied to the device at some point before Run() is
   5554   * invoked. If nullptr, data stays on CPU. The data would still be copied to
   5555   * device if required by the model at inference time.
   5556   * \param[out] out A pointer to a newly created OrtLoraAdapter instance. Must
   5557   * be released with OrtApi::ReleaseLoraAdapter.
   5558   *
   5559   * \snippet{doc} snippets.dox OrtStatus Return Value
   5560   *
   5561   * \since Version 1.20.
   5562   */
   5563  ORT_API2_STATUS(CreateLoraAdapter, const ORTCHAR_T* adapter_file_path,
   5564                  _In_ OrtAllocator* allocator, _Outptr_ OrtLoraAdapter** out);
   5565 
   5566  /** \brief Create an OrtLoraAdapter
   5567   *
   5568   * The function copies the bytes from the array and creates an OrtLoraAdapter
   5569   * instance.
   5570   *
   5571   *
   5572   * \param[in] bytes pointer to a valid Lora Adapter format buffer.
   5573   * \param[in] num_bytes length of bytes buffer.
   5574   * \param[in] allocator optional pointer to a device allocator. If specified
   5575   *            data is copied to the device at some point before Run() is
   5576   * invoked. If nullptr, data stays on CPU. The data would still be copied to
   5577   * device if required by the model at inference time.
   5578   * \param[out] out A pointer to a newly created OrtLoraAdapter instance. Must
   5579   * be released with OrtApi::ReleaseLoraAdapter.
   5580   *
   5581   * \snippet{doc} snippets.dox OrtStatus Return Value
   5582   *
   5583   * \since Version 1.20.
   5584   */
   5585  ORT_API2_STATUS(CreateLoraAdapterFromArray, _In_ const void* bytes,
   5586                  size_t num_bytes, _In_ OrtAllocator* allocator,
   5587                  _Outptr_ OrtLoraAdapter** out);
   5588 
   5589  /** \brief Release an ::OrtLoraAdapter obtained from OrtApi::CreateLoraAdapter
   5590   */
   5591  ORT_CLASS_RELEASE(LoraAdapter);
   5592 
   5593  /** \brief Add the Lora Adapter to the list of active adapters.
   5594   *
   5595   * The function adds the Lora Adapter to the list of active adapters. The Lora
   5596   * Adapter must be created with OrtApi::CreateLoraAdapter or FromArray. The
   5597   * Lora Adapter will be used by the session to run the model. The instance of
   5598   * the OrtRunOptions can then be used to customize the Run() calls. More than
   5599   * one OrtLoraAdapter can be active at the same time. Lora Parameters that
   5600   * belong to different Lora adapters that will be active at the same time must
   5601   * not overlap. This setting does not affect RunWithBinding.
   5602   *
   5603   * \param[in] options OrtRunOptions instance
   5604   * \param[in] adapter OrtLoraAdapter instance
   5605   *
   5606   * \snippet{doc} snippets.dox OrtStatus Return Value
   5607   *
   5608   * \since Version 1.20.
   5609   */
   5610  ORT_API2_STATUS(RunOptionsAddActiveLoraAdapter,
   5611                  _Inout_ OrtRunOptions* options,
   5612                  _In_ const OrtLoraAdapter* adapter);
   5613 
   5614  /// @}
   5615  /// \name OrtEpDynamicOptions
   5616  /// @{
   5617 
   5618  /** \brief Set DynamicOptions for EPs (Execution Providers)
   5619   *
   5620   * Valid options can be found in
   5621   * `include\onnxruntime\core\session\onnxruntime_session_options_config_keys.h`
   5622   * Look for `kOrtEpDynamicOptions`
   5623   *
   5624   * \param[in] sess OrtSession
   5625   * \param[in] keys Array of null terminated UTF8 encoded strings of EP dynamic
   5626   * option keys
   5627   * \param[in] values Array of null terminated UTF8 encoded string of EP
   5628   * dynamic option values
   5629   * \param[in] kv_len Number of elements in the keys and values arrays
   5630   *
   5631   * \snippet{doc} snippets.dox OrtStatus Return Value
   5632   *
   5633   * \since Version 1.20.
   5634   */
   5635  ORT_API2_STATUS(SetEpDynamicOptions, _Inout_ OrtSession* sess,
   5636                  _In_reads_(kv_len) const char* const* keys,
   5637                  _In_reads_(kv_len) const char* const* values,
   5638                  _In_ size_t kv_len);
   5639 
   5640  /** \brief Release an OrtValueInfo instance if it was not added to an
   5641   * OrtGraph.
   5642   * \since Version 1.21.
   5643   */
   5644  ORT_CLASS_RELEASE(ValueInfo);
   5645 
   5646  /** \brief Release an OrtNode if it was not added to an OrtGraph.
   5647   * \since Version 1.21.
   5648   */
   5649  ORT_CLASS_RELEASE(Node);
   5650 
   5651  /** \brief Release an OrtGraph.
   5652   * \snippet{doc} snippets.dox OrtStatus Return Value
   5653   * \since Version 1.21.
   5654   */
   5655  ORT_CLASS_RELEASE(Graph);
   5656 
   5657  /** \brief Release an OrtModel.
   5658   * \snippet{doc} snippets.dox OrtStatus Return Value
   5659   * \since Version 1.21.
   5660   */
   5661  ORT_CLASS_RELEASE(Model);
   5662 
   5663  /** \brief Get the value name from an OrtValueInfo instance.
   5664   * \param[in] value_info The OrtValueInfo instance.
   5665   * \snippet{doc} snippets.dox OrtStatus Return Value
   5666   * \since Version 1.21.
   5667   */
   5668  ORT_API2_STATUS(GetValueInfoName, _In_ const OrtValueInfo* value_info,
   5669                  _Out_ const char** name);
   5670 
   5671  /** \brief Get the type information from an OrtValueInfo instance.
   5672   * \param[in] value_info The OrtValueInfo instance.
   5673   * \snippet{doc} snippets.dox OrtStatus Return Value
   5674   * \since Version 1.21.
   5675   */
   5676  ORT_API2_STATUS(GetValueInfoTypeInfo, _In_ const OrtValueInfo* value_info,
   5677                  _Outptr_ const OrtTypeInfo** type_info);
   5678 
   5679  /** \brief Get the Model Editor API instance
   5680   *
   5681   * Get the Model Editor API instance to create a new model or augment an
   5682   * existing model.
   5683   *
   5684   * \return Model Editor API struct
   5685   *
   5686   * \since Version 1.21.
   5687   */
   5688  const OrtModelEditorApi*(ORT_API_CALL* GetModelEditorApi)();
   5689 
   5690  /** \brief Create an OrtValue for a Tensor that uses pre-existing memory.
   5691   *
   5692   * ORT will take ownership of the memory and free it using the provided
   5693   * deleter when no longer in use.
   5694   *
   5695   * \param[in] deleter OrtAllocator instance that will be used to free the
   5696   * memory. Only the OrtAllocator:Info and OrtAllocator::Release functions are
   5697   * required. The OrtMemoryInfo returned by OrtAllocator::Info must match the
   5698   * location of p_data.
   5699   * \param[in] p_data Pointer to the memory that will be used by the Tensor.
   5700   * ORT will take ownership of the memory.
   5701   * \param[in] p_data_len Length of the memory in bytes.
   5702   * \param[in] shape Dimensions of the Tensor. All values should be > 0.
   5703   * \param[in] shape_len Number of dimensions in the shape array.
   5704   * \param[in] type Data type of the Tensor.
   5705   *
   5706   * \snippet{doc} snippets.dox OrtStatus Return Value
   5707   *
   5708   * \since Version 1.21.
   5709   */
   5710  ORT_API2_STATUS(CreateTensorWithDataAndDeleterAsOrtValue,
   5711                  _In_ OrtAllocator* deleter, _In_ void* p_data,
   5712                  size_t p_data_len, _In_ const int64_t* shape,
   5713                  size_t shape_len, ONNXTensorElementDataType type,
   5714                  _Outptr_ OrtValue** out);
   5715 };
   5716 
   5717 /*
   5718 * Steps to use a custom op:
   5719 *   1 Create an OrtCustomOpDomain with the domain name used by the custom ops
   5720 *   2 Create an OrtCustomOp structure for each op and add them to the domain
   5721 *   3 Call OrtAddCustomOpDomain to add the custom domain of ops to the session
   5722 * options
   5723 */
   5724 
   5725 // Specifies some characteristics of inputs/outputs of custom ops:
   5726 // Specify if the inputs/outputs are one of:
   5727 // 1) Non-optional (input/output must be present in the node)
   5728 // 2) Optional (input/output may be absent in the node)
   5729 // 3) Variadic: A variadic input or output specifies N (i.e., the minimum arity)
   5730 // or more operands.
   5731 //              Only the last input or output of a custom op may be marked as
   5732 //              variadic. The homogeneity of the variadic input or output
   5733 //              determines whether all operands must be of the same tensor
   5734 //              element type.
   5735 typedef enum OrtCustomOpInputOutputCharacteristic {
   5736  INPUT_OUTPUT_REQUIRED = 0,
   5737  INPUT_OUTPUT_OPTIONAL,
   5738  INPUT_OUTPUT_VARIADIC,
   5739 } OrtCustomOpInputOutputCharacteristic;
   5740 
   5741 /*
   5742 * The OrtCustomOp structure defines a custom op's schema and its kernel
   5743 * callbacks. The callbacks are filled in by the implementor of the custom op.
   5744 */
   5745 struct OrtCustomOp {
   5746  uint32_t version;  // Must be initialized to ORT_API_VERSION
   5747 
   5748  // This callback creates the kernel, which is a user defined
   5749  // parameter that is passed to the Kernel* callbacks below. It is
   5750  // recommended to use CreateKernelV2 which allows for a safe error
   5751  // propagation by returning an OrtStatusPtr.
   5752  void*(ORT_API_CALL* CreateKernel)(_In_ const struct OrtCustomOp* op,
   5753                                    _In_ const OrtApi* api,
   5754                                    _In_ const OrtKernelInfo* info);
   5755 
   5756  // Returns the name of the op
   5757  const char*(ORT_API_CALL* GetName)(_In_ const struct OrtCustomOp* op);
   5758 
   5759  // Returns the type of the execution provider, return nullptr to use CPU
   5760  // execution provider
   5761  const char*(ORT_API_CALL* GetExecutionProviderType)(
   5762      _In_ const struct OrtCustomOp* op);
   5763 
   5764  // Returns the count and types of the input & output tensors
   5765  ONNXTensorElementDataType(ORT_API_CALL* GetInputType)(
   5766      _In_ const struct OrtCustomOp* op, _In_ size_t index);
   5767  size_t(ORT_API_CALL* GetInputTypeCount)(_In_ const struct OrtCustomOp* op);
   5768  ONNXTensorElementDataType(ORT_API_CALL* GetOutputType)(
   5769      _In_ const struct OrtCustomOp* op, _In_ size_t index);
   5770  size_t(ORT_API_CALL* GetOutputTypeCount)(_In_ const struct OrtCustomOp* op);
   5771 
   5772  // Perform a computation step.  It is recommended to use
   5773  // KernelComputeV2 which allows for a safe error propagation by
   5774  // returning an OrtStatusPtr.
   5775  void(ORT_API_CALL* KernelCompute)(_In_ void* op_kernel,
   5776                                    _In_ OrtKernelContext* context);
   5777  void(ORT_API_CALL* KernelDestroy)(_In_ void* op_kernel);
   5778 
   5779  // Returns the characteristics of the input & output tensors
   5780  OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetInputCharacteristic)(
   5781      _In_ const struct OrtCustomOp* op, _In_ size_t index);
   5782  OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(
   5783      _In_ const struct OrtCustomOp* op, _In_ size_t index);
   5784 
   5785  // Returns the memory type of the input tensors. This API allows the custom op
   5786  // to place the inputs on specific devices. By default, it returns
   5787  // OrtMemTypeDefault, which means the input is placed on the default device
   5788  // for the execution provider. If the inputs need to be with different memory
   5789  // tyeps, this function can be overridden to return the specific memory types.
   5790  OrtMemType(ORT_API_CALL* GetInputMemoryType)(
   5791      _In_ const struct OrtCustomOp* op, _In_ size_t index);
   5792 
   5793  // Returns the minimum number of input arguments expected for the variadic
   5794  // input. Applicable only for custom ops that have a variadic input.
   5795  int(ORT_API_CALL* GetVariadicInputMinArity)(
   5796      _In_ const struct OrtCustomOp* op);
   5797 
   5798  // Returns true (non-zero) if all arguments of a variadic input have to be of
   5799  // the same type (homogeneous), and false (zero) otherwise. Applicable only
   5800  // for custom ops that have a variadic input.
   5801  int(ORT_API_CALL* GetVariadicInputHomogeneity)(
   5802      _In_ const struct OrtCustomOp* op);
   5803 
   5804  // Returns the minimum number of output values expected for the variadic
   5805  // output. Applicable only for custom ops that have a variadic output.
   5806  int(ORT_API_CALL* GetVariadicOutputMinArity)(
   5807      _In_ const struct OrtCustomOp* op);
   5808 
   5809  // Returns true (non-zero) if all outputs values of a variadic output have to
   5810  // be of the same type (homogeneous), and false (zero) otherwise. Applicable
   5811  // only for custom ops that have a variadic output.
   5812  int(ORT_API_CALL* GetVariadicOutputHomogeneity)(
   5813      _In_ const struct OrtCustomOp* op);
   5814 
   5815  // Create the kernel state which is passed to each compute call.
   5816  OrtStatusPtr(ORT_API_CALL* CreateKernelV2)(_In_ const struct OrtCustomOp* op,
   5817                                             _In_ const OrtApi* api,
   5818                                             _In_ const OrtKernelInfo* info,
   5819                                             _Out_ void** kernel);
   5820 
   5821  // Perform the computation step.
   5822  OrtStatusPtr(ORT_API_CALL* KernelComputeV2)(_In_ void* op_kernel,
   5823                                              _In_ OrtKernelContext* context);
   5824 
   5825  OrtStatusPtr(ORT_API_CALL* InferOutputShapeFn)(
   5826      _In_ const struct OrtCustomOp* op, _In_ OrtShapeInferContext*);
   5827 
   5828  // Get start range
   5829  int(ORT_API_CALL* GetStartVersion)(_In_ const struct OrtCustomOp* op);
   5830  int(ORT_API_CALL* GetEndVersion)(_In_ const struct OrtCustomOp* op);
   5831 
   5832  // Get the inplace_map that defines which output can reuse which input
   5833  // Callers will provide 2 raw int* and pass in their address, this function
   5834  // will fill these 2 arrays when return, output (*output_index)[i] may reuse
   5835  // the input (*input_index[i]). The return value is the size of these 2
   5836  // arrays. Callers are responsible to delete these 2 arrays after use by
   5837  // calling OrtCustomOp::ReleaseMayInplace().
   5838  size_t(ORT_API_CALL* GetMayInplace)(_Out_ int** input_index,
   5839                                      _Out_ int** output_index);
   5840 
   5841  // Release the pointer input_index and output_index allocated from
   5842  // GetMayInplace() function. If GetMayInplace() is defined, this function MUST
   5843  // be defined as well.
   5844  void(ORT_API_CALL* ReleaseMayInplace)(_Frees_ptr_opt_ int* input_index,
   5845                                        _Frees_ptr_opt_ int* output_index);
   5846 
   5847  // Same as GetMayInplace() and ReleaseMayInplace()
   5848  size_t(ORT_API_CALL* GetAliasMap)(_Out_ int** input_index,
   5849                                    _Out_ int** output_index);
   5850  void(ORT_API_CALL* ReleaseAliasMap)(_Frees_ptr_opt_ int* input_index,
   5851                                      _Frees_ptr_opt_ int* output_index);
   5852 };
   5853 
   5854 /**
   5855 * ORT Model Editor API
   5856 */
   5857 
   5858 /**
   5859 * \brief The OrtModelEditorApi struct provides functions to create or edit an
   5860 * ONNX model.
   5861 *
   5862 * See onnxruntime/test/shared_lib/test_model_editor_api.cc for example usage.
   5863 *
   5864 * \since Version 1.21.
   5865 */
   5866 struct OrtModelEditorApi {
   5867  // Model building/editing requires a full build. We return nullptr from
   5868  // GetModelEditorApi if this is a minimal build, so it doesn't matter if there
   5869  // are no function pointers in this struct as a user will never get an
   5870  // OrtModelEditorApi instance. We do however need a dummy field to avoid empty
   5871  // struct warning.
   5872 #if defined(ORT_MINIMAL_BUILD)
   5873  const bool not_defined_in_this_build;
   5874 #else
   5875  /** \brief Create an OrtTypeInfo instance for a Tensor.
   5876   *
   5877   * Create an OrtTypeInfo instance for a Tensor to use as graph inputs/outputs
   5878   * with the Model Editor API.
   5879   *
   5880   * User can release `tensor_info` after creating the OrtTypeInfo.
   5881   *
   5882   * \param[in] tensor_info Tensor type and shape information.
   5883   * \param[out] TypeInfo instance for the tensor.
   5884   *
   5885   * \snippet{doc} snippets.dox OrtStatus Return Value
   5886   *
   5887   * \since Version 1.21.
   5888   */
   5889  ORT_API2_STATUS(CreateTensorTypeInfo,
   5890                  _In_ const OrtTensorTypeAndShapeInfo* tensor_info,
   5891                  _Outptr_ OrtTypeInfo** type_info);
   5892 
   5893  /** \brief Create an OrtTypeInfo instance for a SparseTensor.
   5894   *
   5895   * Create an OrtTypeInfo instance for a SparseTensor to use as graph
   5896   * inputs/outputs with the Model Editor API.
   5897   *
   5898   * User can release `tensor_info` after creating the OrtTypeInfo.
   5899   *
   5900   * \param[in] tensor_info SparseTensor type and shape information.
   5901   * \param[out] TypeInfo instance for the tensor.
   5902   *
   5903   * \snippet{doc} snippets.dox OrtStatus Return Value
   5904   *
   5905   * \since Version 1.21.
   5906   */
   5907  ORT_API2_STATUS(CreateSparseTensorTypeInfo,
   5908                  _In_ const OrtTensorTypeAndShapeInfo* tensor_info,
   5909                  _Outptr_ OrtTypeInfo** type_info);
   5910 
   5911  /** \brief Create an OrtTypeInfo instance for a Map.
   5912   *
   5913   * Create an OrtTypeInfo instance for a Map to use as graph inputs/outputs
   5914   * with the Model Editor API.
   5915   *
   5916   * User can release `map_value_type` after creating the OrtTypeInfo.
   5917   *
   5918   * \param[in] map_key_type Key type for the map.
   5919   * \param[in] map_value_type Value type for the map.
   5920   * \param[out] TypeInfo instance for the map.
   5921   *
   5922   * \snippet{doc} snippets.dox OrtStatus Return Value
   5923   *
   5924   * \since Version 1.21.
   5925   */
   5926  ORT_API2_STATUS(CreateMapTypeInfo, ONNXTensorElementDataType map_key_type,
   5927                  _In_ const OrtTypeInfo* map_value_type,
   5928                  _Outptr_ OrtTypeInfo** type_info);
   5929 
   5930  /** \brief Create an OrtTypeInfo instance for a Sequence.
   5931   *
   5932   * Create an OrtTypeInfo instance for a Sequence to use as graph
   5933   * inputs/outputs with the Model Editor API.
   5934   *
   5935   * User can release `sequence_type` after creating the OrtTypeInfo.
   5936   *
   5937   * \param[in] sequence_type Sequence type and shape information.
   5938   * \param[out] TypeInfo instance for the sequence.
   5939   *
   5940   * \snippet{doc} snippets.dox OrtStatus Return Value
   5941   *
   5942   * \since Version 1.21.
   5943   */
   5944  ORT_API2_STATUS(CreateSequenceTypeInfo, _In_ const OrtTypeInfo* sequence_type,
   5945                  _Outptr_ OrtTypeInfo** type_info);
   5946 
   5947  /** \brief Create an OrtTypeInfo instance for an Optional.
   5948   *
   5949   * Create an OrtTypeInfo instance for an Optional to use as graph
   5950   * inputs/outputs with the Model Editor API.
   5951   *
   5952   * User can release `contained_type` after creating the OrtTypeInfo.
   5953   *
   5954   * \param[in] tensor_info Tensor type and shape information.
   5955   * \param[out] TypeInfo instance for the tensor.
   5956   *
   5957   * \snippet{doc} snippets.dox OrtStatus Return Value
   5958   *
   5959   * \since Version 1.21.
   5960   */
   5961  ORT_API2_STATUS(CreateOptionalTypeInfo,
   5962                  _In_ const OrtTypeInfo* contained_type,
   5963                  _Outptr_ OrtTypeInfo** type_info);
   5964 
   5965  /** \brief Create an OrtValueInfo for use as an OrtGraph input or output.
   5966   *
   5967   * \param[in] name The name of the input or output.
   5968   * \param[in] type_info The type information for the input or output. The
   5969   * provided value is copied.
   5970   *
   5971   * \snippet{doc} snippets.dox OrtStatus Return Value
   5972   *
   5973   * \since Version 1.21.
   5974   */
   5975  ORT_API2_STATUS(CreateValueInfo, _In_ const char* name,
   5976                  _In_ const OrtTypeInfo* type_info,
   5977                  _Outptr_ OrtValueInfo** value_info);
   5978 
   5979  /** \brief Create an OrtNode to add to an OrtGraph.
   5980   *
   5981   * Create an OrtNode.
   5982   *
   5983   * Create attributes with CreateOpAttr. OrtOpAttr instances are copied.
   5984   *
   5985   * \param[in] operator_name The name of the operator.
   5986   * \param[in] domain_name The domain of the operator. Use an empty string for
   5987   * ONNX operators.
   5988   * \param[in] node_name The name of the node.
   5989   * \param[in] input_names The names of the inputs.
   5990   * \param[in] input_names_len The number of input names.
   5991   * \param[in] output_names The names of the outputs.
   5992   * \param[in] output_names_len The number of output names.
   5993   * \param[in] attributes The optional attributes of the node.
   5994   * \param[in] attribs_len The number of attributes. May be zero.
   5995   * \param[out] node The OrtNode instance.
   5996   *
   5997   * \snippet{doc} snippets.dox OrtStatus Return Value
   5998   *
   5999   * \since Version 1.21.
   6000   */
   6001  ORT_API2_STATUS(CreateNode, _In_ const char* operator_name,
   6002                  _In_ const char* domain_name, _In_ const char* node_name,
   6003                  _In_reads_(input_names_len) const char* const* input_names,
   6004                  size_t input_names_len,
   6005                  _In_reads_(output_names_len) const char* const* output_names,
   6006                  size_t output_names_len,
   6007                  _In_reads_(attribs_len) _In_opt_ OrtOpAttr** attributes,
   6008                  _In_ size_t attribs_len, _Outptr_ OrtNode** node);
   6009 
   6010  /** \brief Create an OrtGraph
   6011   * \snippet{doc} snippets.dox OrtStatus Return Value
   6012   * \since Version 1.21.
   6013   */
   6014  ORT_API2_STATUS(CreateGraph, _Outptr_ OrtGraph** graph);
   6015 
   6016  /** \brief Set the inputs for the OrtGraph.
   6017   *
   6018   * Set the graph inputs. This will replace any existing inputs with the new
   6019   * values. The OrtGraph takes ownership of the OrtValueInfo instances and you
   6020   * should NOT call ReleaseOrtValueInfo.
   6021   *
   6022   * \param[in] graph The OrtGraph instance to update.
   6023   * \param[in] inputs The input OrtValueInfo instances.
   6024   * \param[in] inputs_len The number of input OrtValueInfo instances.
   6025   *
   6026   * \snippet{doc} snippets.dox OrtStatus Return Value
   6027   *
   6028   * \since Version 1.21.
   6029   */
   6030  ORT_API2_STATUS(SetGraphInputs, _Inout_ OrtGraph* graph,
   6031                  _In_reads_(inputs_len) _In_ OrtValueInfo** inputs,
   6032                  _In_ size_t inputs_len);
   6033 
   6034  /** \brief Set the outputs for the OrtGraph.
   6035   *
   6036   * Set the graph outputs. This will replace any existing outputs with the new
   6037   * values. The OrtGraph takes ownership of the OrtValueInfo instances provided
   6038   * and you should NOT call ReleaseOrtValueInfo.
   6039   *
   6040   * \param[in] graph The OrtGraph instance to update.
   6041   * \param[in] outputs The output OrtValueInfo instances.
   6042   * \param[in] outputs_len The number of output OrtValueInfo instances.
   6043   *
   6044   * \snippet{doc} snippets.dox OrtStatus Return Value
   6045   *
   6046   * \since Version 1.21.
   6047   */
   6048  ORT_API2_STATUS(SetGraphOutputs, _Inout_ OrtGraph* graph,
   6049                  _In_reads_(outputs_len) _In_ OrtValueInfo** outputs,
   6050                  _In_ size_t outputs_len);
   6051 
   6052  /** \brief Add an initializer to the OrtGraph
   6053   *
   6054   * ORT will take ownership of the OrtValue and you should NOT call
   6055   * ReleaseOrtValue.
   6056   *
   6057   * Two options:
   6058   *
   6059   * Allocated memory:
   6060   *    Use CreateTensorAsOrtValue (allocates memory) and populate the tensor
   6061   * with the data. Set `data_is_external` to false.
   6062   *
   6063   * Pre-existing memory:
   6064   *    Use CreateTensorWithDataAsOrtValue or
   6065   * CreateTensorWithDataAndDeleterAsOrtValue to create an OrtValue with a
   6066   * tensor that contains a pointer to the existing data. Set `data_is_external`
   6067   * to true.
   6068   *
   6069   *    The pointer must remain valid for the duration of the inference session.
   6070   *    If using CreateTensorWithDataAsOrtValue you are responsible for freeing
   6071   * the memory after the inference session is released. If using
   6072   * CreateTensorWithDataAndDeleterAsOrtValue, ORT will free the memory using
   6073   * the provided deleter as soon as the OrtValue is no longer in use.
   6074   *
   6075   *    NOTE: A tensor containing pre-existing memory MUST have 128 bytes of
   6076   * data or more. For smaller tensors use CreateTensorAsOrtValue.
   6077   *
   6078   *          ONNX shape inferencing does not support external data. An
   6079   * initializer involved in shape inferencing is typically small (a single
   6080   * value or limited by the rank of a tensor) and uses less than 128 bytes of
   6081   *          memory, so this limit acts as a simple catch-all rule to avoid
   6082   * issues. e.g. Reshape's `shape`, Clip's `min` and `max`, various ops `axes`.
   6083   *
   6084   * \param[in] graph The OrtGraph instance to update.
   6085   * \param[in] name The value name for the initializer.
   6086   * \param[in] tensor The OrtValue instance containing the tensor data.
   6087   * \param[in] data_is_external Set to true if the data is external and should
   6088   * not be copied.
   6089   *
   6090   * \snippet{doc} snippets.dox OrtStatus Return Value
   6091   *
   6092   * \since Version 1.21.
   6093   */
   6094  ORT_API2_STATUS(AddInitializerToGraph, _Inout_ OrtGraph* graph,
   6095                  _In_ const char* name, _In_ OrtValue* tensor,
   6096                  bool data_is_external);
   6097 
   6098  /** \brief Add an OrtNode to an OrtGraph
   6099   *
   6100   * Add the node to the graph. The OrtGraph will take ownership of OrtNode and
   6101   * you should NOT call ReleaseOrtNode.
   6102   *
   6103   * \param[in] graph The OrtGraph instance to update.
   6104   * \param[in] node The OrtNode instance to add to the graph.
   6105   *
   6106   * \snippet{doc} snippets.dox OrtStatus Return Value
   6107   *
   6108   * \since Version 1.21.
   6109   */
   6110  ORT_API2_STATUS(AddNodeToGraph, _Inout_ OrtGraph* graph, _In_ OrtNode* node);
   6111 
   6112  /** \brief Create an OrtModel.
   6113   *
   6114   * Create an OrtModel.
   6115   *
   6116   * This can be used to build a new model, or to augment an existing model.
   6117   *
   6118   * \param[in] domain_names The domain names for the model.
   6119   *                         If augmenting an existing model add additional
   6120   * domains if needed.
   6121   * \param[in] opset_versions The opset versions for the model.
   6122   *                           If augmenting an existing model add additional
   6123   * opset versions if needed.
   6124   * \param[in] opset_entries_len The number of domain_names and opset_versions
   6125   * entries. Domain and opset entries should be 1:1
   6126   *
   6127   * \snippet{doc} snippets.dox OrtStatus Return Value
   6128   *
   6129   * \since Version 1.21.
   6130   */
   6131  ORT_API2_STATUS(CreateModel,
   6132                  _In_reads_(opset_entries_len) const char* const* domain_names,
   6133                  _In_reads_(opset_entries_len) const int* opset_versions,
   6134                  size_t opset_entries_len, _Outptr_ OrtModel** model);
   6135 
   6136  /** \brief Add an OrtGraph to an OrtModel.
   6137   *
   6138   * Add the graph to a model. This should be called once when creating a new
   6139   * model.
   6140   *
   6141   * The OrtModel takes ownership of the OrtGraph and you should NOT call
   6142   * ReleaseOrtGraph.
   6143   *
   6144   * \param[in] model The OrtModel instance to update.
   6145   * \param[in] graph The OrtGraph instance to add to the model.
   6146   *
   6147   * \snippet{doc} snippets.dox OrtStatus Return Value
   6148   *
   6149   * \since Version 1.21.
   6150   */
   6151  ORT_API2_STATUS(AddGraphToModel, _Inout_ OrtModel* model,
   6152                  _In_ OrtGraph* graph);
   6153 
   6154  /** \brief Create an OrtSession using the OrtModel.
   6155   *
   6156   * Create an inference session using the OrtModel instance.
   6157   * The OrtModel should have been populated with an OrtGraph containing nodes
   6158   * and initializers, and SetGraphInputs and SetGraphOutputs must have been
   6159   * called. This will validate the model, run optimizers, and prepare the
   6160   * session for inferencing.
   6161   *
   6162   * ReleaseOrtModel must be called to free the OrtModel after session creation.
   6163   *
   6164   * \param[in] env The OrtEnv instance.
   6165   * \param[in] model The OrtModel instance.
   6166   * \param[in] options The OrtSessionOptions instance.
   6167   * \param[out] out The OrtSession instance.
   6168   *
   6169   * \snippet{doc} snippets.dox OrtStatus Return Value
   6170   *
   6171   * \since Version 1.21.
   6172   */
   6173  ORT_API2_STATUS(CreateSessionFromModel, _In_ const OrtEnv* env,
   6174                  _In_ const OrtModel* model,
   6175                  _In_ const OrtSessionOptions* options,
   6176                  _Outptr_ OrtSession** out);
   6177 
   6178  /** \brief Create an OrtSession to augment an existing model.
   6179   *
   6180   * Create an OrtSession with an existing model that will be augmented with
   6181   * additional nodes and initializers. Nodes can be added before or after the
   6182   * existing nodes in the model. ONNX Runtime will connect the nodes when the
   6183   * model is finalized.
   6184   *
   6185   * To add nodes and initializers to the existing model, first create an
   6186   * OrtModel using CreateModel. Add nodes and initializers to the OrtModel
   6187   * using AddNodeToGraph and AddInitializerToGraph. Graph inputs/outputs should
   6188   * be updated with SetGraphInputs and SetGraphOutputs as needed to reflect
   6189   * changes made by the new nodes. The list of graph inputs/outputs should be
   6190   * for the overall model and not just the new nodes.
   6191   *
   6192   * Add the new information from the OrtModel to the original model using
   6193   * ApplyModelToSession, and prepare the session for inferencing by calling
   6194   * FinalizeModelEditorSession.
   6195   *
   6196   * \param{in} env The OrtEnv instance.
   6197   * \param{in} model_path The path to the existing ONNX model to augment.
   6198   * \param{in} options The OrtSessionOptions instance.
   6199   * \param{out} out The created OrtSession instance.
   6200   * \snippet{doc} snippets.dox OrtStatus Return Value
   6201   *
   6202   * \since Version 1.21.
   6203   */
   6204  ORT_API2_STATUS(CreateModelEditorSession, _In_ const OrtEnv* env,
   6205                  _In_ const ORTCHAR_T* model_path,
   6206                  _In_ const OrtSessionOptions* options,
   6207                  _Outptr_ OrtSession** out);
   6208 
   6209  /** \brief Create an OrtSession to augment an existing model.
   6210   *
   6211   * Create an OrtSession with an existing model that will be augmented with
   6212   * additional nodes and initializers. Nodes can be added before or after the
   6213   * existing nodes in the model. ONNX Runtime will connect the nodes when the
   6214   * model is finalized.
   6215   *
   6216   * To add nodes and initializers to the existing model, first create an
   6217   * OrtModel using CreateModel. Add nodes and initializers to the OrtModel
   6218   * using AddNodeToGraph and AddInitializerToGraph. Graph inputs/outputs should
   6219   * be updated with SetGraphInputs and SetGraphOutputs as needed to reflect
   6220   * changes made by the new nodes. The list of graph inputs/outputs should be
   6221   * for the overall model and not just the new nodes.
   6222   *
   6223   * Add the new information from the OrtModel to the original model using
   6224   * ApplyModelToSession, and prepare the session for inferencing by calling
   6225   * FinalizeModelEditorSession.
   6226   *
   6227   * \param{in} env The OrtEnv instance.
   6228   * \param{in} model_data The model data for the existing model to augment.
   6229   * \param{in} model_data_length The length of the model data.
   6230   * \param{in} options The OrtSessionOptions instance.
   6231   *
   6232   * \snippet{doc} snippets.dox OrtStatus Return Value
   6233   *
   6234   * \since Version 1.21.
   6235   */
   6236  ORT_API2_STATUS(CreateModelEditorSessionFromArray, _In_ const OrtEnv* env,
   6237                  _In_ const void* model_data, size_t model_data_length,
   6238                  _In_ const OrtSessionOptions* options,
   6239                  _Outptr_ OrtSession** out);
   6240 
   6241  /** \brief Query the session for the opset version of a domain.
   6242   *
   6243   * When using the Model Editor API to augment a model, any new nodes must
   6244   * conform to the opset version of the original model. To do that the user
   6245   * must be able to discover that opset version.
   6246   *
   6247   * \param[in] session OrtSession to query
   6248   * \param[in] domain Domain to query. The ONNX domain is an empty string.
   6249   * \param[out] opset The opset version of the domain.
   6250   *
   6251   * \snippet{doc} snippets.dox OrtStatus Return Value. Returns an error if the
   6252   * domain is not used in the model.
   6253   *
   6254   * \since Version 1.21.
   6255   */
   6256  ORT_API2_STATUS(SessionGetOpsetForDomain, _In_ const OrtSession* session,
   6257                  _In_ const char* domain, _Out_ int* opset);
   6258 
   6259  /** \brief Apply changes to augment the ONNX model in a session created using
   6260   * CreateModelEditorSession[FromArray]
   6261   *
   6262   * Adds new nodes and updates graph inputs/outputs using `model` to augment
   6263   * the original ONNX model in the session. All changes will be validated. Call
   6264   * FinalizeModelEditorSession to prepare the session for inferencing.
   6265   *
   6266   * Existing input/outputs will only be updated if the OrtGraph inputs/outputs
   6267   * are set in the OrtModel. i.e. you don't need to call
   6268   * SetGraphInputs/SetGraphOutputs if they are unchanged.
   6269   *
   6270   * ReleaseOrtModel must be called to free the OrtModel after it is applied to
   6271   * the session.
   6272   *
   6273   * \param[in] session OrtSession to update. Session must have been created
   6274   * using CreateModelEditorSession[FromArray].
   6275   * \param[in] model OrtModel containing new nodes, new initializers, and
   6276   * updated graph input and/or output info.
   6277   *
   6278   * \snippet{doc} snippets.dox OrtStatus Return Value
   6279   *
   6280   * \since Version 1.21.
   6281   */
   6282  ORT_API2_STATUS(ApplyModelToModelEditorSession, _Inout_ OrtSession* session,
   6283                  _In_ OrtModel* model);
   6284 
   6285  /** \brief Finalize the Model Editor session that was created using
   6286   CreateModelEditorSession[FromArray].
   6287   *
   6288   * Finalize the Model Editor session that augmented an ONNX model by adding
   6289   new nodes.
   6290   * This will run optimizers and prepare the session for inferencing.
   6291   *
   6292   * \param[in] session OrtSession to finalize. Session must have been created
   6293   using CreateModelEditorSession[FromArray].
   6294   * \param[in] options OrtSessionOptions to use for the session.
   6295   * \param[in] Optional prepacked_weights_container
   6296   OrtPrepackedWeightsContainer to use for the session. Set to nullptr if not
   6297   used.
   6298   * \snippet{doc} snippets.dox OrtStatus Return Value
   6299   *
   6300   * \since Version 1.21.
   6301   */
   6302  ORT_API2_STATUS(
   6303      FinalizeModelEditorSession, _Inout_ OrtSession* session,
   6304      _In_ const OrtSessionOptions* options,
   6305      _In_opt_ OrtPrepackedWeightsContainer* prepacked_weights_container);
   6306 #endif  // !defined(ORT_MINIMAL_BUILD)
   6307 };
   6308 
   6309 /*
   6310 * This is the old way to add the CUDA provider to the session, please use
   6311 * SessionOptionsAppendExecutionProvider_CUDA above to access the latest
   6312 * functionality This function always exists, but will only succeed if
   6313 * Onnxruntime was built with CUDA support and the CUDA provider shared library
   6314 * exists
   6315 *
   6316 * \param device_id CUDA device id, starts from zero.
   6317 */
   6318 ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA,
   6319               _In_ OrtSessionOptions* options, int device_id);
   6320 
   6321 /*
   6322 * This is the old way to add the ROCm provider to the session, please use
   6323 * SessionOptionsAppendExecutionProvider_ROCM above to access the latest
   6324 * functionality This function always exists, but will only succeed if
   6325 * Onnxruntime was built with HIP support and the ROCm provider shared library
   6326 * exists
   6327 *
   6328 * \param device_id HIP device id, starts from zero.
   6329 */
   6330 ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_ROCM,
   6331               _In_ OrtSessionOptions* options, int device_id);
   6332 
   6333 /*
   6334 * This is the old way to add the MIGraphX provider to the session, please use
   6335 * SessionOptionsAppendExecutionProvider_MIGraphX above to access the latest
   6336 * functionality This function always exists, but will only succeed if
   6337 * Onnxruntime was built with HIP support and the MIGraphX provider shared
   6338 * library exists
   6339 *
   6340 * \param device_id HIP device id, starts from zero.
   6341 */
   6342 ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_MIGraphX,
   6343               _In_ OrtSessionOptions* options, int device_id);
   6344 
   6345 /*
   6346 * This is the old way to add the oneDNN provider to the session, please use
   6347 * SessionOptionsAppendExecutionProvider_oneDNN above to access the latest
   6348 * functionality This function always exists, but will only succeed if
   6349 * Onnxruntime was built with oneDNN support and the oneDNN provider shared
   6350 * library exists
   6351 *
   6352 * \param use_arena zero: false. non-zero: true.
   6353 */
   6354 ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Dnnl,
   6355               _In_ OrtSessionOptions* options, int use_arena);
   6356 
   6357 /*
   6358 * This is the old way to add the TensorRT provider to the session, please use
   6359 * SessionOptionsAppendExecutionProvider_TensorRT_V2 above to access the latest
   6360 * functionality This function always exists, but will only succeed if
   6361 * Onnxruntime was built with TensorRT support and the TensorRT provider shared
   6362 * library exists
   6363 *
   6364 * \param device_id CUDA device id, starts from zero.
   6365 */
   6366 ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_Tensorrt,
   6367               _In_ OrtSessionOptions* options, int device_id);
   6368 
   6369 #ifdef __cplusplus
   6370 }
   6371 #endif
   6372 /// @}