16#include "onnxruntime_c_api.h"
23#include <unordered_map>
27#ifdef ORT_NO_EXCEPTIONS
44 const char*
what() const noexcept
override {
return message_.c_str(); }
51#ifdef ORT_NO_EXCEPTIONS
54#ifndef ORT_CXX_API_THROW
55#define ORT_CXX_API_THROW(string, code) \
57 std::cerr << Ort::Exception(string, code) \
64#define ORT_CXX_API_THROW(string, code) \
65 throw Ort::Exception(string, code)
77#ifdef ORT_API_MANUAL_INIT
81#if defined(_MSC_VER) && !defined(__clang__)
85#pragma warning(disable : 26426)
88#if defined(_MSC_VER) && !defined(__clang__)
101#define ORT_DEFINE_RELEASE(NAME) \
102 inline void OrtRelease(Ort##NAME* ptr) { GetApi().Release##NAME(ptr); }
117ORT_DEFINE_RELEASE(ThreadingOptions);
121#undef ORT_DEFINE_RELEASE
166 constexpr operator uint16_t() const noexcept {
return value; }
171static_assert(
sizeof(Float16_t) ==
sizeof(uint16_t),
"Sizes must match");
185 constexpr operator uint16_t() const noexcept {
return value; }
190static_assert(
sizeof(BFloat16_t) ==
sizeof(uint16_t),
"Sizes must match");
206 ORT_CXX_API_THROW(
"Allocation failure",
ORT_FAIL);
210 operator T*() {
return p_; }
211 operator const T*()
const {
return p_; }
241 Unowned(
typename T::contained_type* p) : T{p} {}
246struct AllocatorWithDefaultOptions;
277 explicit Env(std::nullptr_t) {}
392 const std::unordered_map<std::string, std::string>& provider_options = {});
539 std::vector<Value>
Run(
const RunOptions& run_options,
const char*
const* input_names,
const Value* input_values,
size_t input_count,
540 const char*
const* output_names,
size_t output_count);
545 void Run(
const RunOptions& run_options,
const char*
const* input_names,
const Value* input_values,
size_t input_count,
546 const char*
const* output_names,
Value* output_values,
size_t output_count);
706 template <
typename T>
720#if !defined(DISABLE_SPARSE_TENSORS)
731 template <
typename T>
733 const Shape& values_shape);
774 void UseCsrIndices(int64_t* inner_data,
size_t inner_num, int64_t* outer_data,
size_t outer_num);
794 template <
typename T>
805#if !defined(DISABLE_SPARSE_TENSORS)
815 template <
typename T>
841 const int64_t* indices_data,
size_t indices_num);
856 const int64_t* inner_indices_data,
size_t inner_indices_num,
857 const int64_t* outer_indices_data,
size_t outer_indices_num);
870 const Shape& indices_shape,
871 const int32_t* indices_data);
906 template <
typename T>
914 template <
typename T>
917 template <
typename T>
928#if !defined(DISABLE_SPARSE_TENSORS)
963 template <
typename T>
966 template <
typename T>
969#if !defined(DISABLE_SPARSE_TENSORS)
978 template <
typename T>
982 template <
typename T>
983 T&
At(
const std::vector<int64_t>& location);
1033 size_t size()
const {
return size_; }
1098 std::vector<std::string> GetOutputNamesHelper(
OrtAllocator*)
const;
1099 std::vector<Value> GetOutputValuesHelper(
OrtAllocator*)
const;
1116 ArenaCfg(
size_t max_mem,
int arena_extend_strategy,
int initial_chunk_size_bytes,
int max_dead_bytes_per_chunk);
1126 template <
typename T>
1136 template <
typename T>
1138 template <
typename T>
1154 _In_
const void* data,
1161 _In_
const char* op_name,
1162 _In_
const char* domain,
1164 _In_opt_
const char** type_constraint_names,
1166 _In_opt_
int type_constraint_count,
1167 _In_opt_
const OrtOpAttr*
const* attr_values,
1168 _In_opt_
int attr_count,
1169 _In_
int input_count,
1170 _In_
int output_count);
1173 _In_
const OrtOp* ort_op,
1174 _In_
const OrtValue*
const* input_values,
1175 _In_
int input_count,
1176 _Inout_
OrtValue*
const* output_values,
1177 _In_
int output_count);
1189template <
typename TOp,
typename TKernel>
1205#if defined(_MSC_VER) && !defined(__clang__)
1206#pragma warning(push)
1207#pragma warning(disable : 26409)
1210#if defined(_MSC_VER) && !defined(__clang__)
1233#include "onnxruntime_cxx_inline.h"
struct OrtMemoryInfo OrtMemoryInfo
Definition: onnxruntime_c_api.h:252
struct OrtKernelInfo OrtKernelInfo
Definition: onnxruntime_c_api.h:327
OrtLoggingLevel
Logging severity levels.
Definition: onnxruntime_c_api.h:207
void(* OrtLoggingFunction)(void *param, OrtLoggingLevel severity, const char *category, const char *logid, const char *code_location, const char *message)
Definition: onnxruntime_c_api.h:292
void(* OrtCustomJoinThreadFn)(OrtCustomThreadHandle ort_custom_thread_handle)
Custom thread join function.
Definition: onnxruntime_c_api.h:586
OrtCustomOpInputOutputCharacteristic
Definition: onnxruntime_c_api.h:3515
struct OrtTensorRTProviderOptionsV2 OrtTensorRTProviderOptionsV2
Definition: onnxruntime_c_api.h:268
struct OrtOpAttr OrtOpAttr
Definition: onnxruntime_c_api.h:271
struct OrtThreadingOptions OrtThreadingOptions
Definition: onnxruntime_c_api.h:265
struct OrtSequenceTypeInfo OrtSequenceTypeInfo
Definition: onnxruntime_c_api.h:262
OrtSparseIndicesFormat
Definition: onnxruntime_c_api.h:196
struct OrtPrepackedWeightsContainer OrtPrepackedWeightsContainer
Definition: onnxruntime_c_api.h:267
struct OrtCustomOpDomain OrtCustomOpDomain
Definition: onnxruntime_c_api.h:260
OrtAllocatorType
Definition: onnxruntime_c_api.h:333
struct OrtOp OrtOp
Definition: onnxruntime_c_api.h:270
struct OrtModelMetadata OrtModelMetadata
Definition: onnxruntime_c_api.h:263
struct OrtTypeInfo OrtTypeInfo
Definition: onnxruntime_c_api.h:257
struct OrtTensorTypeAndShapeInfo OrtTensorTypeAndShapeInfo
Definition: onnxruntime_c_api.h:258
struct OrtCUDAProviderOptionsV2 OrtCUDAProviderOptionsV2
Definition: onnxruntime_c_api.h:269
struct OrtKernelContext OrtKernelContext
Definition: onnxruntime_c_api.h:329
struct OrtSessionOptions OrtSessionOptions
Definition: onnxruntime_c_api.h:259
struct OrtValue OrtValue
Definition: onnxruntime_c_api.h:255
GraphOptimizationLevel
Graph optimization level.
Definition: onnxruntime_c_api.h:301
OrtMemType
Memory types for allocated memory, execution provider specific types should be extended in each provi...
Definition: onnxruntime_c_api.h:342
OrtSparseFormat
Definition: onnxruntime_c_api.h:188
ONNXType
Definition: onnxruntime_c_api.h:176
struct OrtEnv OrtEnv
Definition: onnxruntime_c_api.h:250
OrtErrorCode
Definition: onnxruntime_c_api.h:215
struct OrtStatus OrtStatus
Definition: onnxruntime_c_api.h:251
#define ORT_API_VERSION
The API version defined in this header.
Definition: onnxruntime_c_api.h:33
struct OrtMapTypeInfo OrtMapTypeInfo
Definition: onnxruntime_c_api.h:261
struct OrtArenaCfg OrtArenaCfg
Definition: onnxruntime_c_api.h:266
ExecutionMode
Definition: onnxruntime_c_api.h:308
OrtOpAttrType
Definition: onnxruntime_c_api.h:230
OrtCustomThreadHandle(* OrtCustomCreateThreadFn)(void *ort_custom_thread_creation_options, OrtThreadWorkerFn ort_thread_worker_fn, void *ort_worker_fn_param)
Ort custom thread creation function.
Definition: onnxruntime_c_api.h:579
ONNXTensorElementDataType
Definition: onnxruntime_c_api.h:155
const OrtApiBase * OrtGetApiBase(void)
The Onnxruntime library's entry point to access the C API.
@ ORT_LOGGING_LEVEL_WARNING
Warning messages.
Definition: onnxruntime_c_api.h:210
@ INPUT_OUTPUT_REQUIRED
Definition: onnxruntime_c_api.h:3517
@ ORT_FAIL
Definition: onnxruntime_c_api.h:217
All C++ Onnxruntime APIs are defined inside this namespace.
Definition: onnxruntime_cxx_api.h:34
std::unique_ptr< char, detail::AllocatedFree > AllocatedStringPtr
unique_ptr typedef used to own strings allocated by OrtAllocators and release them at the end of the ...
Definition: onnxruntime_cxx_api.h:269
const OrtApi & GetApi()
This returns a reference to the OrtApi interface in use.
Definition: onnxruntime_cxx_api.h:94
void OrtRelease(OrtAllocator *ptr)
Definition: onnxruntime_cxx_api.h:104
std::vector< std::string > GetAvailableProviders()
This is a C++ wrapper for OrtApi::GetAvailableProviders() and returns a vector of strings representin...
Definition: onnxruntime_cxx_api.h:1073
MemoryAllocation GetAllocation(size_t size)
void * Alloc(size_t size) const
Unowned< const MemoryInfo > GetInfo() const
Allocator(const Session &session, const MemoryInfo &)
Definition: onnxruntime_cxx_api.h:1041
const OrtMemoryInfo * GetInfo() const
void * Alloc(size_t size)
AllocatorWithDefaultOptions()
MemoryAllocation GetAllocation(size_t size)
it is a structure that represents the configuration of an arena based allocator
Definition: onnxruntime_cxx_api.h:1106
ArenaCfg(std::nullptr_t)
Create an empty ArenaCfg object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:1107
ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk)
bfloat16 (Brain Floating Point) data type
Definition: onnxruntime_cxx_api.h:181
uint16_t value
Definition: onnxruntime_cxx_api.h:182
constexpr bool operator!=(const BFloat16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:187
constexpr BFloat16_t(uint16_t v) noexcept
Definition: onnxruntime_cxx_api.h:184
constexpr bool operator==(const BFloat16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:186
constexpr BFloat16_t() noexcept
Definition: onnxruntime_cxx_api.h:183
Used internally by the C++ API. C++ wrapper types inherit from this.
Definition: onnxruntime_cxx_api.h:200
Base & operator=(const Base &)=delete
T * release()
Releases ownership of the contained pointer.
Definition: onnxruntime_cxx_api.h:214
~Base()
Definition: onnxruntime_cxx_api.h:208
Base(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:223
T * p_
Definition: onnxruntime_cxx_api.h:229
Base(const Base &)=delete
Base(T *p)
Definition: onnxruntime_cxx_api.h:204
void operator=(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:224
T contained_type
Definition: onnxruntime_cxx_api.h:201
Definition: onnxruntime_cxx_api.h:1123
size_t KernelContext_GetOutputCount(const OrtKernelContext *context)
size_t GetDimensionsCount(const OrtTensorTypeAndShapeInfo *info)
void * KernelContext_GetGPUComputeStream(const OrtKernelContext *context)
size_t KernelContext_GetInputCount(const OrtKernelContext *context)
void InvokeOp(const OrtKernelContext *context, const OrtOp *ort_op, const OrtValue *const *input_values, int input_count, OrtValue *const *output_values, int output_count)
OrtOpAttr * CreateOpAttr(const char *name, const void *data, int len, OrtOpAttrType type)
void ReleaseOp(OrtOp *ort_op)
OrtValue * KernelContext_GetOutput(OrtKernelContext *context, size_t index, const int64_t *dim_values, size_t dim_count)
void ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo *input)
T KernelInfoGetAttribute(const OrtKernelInfo *info, const char *name)
OrtTensorTypeAndShapeInfo * GetTensorTypeAndShape(const OrtValue *value)
std::vector< int64_t > GetTensorShape(const OrtTensorTypeAndShapeInfo *info)
void GetDimensions(const OrtTensorTypeAndShapeInfo *info, int64_t *dim_values, size_t dim_values_length)
void ReleaseOpAttr(OrtOpAttr *op_attr)
void ThrowOnError(OrtStatus *result)
size_t GetTensorShapeElementCount(const OrtTensorTypeAndShapeInfo *info)
ONNXTensorElementDataType GetTensorElementType(const OrtTensorTypeAndShapeInfo *info)
OrtOp * CreateOp(const OrtKernelInfo *info, const char *op_name, const char *domain, int version, const char **type_constraint_names, const ONNXTensorElementDataType *type_constraint_values, int type_constraint_count, const OrtOpAttr *const *attr_values, int attr_count, int input_count, int output_count)
CustomOpApi(const OrtApi &api)
Definition: onnxruntime_cxx_api.h:1124
void SetDimensions(OrtTensorTypeAndShapeInfo *info, const int64_t *dim_values, size_t dim_count)
OrtKernelInfo * CopyKernelInfo(const OrtKernelInfo *info)
void ReleaseKernelInfo(OrtKernelInfo *info_copy)
T * GetTensorMutableData(OrtValue *value)
const OrtValue * KernelContext_GetInput(const OrtKernelContext *context, size_t index)
const OrtMemoryInfo * GetTensorMemoryInfo(const OrtValue *value)
const T * GetTensorData(const OrtValue *value)
Definition: onnxruntime_cxx_api.h:1190
OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t) const
Definition: onnxruntime_cxx_api.h:1226
CustomOpBase()
Definition: onnxruntime_cxx_api.h:1191
const char * GetExecutionProviderType() const
Definition: onnxruntime_cxx_api.h:1218
OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t) const
Definition: onnxruntime_cxx_api.h:1222
Custom Op Domain.
Definition: onnxruntime_cxx_api.h:304
CustomOpDomain(std::nullptr_t)
Create an empty CustomOpDomain object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:305
CustomOpDomain(const char *domain)
Wraps OrtApi::CreateCustomOpDomain.
void Add(OrtCustomOp *op)
Wraps CustomOpDomain_Add.
The Env (Environment)
Definition: onnxruntime_cxx_api.h:276
Env & EnableTelemetryEvents()
Wraps OrtApi::EnableTelemetryEvents.
Env(OrtEnv *p)
C Interop Helper.
Definition: onnxruntime_cxx_api.h:293
Env(std::nullptr_t)
Create an empty Env object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:277
Env(OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnv.
Env(const OrtThreadingOptions *tp_options, OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnvWithGlobalThreadPools.
Env(const OrtThreadingOptions *tp_options, OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnvWithCustomLoggerAndGlobalThreadPools.
Env(OrtLoggingLevel logging_level, const char *logid, OrtLoggingFunction logging_function, void *logger_param)
Wraps OrtApi::CreateEnvWithCustomLogger.
Env & CreateAndRegisterAllocator(const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg)
Wraps OrtApi::CreateAndRegisterAllocator.
Env & DisableTelemetryEvents()
Wraps OrtApi::DisableTelemetryEvents.
All C++ methods that can fail will throw an exception of this type.
Definition: onnxruntime_cxx_api.h:40
const char * what() const noexcept override
Definition: onnxruntime_cxx_api.h:44
OrtErrorCode GetOrtErrorCode() const
Definition: onnxruntime_cxx_api.h:43
Exception(std::string &&string, OrtErrorCode code)
Definition: onnxruntime_cxx_api.h:41
IEEE 754 half-precision floating point data type.
Definition: onnxruntime_cxx_api.h:162
constexpr bool operator!=(const Float16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:168
constexpr Float16_t(uint16_t v) noexcept
Definition: onnxruntime_cxx_api.h:165
uint16_t value
Definition: onnxruntime_cxx_api.h:163
constexpr bool operator==(const Float16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:167
constexpr Float16_t() noexcept
Definition: onnxruntime_cxx_api.h:164
Definition: onnxruntime_cxx_api.h:71
static const OrtApi * api_
Definition: onnxruntime_cxx_api.h:72
Definition: onnxruntime_cxx_api.h:1083
void BindInput(const char *name, const Value &)
std::vector< Value > GetOutputValues() const
void SynchronizeOutputs()
std::vector< std::string > GetOutputNames() const
std::vector< Value > GetOutputValues(Allocator &) const
std::vector< std::string > GetOutputNames(Allocator &) const
void BindOutput(const char *name, const MemoryInfo &)
void BindOutput(const char *name, const Value &)
IoBinding(Session &session)
Wrapper around OrtMapTypeInfo.
Definition: onnxruntime_cxx_api.h:654
ONNXTensorElementDataType GetMapKeyType() const
Wraps OrtApi::GetMapKeyType.
TypeInfo GetMapValueType() const
Wraps OrtApi::GetMapValueType.
MapTypeInfo(OrtMapTypeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:656
MapTypeInfo(std::nullptr_t)
Create an empty MapTypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:655
Definition: onnxruntime_cxx_api.h:1024
MemoryAllocation(MemoryAllocation &&) noexcept
MemoryAllocation & operator=(const MemoryAllocation &)=delete
void * get()
Definition: onnxruntime_cxx_api.h:1032
MemoryAllocation(const MemoryAllocation &)=delete
MemoryAllocation(OrtAllocator *allocator, void *p, size_t size)
size_t size() const
Definition: onnxruntime_cxx_api.h:1033
Definition: onnxruntime_cxx_api.h:1058
OrtAllocatorType GetAllocatorType() const
MemoryInfo(const char *name, OrtAllocatorType type, int id, OrtMemType mem_type)
MemoryInfo(std::nullptr_t)
Definition: onnxruntime_cxx_api.h:1061
MemoryInfo(OrtMemoryInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:1062
static MemoryInfo CreateCpu(OrtAllocatorType type, OrtMemType mem_type1)
std::string GetAllocatorName() const
bool operator==(const MemoryInfo &o) const
OrtMemType GetMemoryType() const
Definition: onnxruntime_cxx_api.h:313
int GetRunLogSeverityLevel() const
Wraps OrtApi::RunOptionsGetRunLogSeverityLevel.
RunOptions & SetTerminate()
Terminates all currently executing Session::Run calls that were made using this RunOptions instance.
RunOptions & SetRunTag(const char *run_tag)
wraps OrtApi::RunOptionsSetRunTag
RunOptions & UnsetTerminate()
Clears the terminate flag so this RunOptions instance can be used in a new Session::Run call without ...
int GetRunLogVerbosityLevel() const
Wraps OrtApi::RunOptionsGetRunLogVerbosityLevel.
RunOptions(std::nullptr_t)
Create an empty RunOptions object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:314
RunOptions & SetRunLogVerbosityLevel(int)
Wraps OrtApi::RunOptionsSetRunLogVerbosityLevel.
RunOptions & SetRunLogSeverityLevel(int)
Wraps OrtApi::RunOptionsSetRunLogSeverityLevel.
RunOptions & AddConfigEntry(const char *config_key, const char *config_value)
Wraps OrtApi::AddRunConfigEntry.
const char * GetRunTag() const
Wraps OrtApi::RunOptionsGetRunTag.
RunOptions()
Wraps OrtApi::CreateRunOptions.
Wrapper around OrtSequenceTypeInfo.
Definition: onnxruntime_cxx_api.h:644
TypeInfo GetSequenceElementType() const
Wraps OrtApi::GetSequenceElementType.
SequenceTypeInfo(std::nullptr_t)
Create an empty SequenceTypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:645
SequenceTypeInfo(OrtSequenceTypeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:646
Wrapper around OrtSession.
Definition: onnxruntime_cxx_api.h:514
Session(Env &env, const char *model_path, const SessionOptions &options)
Wraps OrtApi::CreateSession.
char * GetInputName(size_t index, OrtAllocator *allocator) const
Wraps OrtApi::SessionGetInputName.
char * GetOutputName(size_t index, OrtAllocator *allocator) const
Wraps OrtApi::SessionGetOutputName.
size_t GetInputCount() const
Returns the number of model inputs.
Session(Env &env, const char *model_path, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer.
Session(std::nullptr_t)
Create an empty Session object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:515
TypeInfo GetOutputTypeInfo(size_t index) const
Wraps OrtApi::SessionGetOutputTypeInfo.
ModelMetadata GetModelMetadata() const
Wraps OrtApi::SessionGetModelMetadata.
AllocatedStringPtr GetOverridableInitializerNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of the overridable initializer name at then specified index.
void Run(const RunOptions &run_options, const char *const *input_names, const Value *input_values, size_t input_count, const char *const *output_names, Value *output_values, size_t output_count)
Run the model returning results in user provided outputs Same as Run(const RunOptions&,...
size_t GetOverridableInitializerCount() const
Returns the number of inputs that have defaults that can be overridden.
size_t GetOutputCount() const
Returns the number of model outputs.
AllocatedStringPtr GetOutputNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of output name at then specified index.
Session(Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options)
Wraps OrtApi::CreateSessionFromArray.
uint64_t GetProfilingStartTimeNs() const
Wraps OrtApi::SessionGetProfilingStartTimeNs.
char * EndProfiling(OrtAllocator *allocator) const
Wraps OrtApi::SessionEndProfiling.
TypeInfo GetInputTypeInfo(size_t index) const
Wraps OrtApi::SessionGetInputTypeInfo.
char * GetOverridableInitializerName(size_t index, OrtAllocator *allocator) const
Wraps OrtApi::SessionGetOverridableInitializerName.
TypeInfo GetOverridableInitializerTypeInfo(size_t index) const
Wraps OrtApi::SessionGetOverridableInitializerTypeInfo.
AllocatedStringPtr EndProfilingAllocated(OrtAllocator *allocator) const
Returns a copy of the profiling file name.
AllocatedStringPtr GetInputNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of input name at the specified index.
void Run(const RunOptions &run_options, const struct IoBinding &)
Wraps OrtApi::RunWithBinding.
std::vector< Value > Run(const RunOptions &run_options, const char *const *input_names, const Value *input_values, size_t input_count, const char *const *output_names, size_t output_count)
Run the model returning results in an Ort allocated vector.
Session(Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
Wraps OrtApi::CreateSessionFromArrayWithPrepackedWeightsContainer.
Options object used when creating a new Session object.
Definition: onnxruntime_cxx_api.h:346
SessionOptions & SetGraphOptimizationLevel(GraphOptimizationLevel graph_optimization_level)
Wraps OrtApi::SetSessionGraphOptimizationLevel.
SessionOptions & EnableMemPattern()
Wraps OrtApi::EnableMemPattern.
SessionOptions & AddConfigEntry(const char *config_key, const char *config_value)
Wraps OrtApi::AddSessionConfigEntry.
SessionOptions & AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT.
SessionOptions & SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn)
Wraps OrtApi::SessionOptionsSetCustomCreateThreadFn.
SessionOptions & SetIntraOpNumThreads(int intra_op_num_threads)
Wraps OrtApi::SetIntraOpNumThreads.
SessionOptions & DisableProfiling()
Wraps OrtApi::DisableProfiling.
SessionOptions & DisablePerSessionThreads()
Wraps OrtApi::DisablePerSessionThreads.
SessionOptions & AddExternalInitializers(const std::vector< std::string > &names, const std::vector< Value > &ort_values)
Wraps OrtApi::AddExternalInitializers.
SessionOptions Clone() const
Creates and returns a copy of this SessionOptions object. Wraps OrtApi::CloneSessionOptions.
SessionOptions(std::nullptr_t)
Create an empty SessionOptions object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:347
SessionOptions & AppendExecutionProvider_CUDA_V2(const OrtCUDAProviderOptionsV2 &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA_V2.
SessionOptions & EnableOrtCustomOps()
Wraps OrtApi::EnableOrtCustomOps.
SessionOptions & AppendExecutionProvider(const std::string &provider_name, const std::unordered_map< std::string, std::string > &provider_options={})
Wraps OrtApi::SessionOptionsAppendExecutionProvider. Currently supports SNPE and XNNPACK.
SessionOptions()
Wraps OrtApi::CreateSessionOptions.
SessionOptions & EnableProfiling(const char *profile_file_prefix)
Wraps OrtApi::EnableProfiling.
SessionOptions & SetOptimizedModelFilePath(const char *optimized_model_file)
Wraps OrtApi::SetOptimizedModelFilePath.
SessionOptions & EnableCpuMemArena()
Wraps OrtApi::EnableCpuMemArena.
SessionOptions & AppendExecutionProvider_OpenVINO(const OrtOpenVINOProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO.
SessionOptions & DisableMemPattern()
Wraps OrtApi::DisableMemPattern.
SessionOptions & AddInitializer(const char *name, const OrtValue *ort_val)
Wraps OrtApi::AddInitializer.
SessionOptions & SetLogSeverityLevel(int level)
Wraps OrtApi::SetSessionLogSeverityLevel.
SessionOptions & SetInterOpNumThreads(int inter_op_num_threads)
Wraps OrtApi::SetInterOpNumThreads.
SessionOptions & SetCustomThreadCreationOptions(void *ort_custom_thread_creation_options)
Wraps OrtApi::SessionOptionsSetCustomThreadCreationOptions.
SessionOptions & AppendExecutionProvider_ROCM(const OrtROCMProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_ROCM.
SessionOptions & AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions &provider_options)
SessionOptions & DisableCpuMemArena()
Wraps OrtApi::DisableCpuMemArena.
SessionOptions & AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2 &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT.
SessionOptions & SetCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn)
Wraps OrtApi::SessionOptionsSetCustomJoinThreadFn.
SessionOptions & SetExecutionMode(ExecutionMode execution_mode)
Wraps OrtApi::SetSessionExecutionMode.
SessionOptions & SetLogId(const char *logid)
Wraps OrtApi::SetSessionLogId.
SessionOptions(OrtSessionOptions *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:349
SessionOptions & Add(OrtCustomOpDomain *custom_op_domain)
Wraps OrtApi::AddCustomOpDomain.
SessionOptions & AppendExecutionProvider_CUDA(const OrtCUDAProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA.
Wrapper around OrtTensorTypeAndShapeInfo.
Definition: onnxruntime_cxx_api.h:627
TensorTypeAndShapeInfo(std::nullptr_t)
Create an empty TensorTypeAndShapeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:628
TensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:629
void GetDimensions(int64_t *values, size_t values_count) const
Wraps OrtApi::GetDimensions.
std::vector< int64_t > GetShape() const
Uses GetDimensionsCount & GetDimensions to return a std::vector of the shape.
size_t GetDimensionsCount() const
Wraps OrtApi::GetDimensionsCount.
ONNXTensorElementDataType GetElementType() const
Wraps OrtApi::GetTensorElementType.
size_t GetElementCount() const
Wraps OrtApi::GetTensorShapeElementCount.
void GetSymbolicDimensions(const char **values, size_t values_count) const
Wraps OrtApi::GetSymbolicDimensions.
Definition: onnxruntime_cxx_api.h:662
Unowned< MapTypeInfo > GetMapTypeInfo() const
Wraps OrtApi::CastTypeInfoToMapTypeInfo.
Unowned< SequenceTypeInfo > GetSequenceTypeInfo() const
Wraps OrtApi::CastTypeInfoToSequenceTypeInfo.
ONNXType GetONNXType() const
Unowned< TensorTypeAndShapeInfo > GetTensorTypeAndShapeInfo() const
Wraps OrtApi::CastTypeInfoToTensorInfo.
TypeInfo(std::nullptr_t)
Create an empty TypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:663
TypeInfo(OrtTypeInfo *p)
C API Interop.
Definition: onnxruntime_cxx_api.h:664
Wraps an object that inherits from Ort::Base and stops it from deleting the contained pointer on dest...
Definition: onnxruntime_cxx_api.h:240
Unowned(Unowned &&v)
Definition: onnxruntime_cxx_api.h:242
~Unowned()
Definition: onnxruntime_cxx_api.h:243
Unowned(typename T::contained_type *p)
Definition: onnxruntime_cxx_api.h:241
Definition: onnxruntime_cxx_api.h:682
const char ** str
Definition: onnxruntime_cxx_api.h:687
size_t values_shape_len
Definition: onnxruntime_cxx_api.h:684
const int64_t * values_shape
Definition: onnxruntime_cxx_api.h:683
const void * p_data
Definition: onnxruntime_cxx_api.h:686
union Ort::Value::OrtSparseValuesParam::@0 data
Definition: onnxruntime_cxx_api.h:693
const int64_t * shape
Definition: onnxruntime_cxx_api.h:694
size_t shape_len
Definition: onnxruntime_cxx_api.h:695
Definition: onnxruntime_cxx_api.h:673
T * GetTensorMutableData()
Wraps OrtApi::GetTensorMutableData.
static Value CreateMap(Value &keys, Value &values)
Wraps OrtApi::CreateValue.
static Value CreateSparseTensor(const OrtMemoryInfo *info, void *p_data, const Shape &dense_shape, const Shape &values_shape, ONNXTensorElementDataType type)
Creates an OrtValue instance containing SparseTensor. This constructs a sparse tensor that makes use ...
static Value CreateSparseTensor(const OrtMemoryInfo *info, T *p_data, const Shape &dense_shape, const Shape &values_shape)
This is a simple forwarding method to the other overload that helps deducing data type enum value fro...
const T * GetSparseTensorIndicesData(OrtSparseIndicesFormat indices_format, size_t &num_indices) const
The API retrieves a pointer to the internal indices buffer. The API merely performs a convenience dat...
Value & operator=(Value &&)=default
static Value CreateSparseTensor(OrtAllocator *allocator, const Shape &dense_shape, ONNXTensorElementDataType type)
Creates an instance of OrtValue containing sparse tensor. The created instance has no data....
void UseCooIndices(int64_t *indices_data, size_t indices_num)
Supplies COO format specific indices and marks the contained sparse tensor as being a COO format tens...
Value(std::nullptr_t)
Create an empty Value object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:920
bool IsTensor() const
Returns true if Value is a tensor, false for other types like map/sequence/etc.
const T * GetTensorData() const
Wraps OrtApi::GetTensorMutableData.
static Value CreateTensor(const OrtMemoryInfo *info, T *p_data, size_t p_data_element_count, const int64_t *shape, size_t shape_len)
Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.
TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const
The API returns type information for data contained in a tensor. For sparse tensors it returns type i...
void UseCsrIndices(int64_t *inner_data, size_t inner_num, int64_t *outer_data, size_t outer_num)
Supplies CSR format specific indices and marks the contained sparse tensor as being a CSR format tens...
Value(OrtValue *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:921
void GetStringTensorContent(void *buffer, size_t buffer_length, size_t *offsets, size_t offsets_count) const
The API copies all of the UTF-8 encoded string data contained within a tensor or a sparse tensor into...
static Value CreateSparseTensor(OrtAllocator *allocator, const Shape &dense_shape)
This is a simple forwarding method the below CreateSparseTensor. This helps to specify data type enum...
static Value CreateTensor(OrtAllocator *allocator, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type)
Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.
bool IsSparseTensor() const
< Return true if OrtValue contains data and returns false if the OrtValue is a None
TensorTypeAndShapeInfo GetSparseTensorIndicesTypeShapeInfo(OrtSparseIndicesFormat format) const
The API returns type and shape information for the specified indices. Each supported indices have the...
size_t GetStringTensorElementLength(size_t element_index) const
The API returns a byte length of UTF-8 encoded string element contained in either a tensor or a spare...
TensorTypeAndShapeInfo GetSparseTensorValuesTypeAndShapeInfo() const
The API returns type and shape information for stored non-zero values of the sparse tensor....
void UseBlockSparseIndices(const Shape &indices_shape, int32_t *indices_data)
Supplies BlockSparse format specific indices and marks the contained sparse tensor as being a BlockSp...
void FillStringTensor(const char *const *s, size_t s_len)
void FillSparseTensorBlockSparse(const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values, const Shape &indices_shape, const int32_t *indices_data)
The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API an...
T & At(const std::vector< int64_t > &location)
TypeInfo GetTypeInfo() const
The API returns type information for data contained in a tensor. For sparse tensors it returns type i...
void FillSparseTensorCoo(const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values_param, const int64_t *indices_data, size_t indices_num)
The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API an...
static Value CreateTensor(const OrtMemoryInfo *info, void *p_data, size_t p_data_byte_count, const int64_t *shape, size_t shape_len, ONNXTensorElementDataType type)
Creates a tensor with a user supplied buffer. Wraps OrtApi::CreateTensorWithDataAsOrtValue.
static Value CreateOpaque(const char *domain, const char *type_name, const T &)
Wraps OrtApi::CreateOpaqueValue.
Value GetValue(int index, OrtAllocator *allocator) const
static Value CreateTensor(OrtAllocator *allocator, const int64_t *shape, size_t shape_len)
Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.
static Value CreateSequence(std::vector< Value > &values)
Wraps OrtApi::CreateValue.
void GetStringTensorElement(size_t buffer_length, size_t element_index, void *buffer) const
The API copies UTF-8 encoded bytes for the requested string element contained within a tensor or a sp...
void FillSparseTensorCsr(const OrtMemoryInfo *data_mem_info, const OrtSparseValuesParam &values, const int64_t *inner_indices_data, size_t inner_indices_num, const int64_t *outer_indices_data, size_t outer_indices_num)
The API will allocate memory using the allocator instance supplied to the CreateSparseTensor() API an...
void FillStringTensorElement(const char *s, size_t index)
const T * GetSparseTensorValues() const
The API returns a pointer to an internal buffer of the sparse tensor containing non-zero values....
void GetOpaqueData(const char *domain, const char *type_name, T &) const
Wraps OrtApi::GetOpaqueValue.
OrtSparseFormat GetSparseFormat() const
The API returns the sparse data format this OrtValue holds in a sparse tensor. If the sparse tensor w...
size_t GetStringTensorDataLength() const
This API returns a full length of string data contained within either a tensor or a sparse Tensor....
Definition: onnxruntime_cxx_api.h:255
AllocatedFree(OrtAllocator *allocator)
Definition: onnxruntime_cxx_api.h:257
OrtAllocator * allocator_
Definition: onnxruntime_cxx_api.h:256
void operator()(void *ptr) const
Definition: onnxruntime_cxx_api.h:259
Memory allocation interface.
Definition: onnxruntime_c_api.h:285
void(* Free)(struct OrtAllocator *this_, void *p)
Free a block of memory previously allocated with OrtAllocator::Alloc.
Definition: onnxruntime_c_api.h:288
const OrtApi *(* GetApi)(uint32_t version)
Get a pointer to the requested version of the OrtApi.
Definition: onnxruntime_c_api.h:554
The C API.
Definition: onnxruntime_c_api.h:595
CUDA Provider Options.
Definition: onnxruntime_c_api.h:361
Definition: onnxruntime_c_api.h:3525
OrtCustomOpInputOutputCharacteristic(* GetOutputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:3550
size_t(* GetInputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:3540
const char *(* GetName)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:3533
size_t(* GetOutputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:3542
void(* KernelDestroy)(void *op_kernel)
Definition: onnxruntime_c_api.h:3546
void *(* CreateKernel)(const struct OrtCustomOp *op, const OrtApi *api, const OrtKernelInfo *info)
Definition: onnxruntime_c_api.h:3529
uint32_t version
Definition: onnxruntime_c_api.h:3526
ONNXTensorElementDataType(* GetInputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:3539
OrtCustomOpInputOutputCharacteristic(* GetInputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:3549
const char *(* GetExecutionProviderType)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:3536
ONNXTensorElementDataType(* GetOutputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:3541
void(* KernelCompute)(void *op_kernel, OrtKernelContext *context)
Definition: onnxruntime_c_api.h:3545
MIGraphX Provider Options.
Definition: onnxruntime_c_api.h:506
OpenVINO Provider Options.
Definition: onnxruntime_c_api.h:516
ROCM Provider Options.
Definition: onnxruntime_c_api.h:420
TensorRT Provider Options.
Definition: onnxruntime_c_api.h:478