# OnnxRuntime: onnxruntime_cxx_api.h Source File

Loading...
Searching...
No Matches
onnxruntime_cxx_api.h
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Summary: The Ort C++ API is a header only wrapper around the Ort C API.
//
// The C++ API simplifies usage by returning values directly instead of error codes, throwing exceptions on errors
// and automatically releasing resources in the destructors. The primary purpose of C++ API is exception safety so
// all the resources follow RAII and do not leak memory.
//
// Each of the C++ wrapper classes holds only a pointer to the C internal object. Treat them like smart pointers.
// To create an empty object, pass 'nullptr' to the constructor (for example, Env e{nullptr};). However, you can't use them
// until you assign an instance that actually holds an underlying object.
//
// For Ort objects only move assignment between objects is allowed, there are no copy constructors.
// Some objects have explicit 'Clone' methods for this purpose.
//
// ConstXXXX types are copyable since they do not own the underlying C object, so you can pass them to functions as arguments
// by value or by reference. ConstXXXX types are restricted to const only interfaces.
//
// UnownedXXXX are similar to ConstXXXX but also allow non-const interfaces.
//
// The lifetime of the corresponding owning object must eclipse the lifetimes of the ConstXXXX/UnownedXXXX types. They exists so you do not
// have to fallback to C types and the API with the usual pitfalls. In general, do not use C API from your C++ code.
#pragma once
#include "onnxruntime_c_api.h"
#include <cstddef>
#include <array>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
#include <type_traits>
#ifdef ORT_NO_EXCEPTIONS
#include <iostream>
#endif
namespace Ort {
struct Exception : std::exception {
Exception(std::string&& string, OrtErrorCode code) : message_{std::move(string)}, code_{code} {}
OrtErrorCode GetOrtErrorCode() const { return code_; }
const char* what() const noexcept override { return message_.c_str(); }
private:
std::string message_;
OrtErrorCode code_;
};
#ifdef ORT_NO_EXCEPTIONS
// The #ifndef is for the very special case where the user of this library wants to define their own way of handling errors.
// NOTE: This header expects control flow to not continue after calling ORT_CXX_API_THROW
#ifndef ORT_CXX_API_THROW
#define ORT_CXX_API_THROW(string, code) \
do { \
std::cerr << Ort::Exception(string, code) \
.what() \
<< std::endl; \
abort(); \
} while (false)
#endif
#else
#define ORT_CXX_API_THROW(string, code) \
throw Ort::Exception(string, code)
#endif
// This is used internally by the C++ API. This class holds the global variable that points to the OrtApi,
// it's in a template so that we can define a global variable in a header and make
// it transparent to the users of the API.
template <typename T>
struct Global {
static const OrtApi* api_;
};
// If macro ORT_API_MANUAL_INIT is defined, no static initialization will be performed. Instead, user must call InitApi() before using it.
template <typename T>
#ifdef ORT_API_MANUAL_INIT
const OrtApi* Global<T>::api_{};
inline void InitApi() { Global<void>::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION); }
// Used by custom operator libraries that are not linked to onnxruntime. Sets the global API object, which is
// required by C++ APIs.
//
// Example mycustomop.cc:
//
// #define ORT_API_MANUAL_INIT
// #include <onnxruntime_cxx_api.h>
// #undef ORT_API_MANUAL_INIT
//
// OrtStatus* ORT_API_CALL RegisterCustomOps(OrtSessionOptions* options, const OrtApiBase* api_base) {
// Ort::InitApi(api_base->GetApi(ORT_API_VERSION));
// // ...
// }
//
inline void InitApi(const OrtApi* api) { Global<void>::api_ = api; }
#else
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
// "Global initializer calls a non-constexpr function." Therefore you can't use ORT APIs in the other global initializers.
// Please define ORT_API_MANUAL_INIT if it conerns you.
#pragma warning(disable : 26426)
#endif
const OrtApi* Global<T>::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION);
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
#endif
inline const OrtApi& GetApi() { return *Global<void>::api_; }
std::vector<std::string> GetAvailableProviders();
struct Float16_t {
uint16_t value;
constexpr Float16_t() noexcept : value(0) {}
constexpr Float16_t(uint16_t v) noexcept : value(v) {}
constexpr operator uint16_t() const noexcept { return value; }
constexpr bool operator==(const Float16_t& rhs) const noexcept { return value == rhs.value; };
constexpr bool operator!=(const Float16_t& rhs) const noexcept { return value != rhs.value; };
};
static_assert(sizeof(Float16_t) == sizeof(uint16_t), "Sizes must match");
struct BFloat16_t {
uint16_t value;
constexpr BFloat16_t() noexcept : value(0) {}
constexpr BFloat16_t(uint16_t v) noexcept : value(v) {}
constexpr operator uint16_t() const noexcept { return value; }
constexpr bool operator==(const BFloat16_t& rhs) const noexcept { return value == rhs.value; };
constexpr bool operator!=(const BFloat16_t& rhs) const noexcept { return value != rhs.value; };
};
static_assert(sizeof(BFloat16_t) == sizeof(uint16_t), "Sizes must match");
namespace detail {
// This is used internally by the C++ API. This macro is to make it easy to generate overloaded methods for all of the various OrtRelease* functions for every Ort* type
// This can't be done in the C API since C doesn't have function overloading.
#define ORT_DEFINE_RELEASE(NAME) \
inline void OrtRelease(Ort##NAME* ptr) { GetApi().Release##NAME(ptr); }
ORT_DEFINE_RELEASE(Allocator);
ORT_DEFINE_RELEASE(MemoryInfo);
ORT_DEFINE_RELEASE(CustomOpDomain);
ORT_DEFINE_RELEASE(ThreadingOptions);
ORT_DEFINE_RELEASE(Env);
ORT_DEFINE_RELEASE(RunOptions);
ORT_DEFINE_RELEASE(Session);
ORT_DEFINE_RELEASE(SessionOptions);
ORT_DEFINE_RELEASE(TensorTypeAndShapeInfo);
ORT_DEFINE_RELEASE(SequenceTypeInfo);
ORT_DEFINE_RELEASE(MapTypeInfo);
ORT_DEFINE_RELEASE(TypeInfo);
ORT_DEFINE_RELEASE(Value);
ORT_DEFINE_RELEASE(ModelMetadata);
ORT_DEFINE_RELEASE(IoBinding);
ORT_DEFINE_RELEASE(ArenaCfg);
ORT_DEFINE_RELEASE(Status);
ORT_DEFINE_RELEASE(OpAttr);
ORT_DEFINE_RELEASE(Op);
ORT_DEFINE_RELEASE(KernelInfo);
#undef ORT_DEFINE_RELEASE
template <typename T>
struct Unowned {
using Type = T;
};
template <typename T>
struct Base {
using contained_type = T;
constexpr Base() = default;
constexpr explicit Base(contained_type* p) noexcept : p_{p} {}
~Base() { OrtRelease(p_); }
Base(const Base&) = delete;
Base& operator=(const Base&) = delete;
Base(Base&& v) noexcept : p_{v.p_} { v.p_ = nullptr; }
Base& operator=(Base&& v) noexcept {
OrtRelease(p_);
p_ = v.release();
return *this;
}
constexpr operator contained_type*() const noexcept { return p_; }
contained_type* release() {
T* p = p_;
p_ = nullptr;
return p;
}
protected:
contained_type* p_{};
};
// Undefined. For const types use Base<Unowned<const T>>
template <typename T>
struct Base<const T>;
template <typename T>
struct Base<Unowned<T>> {
using contained_type = typename Unowned<T>::Type;
constexpr Base() = default;
constexpr explicit Base(contained_type* p) noexcept : p_{p} {}
~Base() = default;
Base(const Base&) = default;
Base& operator=(const Base&) = default;
Base(Base&& v) noexcept : p_{v.p_} { v.p_ = nullptr; }
Base& operator=(Base&& v) noexcept {
p_ = nullptr;
std::swap(p_, v.p_);
return *this;
}
constexpr operator contained_type*() const noexcept { return p_; }
protected:
contained_type* p_{};
};
// Light functor to release memory with OrtAllocator
struct AllocatedFree {
OrtAllocator* allocator_;
explicit AllocatedFree(OrtAllocator* allocator)
: allocator_(allocator) {}
void operator()(void* ptr) const {
if (ptr) allocator_->Free(allocator_, ptr);
}
};
} // namespace detail
struct AllocatorWithDefaultOptions;
struct Env;
struct TypeInfo;
struct Value;
struct ModelMetadata;
using AllocatedStringPtr = std::unique_ptr<char, detail::AllocatedFree>;
struct Status : detail::Base<OrtStatus> {
explicit Status(std::nullptr_t) {}
explicit Status(OrtStatus* status);
explicit Status(const Exception&);
explicit Status(const std::exception&);
std::string GetErrorMessage() const;
OrtErrorCode GetErrorCode() const;
};
struct ThreadingOptions : detail::Base<OrtThreadingOptions> {
ThreadingOptions();
ThreadingOptions& SetGlobalIntraOpNumThreads(int intra_op_num_threads);
ThreadingOptions& SetGlobalInterOpNumThreads(int inter_op_num_threads);
ThreadingOptions& SetGlobalSpinControl(int allow_spinning);
ThreadingOptions& SetGlobalDenormalAsZero();
ThreadingOptions& SetGlobalCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn);
ThreadingOptions& SetGlobalCustomThreadCreationOptions(void* ort_custom_thread_creation_options);
ThreadingOptions& SetGlobalCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn);
};
struct Env : detail::Base<OrtEnv> {
explicit Env(std::nullptr_t) {}
Env(OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = "");
Env(OrtLoggingLevel logging_level, const char* logid, OrtLoggingFunction logging_function, void* logger_param);
Env(const OrtThreadingOptions* tp_options, OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = "");
Env(const OrtThreadingOptions* tp_options, OrtLoggingFunction logging_function, void* logger_param,
OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_WARNING, _In_ const char* logid = "");
explicit Env(OrtEnv* p) : Base<OrtEnv>{p} {}
Env& EnableTelemetryEvents();
Env& DisableTelemetryEvents();
Env& UpdateEnvWithCustomLogLevel(OrtLoggingLevel log_severity_level);
Env& CreateAndRegisterAllocator(const OrtMemoryInfo* mem_info, const OrtArenaCfg* arena_cfg);
};
struct CustomOpDomain : detail::Base<OrtCustomOpDomain> {
explicit CustomOpDomain(std::nullptr_t) {}
explicit CustomOpDomain(const char* domain);
// This does not take ownership of the op, simply registers it.
void Add(const OrtCustomOp* op);
};
struct RunOptions : detail::Base<OrtRunOptions> {
explicit RunOptions(std::nullptr_t) {}
RunOptions();
RunOptions& SetRunLogVerbosityLevel(int);
int GetRunLogVerbosityLevel() const;
RunOptions& SetRunLogSeverityLevel(int);
int GetRunLogSeverityLevel() const;
RunOptions& SetRunTag(const char* run_tag);
const char* GetRunTag() const;
RunOptions& AddConfigEntry(const char* config_key, const char* config_value);
RunOptions& SetTerminate();
RunOptions& UnsetTerminate();
};
namespace detail {
// Utility function that returns a SessionOption config entry key for a specific custom operator.
// Ex: custom_op.[custom_op_name].[config]
std::string MakeCustomOpConfigEntryKey(const char* custom_op_name, const char* config);
} // namespace detail
struct CustomOpConfigs {
CustomOpConfigs() = default;
~CustomOpConfigs() = default;
CustomOpConfigs(const CustomOpConfigs&) = default;
CustomOpConfigs& operator=(const CustomOpConfigs&) = default;
CustomOpConfigs(CustomOpConfigs&& o) = default;
CustomOpConfigs& operator=(CustomOpConfigs&& o) = default;
CustomOpConfigs& AddConfig(const char* custom_op_name, const char* config_key, const char* config_value);
const std::unordered_map<std::string, std::string>& GetFlattenedConfigs() const;
private:
std::unordered_map<std::string, std::string> flat_configs_;
};
struct SessionOptions;
namespace detail {
// we separate const-only methods because passing const ptr to non-const methods
// is only discovered when inline methods are compiled which is counter-intuitive
template <typename T>
struct ConstSessionOptionsImpl : Base<T> {
using B = Base<T>;
using B::B;
SessionOptions Clone() const;
std::string GetConfigEntry(const char* config_key) const;
bool HasConfigEntry(const char* config_key) const;
std::string GetConfigEntryOrDefault(const char* config_key, const std::string& def);
};
template <typename T>
struct SessionOptionsImpl : ConstSessionOptionsImpl<T> {
using B = ConstSessionOptionsImpl<T>;
using B::B;
SessionOptionsImpl& SetIntraOpNumThreads(int intra_op_num_threads);
SessionOptionsImpl& SetInterOpNumThreads(int inter_op_num_threads);
SessionOptionsImpl& SetGraphOptimizationLevel(GraphOptimizationLevel graph_optimization_level);
SessionOptionsImpl& EnableCpuMemArena();
SessionOptionsImpl& DisableCpuMemArena();
SessionOptionsImpl& SetOptimizedModelFilePath(const ORTCHAR_T* optimized_model_file);
SessionOptionsImpl& EnableProfiling(const ORTCHAR_T* profile_file_prefix);
SessionOptionsImpl& DisableProfiling();
SessionOptionsImpl& EnableOrtCustomOps();
SessionOptionsImpl& EnableMemPattern();
SessionOptionsImpl& DisableMemPattern();
SessionOptionsImpl& SetExecutionMode(ExecutionMode execution_mode);
SessionOptionsImpl& SetLogId(const char* logid);
SessionOptionsImpl& SetLogSeverityLevel(int level);
SessionOptionsImpl& Add(OrtCustomOpDomain* custom_op_domain);
SessionOptionsImpl& DisablePerSessionThreads();
SessionOptionsImpl& AddConfigEntry(const char* config_key, const char* config_value);
SessionOptionsImpl& AddInitializer(const char* name, const OrtValue* ort_val);
SessionOptionsImpl& AddExternalInitializers(const std::vector<std::string>& names, const std::vector<Value>& ort_values);
SessionOptionsImpl& AppendExecutionProvider_CUDA(const OrtCUDAProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_CUDA_V2(const OrtCUDAProviderOptionsV2& provider_options);
SessionOptionsImpl& AppendExecutionProvider_ROCM(const OrtROCMProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_OpenVINO(const OrtOpenVINOProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2& provider_options);
SessionOptionsImpl& AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_CANN(const OrtCANNProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider_Dnnl(const OrtDnnlProviderOptions& provider_options);
SessionOptionsImpl& AppendExecutionProvider(const std::string& provider_name,
const std::unordered_map<std::string, std::string>& provider_options = {});
SessionOptionsImpl& SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn);
SessionOptionsImpl& SetCustomThreadCreationOptions(void* ort_custom_thread_creation_options);
SessionOptionsImpl& SetCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn);
SessionOptionsImpl& RegisterCustomOpsLibrary(const ORTCHAR_T* library_name, const CustomOpConfigs& custom_op_configs = {});
SessionOptionsImpl& RegisterCustomOpsUsingFunction(const char* function_name);
};
} // namespace detail
using UnownedSessionOptions = detail::SessionOptionsImpl<detail::Unowned<OrtSessionOptions>>;
using ConstSessionOptions = detail::ConstSessionOptionsImpl<detail::Unowned<const OrtSessionOptions>>;
struct SessionOptions : detail::SessionOptionsImpl<OrtSessionOptions> {
explicit SessionOptions(std::nullptr_t) {}
SessionOptions();
explicit SessionOptions(OrtSessionOptions* p) : SessionOptionsImpl<OrtSessionOptions>{p} {}
UnownedSessionOptions GetUnowned() const { return UnownedSessionOptions{this->p_}; }
ConstSessionOptions GetConst() const { return ConstSessionOptions{this->p_}; }
};
struct ModelMetadata : detail::Base<OrtModelMetadata> {
explicit ModelMetadata(std::nullptr_t) {}
explicit ModelMetadata(OrtModelMetadata* p) : Base<OrtModelMetadata>{p} {}
AllocatedStringPtr GetProducerNameAllocated(OrtAllocator* allocator) const;
AllocatedStringPtr GetGraphNameAllocated(OrtAllocator* allocator) const;
AllocatedStringPtr GetDomainAllocated(OrtAllocator* allocator) const;
AllocatedStringPtr GetDescriptionAllocated(OrtAllocator* allocator) const;
AllocatedStringPtr GetGraphDescriptionAllocated(OrtAllocator* allocator) const;
std::vector<AllocatedStringPtr> GetCustomMetadataMapKeysAllocated(OrtAllocator* allocator) const;
AllocatedStringPtr LookupCustomMetadataMapAllocated(const char* key, OrtAllocator* allocator) const;
int64_t GetVersion() const;
};
struct IoBinding;
namespace detail {
// we separate const-only methods because passing const ptr to non-const methods
// is only discovered when inline methods are compiled which is counter-intuitive
template <typename T>
struct ConstSessionImpl : Base<T> {
using B = Base<T>;
using B::B;
size_t GetInputCount() const;
size_t GetOutputCount() const;
size_t GetOverridableInitializerCount() const;
AllocatedStringPtr GetInputNameAllocated(size_t index, OrtAllocator* allocator) const;
AllocatedStringPtr GetOutputNameAllocated(size_t index, OrtAllocator* allocator) const;
AllocatedStringPtr GetOverridableInitializerNameAllocated(size_t index, OrtAllocator* allocator) const;
uint64_t GetProfilingStartTimeNs() const;
ModelMetadata GetModelMetadata() const;
TypeInfo GetInputTypeInfo(size_t index) const;
TypeInfo GetOutputTypeInfo(size_t index) const;
TypeInfo GetOverridableInitializerTypeInfo(size_t index) const;
};
template <typename T>
struct SessionImpl : ConstSessionImpl<T> {
using B = ConstSessionImpl<T>;
using B::B;
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);
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);
void Run(const RunOptions& run_options, const IoBinding&);
AllocatedStringPtr EndProfilingAllocated(OrtAllocator* allocator);
};
} // namespace detail
using ConstSession = detail::ConstSessionImpl<detail::Unowned<const OrtSession>>;
using UnownedSession = detail::SessionImpl<detail::Unowned<OrtSession>>;
struct Session : detail::SessionImpl<OrtSession> {
explicit Session(std::nullptr_t) {}
Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options);
Session(const Env& env, const ORTCHAR_T* model_path, const SessionOptions& options,
OrtPrepackedWeightsContainer* prepacked_weights_container);
Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options);
Session(const Env& env, const void* model_data, size_t model_data_length, const SessionOptions& options,
OrtPrepackedWeightsContainer* prepacked_weights_container);
ConstSession GetConst() const { return ConstSession{this->p_}; }
UnownedSession GetUnowned() const { return UnownedSession{this->p_}; }
};
namespace detail {
template <typename T>
struct MemoryInfoImpl : Base<T> {
using B = Base<T>;
using B::B;
std::string GetAllocatorName() const;
OrtAllocatorType GetAllocatorType() const;
int GetDeviceId() const;
OrtMemoryInfoDeviceType GetDeviceType() const;
OrtMemType GetMemoryType() const;
template <typename U>
bool operator==(const MemoryInfoImpl<U>& o) const;
};
} // namespace detail
// Const object holder that does not own the underlying object
using ConstMemoryInfo = detail::MemoryInfoImpl<detail::Unowned<const OrtMemoryInfo>>;
struct MemoryInfo : detail::MemoryInfoImpl<OrtMemoryInfo> {
static MemoryInfo CreateCpu(OrtAllocatorType type, OrtMemType mem_type1);
explicit MemoryInfo(std::nullptr_t) {}
explicit MemoryInfo(OrtMemoryInfo* p) : MemoryInfoImpl<OrtMemoryInfo>{p} {}
MemoryInfo(const char* name, OrtAllocatorType type, int id, OrtMemType mem_type);
ConstMemoryInfo GetConst() const { return ConstMemoryInfo{this->p_}; }
};
namespace detail {
template <typename T>
struct TensorTypeAndShapeInfoImpl : Base<T> {
using B = Base<T>;
using B::B;
ONNXTensorElementDataType GetElementType() const;
size_t GetElementCount() const;
size_t GetDimensionsCount() const;
[[deprecated("use GetShape()")]] void GetDimensions(int64_t* values, size_t values_count) const;
void GetSymbolicDimensions(const char** values, size_t values_count) const;
std::vector<int64_t> GetShape() const;
};
} // namespace detail
using ConstTensorTypeAndShapeInfo = detail::TensorTypeAndShapeInfoImpl<detail::Unowned<const OrtTensorTypeAndShapeInfo>>;
struct TensorTypeAndShapeInfo : detail::TensorTypeAndShapeInfoImpl<OrtTensorTypeAndShapeInfo> {
explicit TensorTypeAndShapeInfo(std::nullptr_t) {}
explicit TensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo* p) : TensorTypeAndShapeInfoImpl{p} {}
ConstTensorTypeAndShapeInfo GetConst() const { return ConstTensorTypeAndShapeInfo{this->p_}; }
};
namespace detail {
template <typename T>
struct SequenceTypeInfoImpl : Base<T> {
using B = Base<T>;
using B::B;
TypeInfo GetSequenceElementType() const;
};
} // namespace detail
using ConstSequenceTypeInfo = detail::SequenceTypeInfoImpl<detail::Unowned<const OrtSequenceTypeInfo>>;
struct SequenceTypeInfo : detail::SequenceTypeInfoImpl<OrtSequenceTypeInfo> {
explicit SequenceTypeInfo(std::nullptr_t) {}
explicit SequenceTypeInfo(OrtSequenceTypeInfo* p) : SequenceTypeInfoImpl<OrtSequenceTypeInfo>{p} {}
ConstSequenceTypeInfo GetConst() const { return ConstSequenceTypeInfo{this->p_}; }
};
namespace detail {
template <typename T>
struct MapTypeInfoImpl : detail::Base<T> {
using B = Base<T>;
using B::B;
ONNXTensorElementDataType GetMapKeyType() const;
TypeInfo GetMapValueType() const;
};
} // namespace detail
using ConstMapTypeInfo = detail::MapTypeInfoImpl<detail::Unowned<const OrtMapTypeInfo>>;
struct MapTypeInfo : detail::MapTypeInfoImpl<OrtMapTypeInfo> {
explicit MapTypeInfo(std::nullptr_t) {}
explicit MapTypeInfo(OrtMapTypeInfo* p) : MapTypeInfoImpl<OrtMapTypeInfo>{p} {}
ConstMapTypeInfo GetConst() const { return ConstMapTypeInfo{this->p_}; }
};
namespace detail {
template <typename T>
struct TypeInfoImpl : detail::Base<T> {
using B = Base<T>;
using B::B;
ConstTensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const;
ConstSequenceTypeInfo GetSequenceTypeInfo() const;
ConstMapTypeInfo GetMapTypeInfo() const;
ONNXType GetONNXType() const;
};
} // namespace detail
using ConstTypeInfo = detail::TypeInfoImpl<detail::Unowned<const OrtTypeInfo>>;
struct TypeInfo : detail::TypeInfoImpl<OrtTypeInfo> {
explicit TypeInfo(std::nullptr_t) {}
explicit TypeInfo(OrtTypeInfo* p) : TypeInfoImpl<OrtTypeInfo>{p} {}
ConstTypeInfo GetConst() const { return ConstTypeInfo{this->p_}; }
};
namespace detail {
// This structure is used to feed sparse tensor values
// information for use with FillSparseTensor<Format>() API
// if the data type for the sparse tensor values is numeric
// use data.p_data, otherwise, use data.str pointer to feed
// values. data.str is an array of const char* that are zero terminated.
// number of strings in the array must match shape size.
// For fully sparse tensors use shape {0} and set p_data/str
// to nullptr.
struct OrtSparseValuesParam {
const int64_t* values_shape;
size_t values_shape_len;
union {
const void* p_data;
const char** str;
} data;
};
// Provides a way to pass shape in a single
// argument
struct Shape {
const int64_t* shape;
size_t shape_len;
};
template <typename T>
struct ConstValueImpl : Base<T> {
using B = Base<T>;
using B::B;
template <typename R>
void GetOpaqueData(const char* domain, const char* type_name, R&) const;
bool IsTensor() const;
bool HasValue() const;
size_t GetCount() const; // If a non tensor, returns 2 for map and N for sequence, where N is the number of elements
Value GetValue(int index, OrtAllocator* allocator) const;
size_t GetStringTensorDataLength() const;
void GetStringTensorContent(void* buffer, size_t buffer_length, size_t* offsets, size_t offsets_count) const;
template <typename R>
const R* GetTensorData() const;
const void* GetTensorRawData() const;
TypeInfo GetTypeInfo() const;
TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const;
ConstMemoryInfo GetTensorMemoryInfo() const;
void GetStringTensorElement(size_t buffer_length, size_t element_index, void* buffer) const;
size_t GetStringTensorElementLength(size_t element_index) const;
#if !defined(DISABLE_SPARSE_TENSORS)
OrtSparseFormat GetSparseFormat() const;
TensorTypeAndShapeInfo GetSparseTensorValuesTypeAndShapeInfo() const;
TensorTypeAndShapeInfo GetSparseTensorIndicesTypeShapeInfo(OrtSparseIndicesFormat format) const;
template <typename R>
const R* GetSparseTensorIndicesData(OrtSparseIndicesFormat indices_format, size_t& num_indices) const;
bool IsSparseTensor() const;
template <typename R>
const R* GetSparseTensorValues() const;
#endif
};
template <typename T>
struct ValueImpl : ConstValueImpl<T> {
using B = ConstValueImpl<T>;
using B::B;
template <typename R>
R* GetTensorMutableData();
void* GetTensorMutableRawData();
// Obtain a reference to an element of data at the location specified
template <typename R>
R& At(const std::vector<int64_t>& location);
void FillStringTensor(const char* const* s, size_t s_len);
void FillStringTensorElement(const char* s, size_t index);
#if !defined(DISABLE_SPARSE_TENSORS)
void UseCooIndices(int64_t* indices_data, size_t indices_num);
void UseCsrIndices(int64_t* inner_data, size_t inner_num, int64_t* outer_data, size_t outer_num);
void UseBlockSparseIndices(const Shape& indices_shape, int32_t* indices_data);
void FillSparseTensorCoo(const OrtMemoryInfo* data_mem_info, const OrtSparseValuesParam& values_param,
const int64_t* indices_data, size_t indices_num);
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);
void FillSparseTensorBlockSparse(const OrtMemoryInfo* data_mem_info,
const OrtSparseValuesParam& values,
const Shape& indices_shape,
const int32_t* indices_data);
#endif
};
} // namespace detail
using ConstValue = detail::ConstValueImpl<detail::Unowned<const OrtValue>>;
using UnownedValue = detail::ValueImpl<detail::Unowned<OrtValue>>;
struct Value : detail::ValueImpl<OrtValue> {
using Base = detail::ValueImpl<OrtValue>;
using OrtSparseValuesParam = detail::OrtSparseValuesParam;
using Shape = detail::Shape;
explicit Value(std::nullptr_t) {}
explicit Value(OrtValue* p) : Base{p} {}
Value(Value&&) = default;
Value& operator=(Value&&) = default;
ConstValue GetConst() const { return ConstValue{this->p_}; }
UnownedValue GetUnowned() const { return UnownedValue{this->p_}; }
template <typename T>
static Value CreateTensor(const OrtMemoryInfo* info, T* p_data, size_t p_data_element_count, const int64_t* shape, size_t shape_len);
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);
template <typename T>
static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len);
static Value CreateTensor(OrtAllocator* allocator, const int64_t* shape, size_t shape_len, ONNXTensorElementDataType type);
static Value CreateMap(Value& keys, Value& values);
static Value CreateSequence(std::vector<Value>& values);
template <typename T>
static Value CreateOpaque(const char* domain, const char* type_name, const T&);
#if !defined(DISABLE_SPARSE_TENSORS)
template <typename T>
static Value CreateSparseTensor(const OrtMemoryInfo* info, T* p_data, const Shape& dense_shape,
const Shape& values_shape);
static Value CreateSparseTensor(const OrtMemoryInfo* info, void* p_data, const Shape& dense_shape,
const Shape& values_shape, ONNXTensorElementDataType type);
template <typename T>
static Value CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape);
static Value CreateSparseTensor(OrtAllocator* allocator, const Shape& dense_shape, ONNXTensorElementDataType type);
#endif // !defined(DISABLE_SPARSE_TENSORS)
};
struct MemoryAllocation {
MemoryAllocation(OrtAllocator* allocator, void* p, size_t size);
~MemoryAllocation();
MemoryAllocation(const MemoryAllocation&) = delete;
MemoryAllocation& operator=(const MemoryAllocation&) = delete;
MemoryAllocation(MemoryAllocation&&) noexcept;
MemoryAllocation& operator=(MemoryAllocation&&) noexcept;
void* get() { return p_; }
size_t size() const { return size_; }
private:
OrtAllocator* allocator_;
void* p_;
size_t size_;
};
namespace detail {
template <typename T>
struct AllocatorImpl : Base<T> {
using B = Base<T>;
using B::B;
void* Alloc(size_t size);
MemoryAllocation GetAllocation(size_t size);
void Free(void* p);
ConstMemoryInfo GetInfo() const;
};
} // namespace detail
struct AllocatorWithDefaultOptions : detail::AllocatorImpl<detail::Unowned<OrtAllocator>> {
explicit AllocatorWithDefaultOptions(std::nullptr_t) {}
AllocatorWithDefaultOptions();
};
struct Allocator : detail::AllocatorImpl<OrtAllocator> {
explicit Allocator(std::nullptr_t) {}
Allocator(const Session& session, const OrtMemoryInfo*);
};
using UnownedAllocator = detail::AllocatorImpl<detail::Unowned<OrtAllocator>>;
namespace detail {
namespace binding_utils {
// Bring these out of template
std::vector<std::string> GetOutputNamesHelper(const OrtIoBinding* binding, OrtAllocator*);
std::vector<Value> GetOutputValuesHelper(const OrtIoBinding* binding, OrtAllocator*);
} // namespace binding_utils
template <typename T>
struct ConstIoBindingImpl : Base<T> {
using B = Base<T>;
using B::B;
std::vector<std::string> GetOutputNames() const;
std::vector<std::string> GetOutputNames(OrtAllocator*) const;
std::vector<Value> GetOutputValues() const;
std::vector<Value> GetOutputValues(OrtAllocator*) const;
};
template <typename T>
struct IoBindingImpl : ConstIoBindingImpl<T> {
using B = ConstIoBindingImpl<T>;
using B::B;
void BindInput(const char* name, const Value&);
void BindOutput(const char* name, const Value&);
void BindOutput(const char* name, const OrtMemoryInfo*);
void ClearBoundInputs();
void ClearBoundOutputs();
void SynchronizeInputs();
void SynchronizeOutputs();
};
} // namespace detail
using ConstIoBinding = detail::ConstIoBindingImpl<detail::Unowned<const OrtIoBinding>>;
using UnownedIoBinding = detail::IoBindingImpl<detail::Unowned<OrtIoBinding>>;
struct IoBinding : detail::IoBindingImpl<OrtIoBinding> {
explicit IoBinding(std::nullptr_t) {}
explicit IoBinding(Session& session);
ConstIoBinding GetConst() const { return ConstIoBinding{this->p_}; }
UnownedIoBinding GetUnowned() const { return UnownedIoBinding{this->p_}; }
};
struct ArenaCfg : detail::Base<OrtArenaCfg> {
explicit ArenaCfg(std::nullptr_t) {}
ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk);
};
//
// Custom OPs (only needed to implement custom OPs)
//
struct OpAttr : detail::Base<OrtOpAttr> {
OpAttr(const char* name, const void* data, int len, OrtOpAttrType type);
};
struct KernelContext {
explicit KernelContext(OrtKernelContext* context);
size_t GetInputCount() const;
size_t GetOutputCount() const;
ConstValue GetInput(size_t index) const;
UnownedValue GetOutput(size_t index, const int64_t* dim_values, size_t dim_count) const;
UnownedValue GetOutput(size_t index, const std::vector<int64_t>& dims) const;
void* GetGPUComputeStream() const;
private:
OrtKernelContext* ctx_;
};
struct KernelInfo;
namespace detail {
namespace attr_utils {
void GetAttr(const OrtKernelInfo* p, const char* name, float&);
void GetAttr(const OrtKernelInfo* p, const char* name, int64_t&);
void GetAttr(const OrtKernelInfo* p, const char* name, std::string&);
void GetAttrs(const OrtKernelInfo* p, const char* name, std::vector<float>&);
void GetAttrs(const OrtKernelInfo* p, const char* name, std::vector<int64_t>&);
} // namespace attr_utils
template <typename T>
struct KernelInfoImpl : Base<T> {
using B = Base<T>;
using B::B;
KernelInfo Copy() const;
template <typename R> // R is only implemented for float, int64_t, and string
R GetAttribute(const char* name) const {
R val;
attr_utils::GetAttr(this->p_, name, val);
return val;
}
template <typename R> // R is only implemented for std::vector<float>, std::vector<int64_t>
std::vector<R> GetAttributes(const char* name) const {
std::vector<R> result;
attr_utils::GetAttrs(this->p_, name, result);
return result;
}
Value GetTensorAttribute(const char* name, OrtAllocator* allocator) const;
size_t GetInputCount() const;
size_t GetOutputCount() const;
std::string GetInputName(size_t index) const;
std::string GetOutputName(size_t index) const;
TypeInfo GetInputTypeInfo(size_t index) const;
TypeInfo GetOutputTypeInfo(size_t index) const;
};
} // namespace detail
using ConstKernelInfo = detail::KernelInfoImpl<detail::Unowned<const OrtKernelInfo>>;
struct KernelInfo : detail::KernelInfoImpl<OrtKernelInfo> {
explicit KernelInfo(std::nullptr_t) {}
explicit KernelInfo(OrtKernelInfo* info);
ConstKernelInfo GetConst() const { return ConstKernelInfo{this->p_}; }
};
struct Op : detail::Base<OrtOp> {
explicit Op(std::nullptr_t) {}
explicit Op(OrtOp*);
static Op Create(const OrtKernelInfo* info, const char* op_name, const char* domain,
int version, const char** type_constraint_names,
const ONNXTensorElementDataType* type_constraint_values,
size_t type_constraint_count,
const OpAttr* attr_values,
size_t attr_count,
size_t input_count, size_t output_count);
void Invoke(const OrtKernelContext* context,
const Value* input_values,
size_t input_count,
Value* output_values,
size_t output_count);
// For easier refactoring
void Invoke(const OrtKernelContext* context,
const OrtValue* const* input_values,
size_t input_count,
OrtValue* const* output_values,
size_t output_count);
};
struct CustomOpApi {
CustomOpApi(const OrtApi& api) : api_(api) {}
[[deprecated("use Ort::Value::GetTensorTypeAndShape()")]] OrtTensorTypeAndShapeInfo* GetTensorTypeAndShape(_In_ const OrtValue* value);
[[deprecated("use Ort::TensorTypeAndShapeInfo::GetElementCount()")]] size_t GetTensorShapeElementCount(_In_ const OrtTensorTypeAndShapeInfo* info);
[[deprecated("use Ort::TensorTypeAndShapeInfo::GetElementType()")]] ONNXTensorElementDataType GetTensorElementType(const OrtTensorTypeAndShapeInfo* info);
[[deprecated("use Ort::TensorTypeAndShapeInfo::GetDimensionsCount()")]] size_t GetDimensionsCount(_In_ const OrtTensorTypeAndShapeInfo* info);
[[deprecated("use Ort::TensorTypeAndShapeInfo::GetShape()")]] void GetDimensions(_In_ const OrtTensorTypeAndShapeInfo* info, _Out_ int64_t* dim_values, size_t dim_values_length);
[[deprecated("Do not use")]] void SetDimensions(OrtTensorTypeAndShapeInfo* info, _In_ const int64_t* dim_values, size_t dim_count);
template <typename T>
[[deprecated("use Ort::Value::GetTensorMutableData()")]] T* GetTensorMutableData(_Inout_ OrtValue* value);
template <typename T>
[[deprecated("use Ort::Value::GetTensorData()")]] const T* GetTensorData(_Inout_ const OrtValue* value);
[[deprecated("use Ort::Value::GetTensorMemoryInfo()")]] const OrtMemoryInfo* GetTensorMemoryInfo(_In_ const OrtValue* value);
[[deprecated("use Ort::TensorTypeAndShapeInfo::GetShape()")]] std::vector<int64_t> GetTensorShape(const OrtTensorTypeAndShapeInfo* info);
[[deprecated("use TensorTypeAndShapeInfo")]] void ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo* input);
[[deprecated("use Ort::KernelContext::GetInputCount")]] size_t KernelContext_GetInputCount(const OrtKernelContext* context);
[[deprecated("use Ort::KernelContext::GetInput")]] const OrtValue* KernelContext_GetInput(const OrtKernelContext* context, _In_ size_t index);
[[deprecated("use Ort::KernelContext::GetOutputCount")]] size_t KernelContext_GetOutputCount(const OrtKernelContext* context);
[[deprecated("use Ort::KernelContext::GetOutput")]] OrtValue* KernelContext_GetOutput(OrtKernelContext* context, _In_ size_t index, _In_ const int64_t* dim_values, size_t dim_count);
[[deprecated("use Ort::KernelContext::GetGPUComputeStream")]] void* KernelContext_GetGPUComputeStream(const OrtKernelContext* context);
[[deprecated("use Ort::ThrowOnError()")]] void ThrowOnError(OrtStatus* result);
[[deprecated("use Ort::OpAttr")]] OrtOpAttr* CreateOpAttr(_In_ const char* name,
_In_ const void* data,
_In_ int len,
_In_ OrtOpAttrType type);
[[deprecated("use Ort::OpAttr")]] void ReleaseOpAttr(_Frees_ptr_opt_ OrtOpAttr* op_attr);
[[deprecated("use Ort::Op")]] OrtOp* CreateOp(_In_ const OrtKernelInfo* info,
_In_ const char* op_name,
_In_ const char* domain,
_In_ int version,
_In_opt_ const char** type_constraint_names,
_In_opt_ const ONNXTensorElementDataType* type_constraint_values,
_In_opt_ int type_constraint_count,
_In_opt_ const OrtOpAttr* const* attr_values,
_In_opt_ int attr_count,
_In_ int input_count,
_In_ int output_count);
[[deprecated("use Ort::Op::Invoke")]] void InvokeOp(_In_ const OrtKernelContext* context,
_In_ const OrtOp* ort_op,
_In_ const OrtValue* const* input_values,
_In_ int input_count,
_Inout_ OrtValue* const* output_values,
_In_ int output_count);
[[deprecated("use Ort::Op")]] void ReleaseOp(_Frees_ptr_opt_ OrtOp* ort_op);
template <typename T> // T is only implemented for std::vector<float>, std::vector<int64_t>, float, int64_t, and string
[[deprecated("use Ort::KernelInfo::GetAttribute")]] T KernelInfoGetAttribute(_In_ const OrtKernelInfo* info, _In_ const char* name);
[[deprecated("use Ort::KernelInfo::Copy")]] OrtKernelInfo* CopyKernelInfo(_In_ const OrtKernelInfo* info);
[[deprecated("use Ort::KernelInfo")]] void ReleaseKernelInfo(_Frees_ptr_opt_ OrtKernelInfo* info_copy);
private:
const OrtApi& api_;
};
template <typename TOp, typename TKernel>
struct CustomOpBase : OrtCustomOp {
CustomOpBase() {
OrtCustomOp::version = ORT_API_VERSION;
OrtCustomOp::CreateKernel = [](const OrtCustomOp* this_, const OrtApi* api, const OrtKernelInfo* info) { return static_cast<const TOp*>(this_)->CreateKernel(*api, info); };
OrtCustomOp::GetName = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetName(); };
OrtCustomOp::GetExecutionProviderType = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetExecutionProviderType(); };
OrtCustomOp::GetInputTypeCount = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetInputTypeCount(); };
OrtCustomOp::GetInputType = [](const OrtCustomOp* this_, size_t index) { return static_cast<const TOp*>(this_)->GetInputType(index); };
OrtCustomOp::GetInputMemoryType = [](const OrtCustomOp* this_, size_t index) { return static_cast<const TOp*>(this_)->GetInputMemoryType(index); };
OrtCustomOp::GetOutputTypeCount = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetOutputTypeCount(); };
OrtCustomOp::GetOutputType = [](const OrtCustomOp* this_, size_t index) { return static_cast<const TOp*>(this_)->GetOutputType(index); };
OrtCustomOp::KernelCompute = [](void* op_kernel, OrtKernelContext* context) { static_cast<TKernel*>(op_kernel)->Compute(context); };
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 26409)
#endif
OrtCustomOp::KernelDestroy = [](void* op_kernel) { delete static_cast<TKernel*>(op_kernel); };
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
OrtCustomOp::GetInputCharacteristic = [](const OrtCustomOp* this_, size_t index) { return static_cast<const TOp*>(this_)->GetInputCharacteristic(index); };
OrtCustomOp::GetOutputCharacteristic = [](const OrtCustomOp* this_, size_t index) { return static_cast<const TOp*>(this_)->GetOutputCharacteristic(index); };
OrtCustomOp::GetVariadicInputMinArity = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetVariadicInputMinArity(); };
OrtCustomOp::GetVariadicInputHomogeneity = [](const OrtCustomOp* this_) { return static_cast<int>(static_cast<const TOp*>(this_)->GetVariadicInputHomogeneity()); };
OrtCustomOp::GetVariadicOutputMinArity = [](const OrtCustomOp* this_) { return static_cast<const TOp*>(this_)->GetVariadicOutputMinArity(); };
OrtCustomOp::GetVariadicOutputHomogeneity = [](const OrtCustomOp* this_) { return static_cast<int>(static_cast<const TOp*>(this_)->GetVariadicOutputHomogeneity()); };
}
// Default implementation of GetExecutionProviderType that returns nullptr to default to the CPU provider
const char* GetExecutionProviderType() const { return nullptr; }
// Default implementations of GetInputCharacteristic() and GetOutputCharacteristic() below
// (inputs and outputs are required by default)
OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t /*index*/) const {
return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED;
}
OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t /*index*/) const {
return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED;
}
// Default implemention of GetInputMemoryType() that returns OrtMemTypeDefault
OrtMemType GetInputMemoryType(size_t /*index*/) const {
return OrtMemTypeDefault;
}
// Default implementation of GetVariadicInputMinArity() returns 1 to specify that a variadic input
// should expect at least 1 argument.
int GetVariadicInputMinArity() const {
return 1;
}
// Default implementation of GetVariadicInputHomegeneity() returns true to specify that all arguments
// to a variadic input should be of the same type.
bool GetVariadicInputHomogeneity() const {
return true;
}
// Default implementation of GetVariadicOutputMinArity() returns 1 to specify that a variadic output
// should produce at least 1 output value.
int GetVariadicOutputMinArity() const {
return 1;
}
// Default implementation of GetVariadicOutputHomegeneity() returns true to specify that all output values
// produced by a variadic output should be of the same type.
bool GetVariadicOutputHomogeneity() const {
return true;
}
// Declare list of session config entries used by this Custom Op.
// Implement this function in order to get configs from CustomOpBase::GetSessionConfigs().
// This default implementation returns an empty vector of config entries.
std::vector<std::string> GetSessionConfigKeys() const {
return std::vector<std::string>{};
}
protected:
// Helper function that returns a map of session config entries specified by CustomOpBase::GetSessionConfigKeys.
void GetSessionConfigs(std::unordered_map<std::string, std::string>& out, ConstSessionOptions options) const;
};
} // namespace Ort
#include "onnxruntime_cxx_inline.h"
OrtMemoryInfo
struct OrtMemoryInfo OrtMemoryInfo
Definition: onnxruntime_c_api.h:252
OrtKernelInfo
struct OrtKernelInfo OrtKernelInfo
Definition: onnxruntime_c_api.h:329
OrtLoggingLevel
OrtLoggingLevel
Logging severity levels.
Definition: onnxruntime_c_api.h:207
OrtMemoryInfoDeviceType
OrtMemoryInfoDeviceType
This mimics OrtDevice type constants so they can be returned in the API.
Definition: onnxruntime_c_api.h:353
OrtLoggingFunction
void(* OrtLoggingFunction)(void *param, OrtLoggingLevel severity, const char *category, const char *logid, const char *code_location, const char *message)
Definition: onnxruntime_c_api.h:294
OrtCustomJoinThreadFn
void(* OrtCustomJoinThreadFn)(OrtCustomThreadHandle ort_custom_thread_handle)
Custom thread join function.
Definition: onnxruntime_c_api.h:627
OrtCustomOpInputOutputCharacteristic
OrtCustomOpInputOutputCharacteristic
Definition: onnxruntime_c_api.h:3979
OrtTensorRTProviderOptionsV2
struct OrtTensorRTProviderOptionsV2 OrtTensorRTProviderOptionsV2
Definition: onnxruntime_c_api.h:268
OrtOpAttr
struct OrtOpAttr OrtOpAttr
Definition: onnxruntime_c_api.h:273
OrtThreadingOptions
struct OrtThreadingOptions OrtThreadingOptions
Definition: onnxruntime_c_api.h:265
OrtSequenceTypeInfo
struct OrtSequenceTypeInfo OrtSequenceTypeInfo
Definition: onnxruntime_c_api.h:262
OrtDnnlProviderOptions
struct OrtDnnlProviderOptions OrtDnnlProviderOptions
Definition: onnxruntime_c_api.h:271
OrtSparseIndicesFormat
OrtSparseIndicesFormat
Definition: onnxruntime_c_api.h:196
OrtPrepackedWeightsContainer
struct OrtPrepackedWeightsContainer OrtPrepackedWeightsContainer
Definition: onnxruntime_c_api.h:267
OrtCustomOpDomain
struct OrtCustomOpDomain OrtCustomOpDomain
Definition: onnxruntime_c_api.h:260
OrtIoBinding
struct OrtIoBinding OrtIoBinding
Definition: onnxruntime_c_api.h:253
OrtAllocatorType
OrtAllocatorType
Definition: onnxruntime_c_api.h:335
OrtOp
struct OrtOp OrtOp
Definition: onnxruntime_c_api.h:272
OrtModelMetadata
struct OrtModelMetadata OrtModelMetadata
Definition: onnxruntime_c_api.h:263
OrtTypeInfo
struct OrtTypeInfo OrtTypeInfo
Definition: onnxruntime_c_api.h:257
OrtTensorTypeAndShapeInfo
struct OrtTensorTypeAndShapeInfo OrtTensorTypeAndShapeInfo
Definition: onnxruntime_c_api.h:258
OrtCUDAProviderOptionsV2
struct OrtCUDAProviderOptionsV2 OrtCUDAProviderOptionsV2
Definition: onnxruntime_c_api.h:269
OrtKernelContext
struct OrtKernelContext OrtKernelContext
Definition: onnxruntime_c_api.h:331
OrtCANNProviderOptions
struct OrtCANNProviderOptions OrtCANNProviderOptions
Definition: onnxruntime_c_api.h:270
OrtSessionOptions
struct OrtSessionOptions OrtSessionOptions
Definition: onnxruntime_c_api.h:259
OrtValue
struct OrtValue OrtValue
Definition: onnxruntime_c_api.h:255
GraphOptimizationLevel
GraphOptimizationLevel
Graph optimization level.
Definition: onnxruntime_c_api.h:303
OrtMemType
OrtMemType
Memory types for allocated memory, execution provider specific types should be extended in each provi...
Definition: onnxruntime_c_api.h:344
OrtSparseFormat
OrtSparseFormat
Definition: onnxruntime_c_api.h:188
ONNXType
ONNXType
Definition: onnxruntime_c_api.h:176
OrtEnv
struct OrtEnv OrtEnv
Definition: onnxruntime_c_api.h:250
OrtErrorCode
OrtErrorCode
Definition: onnxruntime_c_api.h:215
OrtStatus
struct OrtStatus OrtStatus
Definition: onnxruntime_c_api.h:251
ORT_API_VERSION
#define ORT_API_VERSION
The API version defined in this header.
Definition: onnxruntime_c_api.h:33
OrtMapTypeInfo
struct OrtMapTypeInfo OrtMapTypeInfo
Definition: onnxruntime_c_api.h:261
OrtArenaCfg
struct OrtArenaCfg OrtArenaCfg
Definition: onnxruntime_c_api.h:266
ExecutionMode
ExecutionMode
Definition: onnxruntime_c_api.h:310
OrtOpAttrType
OrtOpAttrType
Definition: onnxruntime_c_api.h:230
OrtCustomCreateThreadFn
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:620
ONNXTensorElementDataType
ONNXTensorElementDataType
Definition: onnxruntime_c_api.h:155
OrtGetApiBase
const OrtApiBase * OrtGetApiBase(void)
The Onnxruntime library's entry point to access the C API.
ORT_LOGGING_LEVEL_WARNING
@ ORT_LOGGING_LEVEL_WARNING
Warning messages.
Definition: onnxruntime_c_api.h:210
OrtMemTypeDefault
@ OrtMemTypeDefault
The default allocator for execution provider.
Definition: onnxruntime_c_api.h:348
Ort::detail::attr_utils::GetAttr
void GetAttr(const OrtKernelInfo *p, const char *name, float &)
Ort::detail::attr_utils::GetAttrs
void GetAttrs(const OrtKernelInfo *p, const char *name, std::vector< float > &)
Ort::detail::binding_utils::GetOutputValuesHelper
std::vector< Value > GetOutputValuesHelper(const OrtIoBinding *binding, OrtAllocator *)
Ort::detail::binding_utils::GetOutputNamesHelper
std::vector< std::string > GetOutputNamesHelper(const OrtIoBinding *binding, OrtAllocator *)
Ort::detail::OrtRelease
void OrtRelease(OrtAllocator *ptr)
Definition: onnxruntime_cxx_api.h:205
Ort::detail::MakeCustomOpConfigEntryKey
std::string MakeCustomOpConfigEntryKey(const char *custom_op_name, const char *config)
Ort
All C++ Onnxruntime APIs are defined inside this namespace.
Definition: onnxruntime_cxx_api.h:44
Ort::AllocatedStringPtr
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:345
Ort::GetApi
const OrtApi & GetApi()
This returns a reference to the OrtApi interface in use.
Definition: onnxruntime_cxx_api.h:121
Ort::GetAvailableProviders
std::vector< std::string > GetAvailableProviders()
This is a C++ wrapper for OrtApi::GetAvailableProviders() and returns a vector of strings representin...
Ort::Allocator
Wrapper around OrtAllocator.
Definition: onnxruntime_cxx_api.h:1412
Ort::Allocator::Allocator
Allocator(const Session &session, const OrtMemoryInfo *)
Ort::Allocator::Allocator
Allocator(std::nullptr_t)
Convenience to create a class member and then replace with an instance.
Definition: onnxruntime_cxx_api.h:1413
Ort::AllocatorWithDefaultOptions
Wrapper around OrtAllocator default instance that is owned by Onnxruntime.
Definition: onnxruntime_cxx_api.h:1404
Ort::AllocatorWithDefaultOptions::AllocatorWithDefaultOptions
AllocatorWithDefaultOptions(std::nullptr_t)
Convenience to create a class member and then replace with an instance.
Definition: onnxruntime_cxx_api.h:1405
Ort::AllocatorWithDefaultOptions::AllocatorWithDefaultOptions
AllocatorWithDefaultOptions()
Ort::ArenaCfg
it is a structure that represents the configuration of an arena based allocator
Definition: onnxruntime_cxx_api.h:1470
Ort::ArenaCfg::ArenaCfg
ArenaCfg(std::nullptr_t)
Create an empty ArenaCfg object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:1471
Ort::ArenaCfg::ArenaCfg
ArenaCfg(size_t max_mem, int arena_extend_strategy, int initial_chunk_size_bytes, int max_dead_bytes_per_chunk)
Ort::BFloat16_t
bfloat16 (Brain Floating Point) data type
Definition: onnxruntime_cxx_api.h:188
Ort::BFloat16_t::value
uint16_t value
Definition: onnxruntime_cxx_api.h:189
Ort::BFloat16_t::operator!=
constexpr bool operator!=(const BFloat16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:194
Ort::BFloat16_t::BFloat16_t
constexpr BFloat16_t(uint16_t v) noexcept
Definition: onnxruntime_cxx_api.h:191
Ort::BFloat16_t::operator==
constexpr bool operator==(const BFloat16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:193
Ort::BFloat16_t::BFloat16_t
constexpr BFloat16_t() noexcept
Definition: onnxruntime_cxx_api.h:190
Ort::CustomOpApi
This entire structure is deprecated, but we not marking it as a whole yet since we want to preserve f...
Definition: onnxruntime_cxx_api.h:1607
Ort::CustomOpApi::KernelContext_GetOutputCount
size_t KernelContext_GetOutputCount(const OrtKernelContext *context)
Ort::CustomOpApi::GetDimensionsCount
size_t GetDimensionsCount(const OrtTensorTypeAndShapeInfo *info)
Ort::CustomOpApi::KernelContext_GetGPUComputeStream
void * KernelContext_GetGPUComputeStream(const OrtKernelContext *context)
Ort::CustomOpApi::KernelContext_GetInputCount
size_t KernelContext_GetInputCount(const OrtKernelContext *context)
Ort::CustomOpApi::InvokeOp
void InvokeOp(const OrtKernelContext *context, const OrtOp *ort_op, const OrtValue *const *input_values, int input_count, OrtValue *const *output_values, int output_count)
Ort::CustomOpApi::CreateOpAttr
OrtOpAttr * CreateOpAttr(const char *name, const void *data, int len, OrtOpAttrType type)
Ort::CustomOpApi::ReleaseOp
void ReleaseOp(OrtOp *ort_op)
Ort::CustomOpApi::KernelContext_GetOutput
OrtValue * KernelContext_GetOutput(OrtKernelContext *context, size_t index, const int64_t *dim_values, size_t dim_count)
Ort::CustomOpApi::ReleaseTensorTypeAndShapeInfo
void ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo *input)
Ort::CustomOpApi::KernelInfoGetAttribute
T KernelInfoGetAttribute(const OrtKernelInfo *info, const char *name)
Ort::CustomOpApi::GetTensorTypeAndShape
OrtTensorTypeAndShapeInfo * GetTensorTypeAndShape(const OrtValue *value)
Ort::CustomOpApi::GetTensorShape
std::vector< int64_t > GetTensorShape(const OrtTensorTypeAndShapeInfo *info)
Ort::CustomOpApi::GetDimensions
void GetDimensions(const OrtTensorTypeAndShapeInfo *info, int64_t *dim_values, size_t dim_values_length)
Ort::CustomOpApi::ReleaseOpAttr
void ReleaseOpAttr(OrtOpAttr *op_attr)
Ort::CustomOpApi::ThrowOnError
void ThrowOnError(OrtStatus *result)
Ort::CustomOpApi::GetTensorShapeElementCount
size_t GetTensorShapeElementCount(const OrtTensorTypeAndShapeInfo *info)
Ort::CustomOpApi::GetTensorElementType
ONNXTensorElementDataType GetTensorElementType(const OrtTensorTypeAndShapeInfo *info)
Ort::CustomOpApi::CreateOp
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)
Ort::CustomOpApi::CustomOpApi
CustomOpApi(const OrtApi &api)
Definition: onnxruntime_cxx_api.h:1608
Ort::CustomOpApi::SetDimensions
void SetDimensions(OrtTensorTypeAndShapeInfo *info, const int64_t *dim_values, size_t dim_count)
Ort::CustomOpApi::CopyKernelInfo
OrtKernelInfo * CopyKernelInfo(const OrtKernelInfo *info)
Ort::CustomOpApi::ReleaseKernelInfo
void ReleaseKernelInfo(OrtKernelInfo *info_copy)
Ort::CustomOpApi::GetTensorMutableData
T * GetTensorMutableData(OrtValue *value)
Ort::CustomOpApi::KernelContext_GetInput
const OrtValue * KernelContext_GetInput(const OrtKernelContext *context, size_t index)
Ort::CustomOpApi::GetTensorMemoryInfo
const OrtMemoryInfo * GetTensorMemoryInfo(const OrtValue *value)
Ort::CustomOpApi::GetTensorData
const T * GetTensorData(const OrtValue *value)
Ort::CustomOpBase
Definition: onnxruntime_cxx_api.h:1789
Ort::CustomOpBase::GetSessionConfigKeys
std::vector< std::string > GetSessionConfigKeys() const
Definition: onnxruntime_cxx_api.h:1867
Ort::CustomOpBase::GetOutputCharacteristic
OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t) const
Definition: onnxruntime_cxx_api.h:1831
Ort::CustomOpBase::GetVariadicInputHomogeneity
bool GetVariadicInputHomogeneity() const
Definition: onnxruntime_cxx_api.h:1848
Ort::CustomOpBase::CustomOpBase
CustomOpBase()
Definition: onnxruntime_cxx_api.h:1790
Ort::CustomOpBase::GetVariadicOutputHomogeneity
bool GetVariadicOutputHomogeneity() const
Definition: onnxruntime_cxx_api.h:1860
Ort::CustomOpBase::GetInputMemoryType
OrtMemType GetInputMemoryType(size_t) const
Definition: onnxruntime_cxx_api.h:1836
Ort::CustomOpBase::GetVariadicInputMinArity
int GetVariadicInputMinArity() const
Definition: onnxruntime_cxx_api.h:1842
Ort::CustomOpBase::GetExecutionProviderType
const char * GetExecutionProviderType() const
Definition: onnxruntime_cxx_api.h:1823
Ort::CustomOpBase::GetVariadicOutputMinArity
int GetVariadicOutputMinArity() const
Definition: onnxruntime_cxx_api.h:1854
Ort::CustomOpBase::GetInputCharacteristic
OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t) const
Definition: onnxruntime_cxx_api.h:1827
Ort::CustomOpBase::GetSessionConfigs
void GetSessionConfigs(std::unordered_map< std::string, std::string > &out, ConstSessionOptions options) const
Ort::CustomOpConfigs
Class that represents session configuration entries for one or more custom operators.
Definition: onnxruntime_cxx_api.h:483
Ort::CustomOpConfigs::~CustomOpConfigs
~CustomOpConfigs()=default
Ort::CustomOpConfigs::AddConfig
CustomOpConfigs & AddConfig(const char *custom_op_name, const char *config_key, const char *config_value)
Adds a session configuration entry/value for a specific custom operator.
Ort::CustomOpConfigs::operator=
CustomOpConfigs & operator=(CustomOpConfigs &&o)=default
Ort::CustomOpConfigs::CustomOpConfigs
CustomOpConfigs(CustomOpConfigs &&o)=default
Ort::CustomOpConfigs::CustomOpConfigs
CustomOpConfigs()=default
Ort::CustomOpConfigs::GetFlattenedConfigs
const std::unordered_map< std::string, std::string > & GetFlattenedConfigs() const
Returns a flattened map of custom operator configuration entries and their values.
Ort::CustomOpConfigs::CustomOpConfigs
CustomOpConfigs(const CustomOpConfigs &)=default
Ort::CustomOpConfigs::operator=
CustomOpConfigs & operator=(const CustomOpConfigs &)=default
Ort::CustomOpDomain
Custom Op Domain.
Definition: onnxruntime_cxx_api.h:425
Ort::CustomOpDomain::CustomOpDomain
CustomOpDomain(std::nullptr_t)
Create an empty CustomOpDomain object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:426
Ort::CustomOpDomain::CustomOpDomain
CustomOpDomain(const char *domain)
Wraps OrtApi::CreateCustomOpDomain.
Ort::CustomOpDomain::Add
void Add(const OrtCustomOp *op)
Wraps CustomOpDomain_Add.
Ort::Env
The Env (Environment)
Definition: onnxruntime_cxx_api.h:395
Ort::Env::EnableTelemetryEvents
Env & EnableTelemetryEvents()
Wraps OrtApi::EnableTelemetryEvents.
Ort::Env::Env
Env(OrtEnv *p)
C Interop Helper.
Definition: onnxruntime_cxx_api.h:412
Ort::Env::Env
Env(std::nullptr_t)
Create an empty Env object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:396
Ort::Env::Env
Env(OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnv.
Ort::Env::Env
Env(const OrtThreadingOptions *tp_options, OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnvWithGlobalThreadPools.
Ort::Env::Env
Env(const OrtThreadingOptions *tp_options, OrtLoggingFunction logging_function, void *logger_param, OrtLoggingLevel logging_level=ORT_LOGGING_LEVEL_WARNING, const char *logid="")
Wraps OrtApi::CreateEnvWithCustomLoggerAndGlobalThreadPools.
Ort::Env::Env
Env(OrtLoggingLevel logging_level, const char *logid, OrtLoggingFunction logging_function, void *logger_param)
Wraps OrtApi::CreateEnvWithCustomLogger.
Ort::Env::CreateAndRegisterAllocator
Env & CreateAndRegisterAllocator(const OrtMemoryInfo *mem_info, const OrtArenaCfg *arena_cfg)
Wraps OrtApi::CreateAndRegisterAllocator.
Ort::Env::UpdateEnvWithCustomLogLevel
Env & UpdateEnvWithCustomLogLevel(OrtLoggingLevel log_severity_level)
Wraps OrtApi::UpdateEnvWithCustomLogLevel.
Ort::Env::DisableTelemetryEvents
Env & DisableTelemetryEvents()
Wraps OrtApi::DisableTelemetryEvents.
Ort::Exception
All C++ methods that can fail will throw an exception of this type.
Definition: onnxruntime_cxx_api.h:50
Ort::Exception::what
const char * what() const noexcept override
Definition: onnxruntime_cxx_api.h:54
Ort::Exception::GetOrtErrorCode
OrtErrorCode GetOrtErrorCode() const
Definition: onnxruntime_cxx_api.h:53
Ort::Exception::Exception
Exception(std::string &&string, OrtErrorCode code)
Definition: onnxruntime_cxx_api.h:51
Ort::Float16_t
IEEE 754 half-precision floating point data type.
Definition: onnxruntime_cxx_api.h:169
Ort::Float16_t::operator!=
constexpr bool operator!=(const Float16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:175
Ort::Float16_t::Float16_t
constexpr Float16_t(uint16_t v) noexcept
Definition: onnxruntime_cxx_api.h:172
Ort::Float16_t::value
uint16_t value
Definition: onnxruntime_cxx_api.h:170
Ort::Float16_t::operator==
constexpr bool operator==(const Float16_t &rhs) const noexcept
Definition: onnxruntime_cxx_api.h:174
Ort::Float16_t::Float16_t
constexpr Float16_t() noexcept
Definition: onnxruntime_cxx_api.h:171
Ort::Global
Definition: onnxruntime_cxx_api.h:82
Ort::Global::api_
static const OrtApi * api_
Definition: onnxruntime_cxx_api.h:83
Ort::IoBinding
Wrapper around OrtIoBinding.
Definition: onnxruntime_cxx_api.h:1459
Ort::IoBinding::GetUnowned
UnownedIoBinding GetUnowned() const
Definition: onnxruntime_cxx_api.h:1463
Ort::IoBinding::GetConst
ConstIoBinding GetConst() const
Definition: onnxruntime_cxx_api.h:1462
Ort::IoBinding::IoBinding
IoBinding(Session &session)
Ort::IoBinding::IoBinding
IoBinding(std::nullptr_t)
Create an empty object for convenience. Sometimes, we want to initialize members later.
Definition: onnxruntime_cxx_api.h:1460
Ort::KernelContext
This class wraps a raw pointer OrtKernelContext* that is being passed to the custom kernel Compute() ...
Definition: onnxruntime_cxx_api.h:1500
Ort::KernelContext::KernelContext
KernelContext(OrtKernelContext *context)
Ort::KernelContext::GetInput
ConstValue GetInput(size_t index) const
Ort::KernelContext::GetGPUComputeStream
void * GetGPUComputeStream() const
Ort::KernelContext::GetInputCount
size_t GetInputCount() const
Ort::KernelContext::GetOutputCount
size_t GetOutputCount() const
Ort::KernelContext::GetOutput
UnownedValue GetOutput(size_t index, const std::vector< int64_t > &dims) const
Ort::KernelContext::GetOutput
UnownedValue GetOutput(size_t index, const int64_t *dim_values, size_t dim_count) const
Ort::KernelInfo
This struct owns the OrtKernInfo* pointer when a copy is made. For convenient wrapping of OrtKernelIn...
Definition: onnxruntime_cxx_api.h:1567
Ort::KernelInfo::KernelInfo
KernelInfo(OrtKernelInfo *info)
Take ownership of the instance.
Ort::KernelInfo::GetConst
ConstKernelInfo GetConst() const
Definition: onnxruntime_cxx_api.h:1570
Ort::KernelInfo::KernelInfo
KernelInfo(std::nullptr_t)
Create an empty instance to initialize later.
Definition: onnxruntime_cxx_api.h:1568
Ort::MapTypeInfo
Wrapper around OrtMapTypeInfo.
Definition: onnxruntime_cxx_api.h:900
Ort::MapTypeInfo::GetConst
ConstMapTypeInfo GetConst() const
Definition: onnxruntime_cxx_api.h:903
Ort::MapTypeInfo::MapTypeInfo
MapTypeInfo(OrtMapTypeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:902
Ort::MapTypeInfo::MapTypeInfo
MapTypeInfo(std::nullptr_t)
Create an empty MapTypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:901
Ort::MemoryAllocation
Represents native memory allocation coming from one of the OrtAllocators registered with OnnxRuntime....
Definition: onnxruntime_cxx_api.h:1370
Ort::MemoryAllocation::MemoryAllocation
MemoryAllocation(MemoryAllocation &&) noexcept
Ort::MemoryAllocation::operator=
MemoryAllocation & operator=(const MemoryAllocation &)=delete
Ort::MemoryAllocation::get
void * get()
Definition: onnxruntime_cxx_api.h:1378
Ort::MemoryAllocation::~MemoryAllocation
~MemoryAllocation()
Ort::MemoryAllocation::MemoryAllocation
MemoryAllocation(const MemoryAllocation &)=delete
Ort::MemoryAllocation::MemoryAllocation
MemoryAllocation(OrtAllocator *allocator, void *p, size_t size)
Ort::MemoryAllocation::size
size_t size() const
Definition: onnxruntime_cxx_api.h:1379
Ort::MemoryInfo
Wrapper around OrtMemoryInfo.
Definition: onnxruntime_cxx_api.h:820
Ort::MemoryInfo::MemoryInfo
MemoryInfo(const char *name, OrtAllocatorType type, int id, OrtMemType mem_type)
Ort::MemoryInfo::MemoryInfo
MemoryInfo(std::nullptr_t)
No instance is created.
Definition: onnxruntime_cxx_api.h:822
Ort::MemoryInfo::MemoryInfo
MemoryInfo(OrtMemoryInfo *p)
Take ownership of a pointer created by C Api.
Definition: onnxruntime_cxx_api.h:823
Ort::MemoryInfo::CreateCpu
static MemoryInfo CreateCpu(OrtAllocatorType type, OrtMemType mem_type1)
Ort::MemoryInfo::GetConst
ConstMemoryInfo GetConst() const
Definition: onnxruntime_cxx_api.h:825
Ort::ModelMetadata
Wrapper around OrtModelMetadata.
Definition: onnxruntime_cxx_api.h:618
Ort::ModelMetadata::GetDescriptionAllocated
AllocatedStringPtr GetDescriptionAllocated(OrtAllocator *allocator) const
Returns a copy of the description.
Ort::ModelMetadata::GetCustomMetadataMapKeysAllocated
std::vector< AllocatedStringPtr > GetCustomMetadataMapKeysAllocated(OrtAllocator *allocator) const
Returns a vector of copies of the custom metadata keys.
Ort::ModelMetadata::ModelMetadata
ModelMetadata(std::nullptr_t)
Create an empty ModelMetadata object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:619
Ort::ModelMetadata::GetGraphDescriptionAllocated
AllocatedStringPtr GetGraphDescriptionAllocated(OrtAllocator *allocator) const
Returns a copy of the graph description.
Ort::ModelMetadata::GetProducerNameAllocated
AllocatedStringPtr GetProducerNameAllocated(OrtAllocator *allocator) const
Returns a copy of the producer name.
Ort::ModelMetadata::GetGraphNameAllocated
AllocatedStringPtr GetGraphNameAllocated(OrtAllocator *allocator) const
Returns a copy of the graph name.
Ort::ModelMetadata::LookupCustomMetadataMapAllocated
AllocatedStringPtr LookupCustomMetadataMapAllocated(const char *key, OrtAllocator *allocator) const
Looks up a value by a key in the Custom Metadata map.
Ort::ModelMetadata::ModelMetadata
ModelMetadata(OrtModelMetadata *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:620
Ort::ModelMetadata::GetDomainAllocated
AllocatedStringPtr GetDomainAllocated(OrtAllocator *allocator) const
Returns a copy of the domain name.
Ort::ModelMetadata::GetVersion
int64_t GetVersion() const
Wraps OrtApi::ModelMetadataGetVersion.
Ort::OpAttr
This struct provides life time management for custom op attribute.
Definition: onnxruntime_cxx_api.h:1490
Ort::OpAttr::OpAttr
OpAttr(const char *name, const void *data, int len, OrtOpAttrType type)
Ort::Op
Create and own custom defined operation.
Definition: onnxruntime_cxx_api.h:1576
Ort::Op::Op
Op(OrtOp *)
Take ownership of the OrtOp.
Ort::Op::Create
static Op Create(const OrtKernelInfo *info, const char *op_name, const char *domain, int version, const char **type_constraint_names, const ONNXTensorElementDataType *type_constraint_values, size_t type_constraint_count, const OpAttr *attr_values, size_t attr_count, size_t input_count, size_t output_count)
Ort::Op::Op
Op(std::nullptr_t)
Create an empty Operator object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:1577
Ort::Op::Invoke
void Invoke(const OrtKernelContext *context, const OrtValue *const *input_values, size_t input_count, OrtValue *const *output_values, size_t output_count)
Ort::Op::Invoke
void Invoke(const OrtKernelContext *context, const Value *input_values, size_t input_count, Value *output_values, size_t output_count)
Ort::RunOptions
RunOptions.
Definition: onnxruntime_cxx_api.h:438
Ort::RunOptions::GetRunLogSeverityLevel
int GetRunLogSeverityLevel() const
Wraps OrtApi::RunOptionsGetRunLogSeverityLevel.
Ort::RunOptions::SetTerminate
RunOptions & SetTerminate()
Terminates all currently executing Session::Run calls that were made using this RunOptions instance.
Ort::RunOptions::SetRunTag
RunOptions & SetRunTag(const char *run_tag)
wraps OrtApi::RunOptionsSetRunTag
Ort::RunOptions::UnsetTerminate
RunOptions & UnsetTerminate()
Clears the terminate flag so this RunOptions instance can be used in a new Session::Run call without ...
Ort::RunOptions::GetRunLogVerbosityLevel
int GetRunLogVerbosityLevel() const
Wraps OrtApi::RunOptionsGetRunLogVerbosityLevel.
Ort::RunOptions::RunOptions
RunOptions(std::nullptr_t)
Create an empty RunOptions object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:439
Ort::RunOptions::SetRunLogVerbosityLevel
RunOptions & SetRunLogVerbosityLevel(int)
Wraps OrtApi::RunOptionsSetRunLogVerbosityLevel.
Ort::RunOptions::SetRunLogSeverityLevel
RunOptions & SetRunLogSeverityLevel(int)
Wraps OrtApi::RunOptionsSetRunLogSeverityLevel.
Ort::RunOptions::AddConfigEntry
RunOptions & AddConfigEntry(const char *config_key, const char *config_value)
Wraps OrtApi::AddRunConfigEntry.
Ort::RunOptions::GetRunTag
const char * GetRunTag() const
Wraps OrtApi::RunOptionsGetRunTag.
Ort::RunOptions::RunOptions
RunOptions()
Wraps OrtApi::CreateRunOptions.
Ort::SequenceTypeInfo
Wrapper around OrtSequenceTypeInfo.
Definition: onnxruntime_cxx_api.h:878
Ort::SequenceTypeInfo::SequenceTypeInfo
SequenceTypeInfo(std::nullptr_t)
Create an empty SequenceTypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:879
Ort::SequenceTypeInfo::GetConst
ConstSequenceTypeInfo GetConst() const
Definition: onnxruntime_cxx_api.h:881
Ort::SequenceTypeInfo::SequenceTypeInfo
SequenceTypeInfo(OrtSequenceTypeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:880
Ort::Session
Wrapper around OrtSession.
Definition: onnxruntime_cxx_api.h:784
Ort::Session::Session
Session(std::nullptr_t)
Create an empty Session object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:785
Ort::Session::GetUnowned
UnownedSession GetUnowned() const
Definition: onnxruntime_cxx_api.h:794
Ort::Session::Session
Session(const Env &env, const char *model_path, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer.
Ort::Session::Session
Session(const Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
Wraps OrtApi::CreateSessionFromArrayWithPrepackedWeightsContainer.
Ort::Session::Session
Session(const Env &env, const char *model_path, const SessionOptions &options)
Wraps OrtApi::CreateSession.
Ort::Session::GetConst
ConstSession GetConst() const
Definition: onnxruntime_cxx_api.h:793
Ort::Session::Session
Session(const Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options)
Wraps OrtApi::CreateSessionFromArray.
Ort::SessionOptions
Wrapper around OrtSessionOptions.
Definition: onnxruntime_cxx_api.h:607
Ort::SessionOptions::SessionOptions
SessionOptions(std::nullptr_t)
Create an empty SessionOptions object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:608
Ort::SessionOptions::GetUnowned
UnownedSessionOptions GetUnowned() const
Definition: onnxruntime_cxx_api.h:611
Ort::SessionOptions::SessionOptions
SessionOptions()
Wraps OrtApi::CreateSessionOptions.
Ort::SessionOptions::GetConst
ConstSessionOptions GetConst() const
Definition: onnxruntime_cxx_api.h:612
Ort::SessionOptions::SessionOptions
SessionOptions(OrtSessionOptions *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:610
Ort::Status
The Status that holds ownership of OrtStatus received from C API Use it to safely destroy OrtStatus* ...
Definition: onnxruntime_cxx_api.h:351
Ort::Status::GetErrorCode
OrtErrorCode GetErrorCode() const
Ort::Status::Status
Status(const Exception &)
Creates status instance out of exception.
Ort::Status::Status
Status(OrtStatus *status)
Takes ownership of OrtStatus instance returned from the C API. Must be non-null.
Ort::Status::GetErrorMessage
std::string GetErrorMessage() const
Ort::Status::Status
Status(const std::exception &)
Creates status instance out of exception.
Ort::Status::Status
Status(std::nullptr_t)
Create an empty object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:352
Ort::TensorTypeAndShapeInfo
Wrapper around OrtTensorTypeAndShapeInfo.
Definition: onnxruntime_cxx_api.h:857
Ort::TensorTypeAndShapeInfo::TensorTypeAndShapeInfo
TensorTypeAndShapeInfo(std::nullptr_t)
Create an empty TensorTypeAndShapeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:858
Ort::TensorTypeAndShapeInfo::GetConst
ConstTensorTypeAndShapeInfo GetConst() const
Definition: onnxruntime_cxx_api.h:860
Ort::TensorTypeAndShapeInfo::TensorTypeAndShapeInfo
TensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:859
Ort::ThreadingOptions
The ThreadingOptions.
Definition: onnxruntime_cxx_api.h:364
Ort::ThreadingOptions::SetGlobalCustomThreadCreationOptions
ThreadingOptions & SetGlobalCustomThreadCreationOptions(void *ort_custom_thread_creation_options)
Wraps OrtApi::SetGlobalCustomThreadCreationOptions.
Ort::ThreadingOptions::ThreadingOptions
ThreadingOptions()
Wraps OrtApi::CreateThreadingOptions.
Ort::ThreadingOptions::SetGlobalInterOpNumThreads
ThreadingOptions & SetGlobalInterOpNumThreads(int inter_op_num_threads)
Wraps OrtApi::SetGlobalInterOpNumThreads.
Ort::ThreadingOptions::SetGlobalCustomCreateThreadFn
ThreadingOptions & SetGlobalCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn)
Wraps OrtApi::SetGlobalCustomCreateThreadFn.
Ort::ThreadingOptions::SetGlobalCustomJoinThreadFn
ThreadingOptions & SetGlobalCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn)
Wraps OrtApi::SetGlobalCustomJoinThreadFn.
Ort::ThreadingOptions::SetGlobalSpinControl
ThreadingOptions & SetGlobalSpinControl(int allow_spinning)
Wraps OrtApi::SetGlobalSpinControl.
Ort::ThreadingOptions::SetGlobalDenormalAsZero
ThreadingOptions & SetGlobalDenormalAsZero()
Wraps OrtApi::SetGlobalDenormalAsZero.
Ort::ThreadingOptions::SetGlobalIntraOpNumThreads
ThreadingOptions & SetGlobalIntraOpNumThreads(int intra_op_num_threads)
Wraps OrtApi::SetGlobalIntraOpNumThreads.
Ort::TypeInfo
Type information that may contain either TensorTypeAndShapeInfo or the information about contained se...
Definition: onnxruntime_cxx_api.h:930
Ort::TypeInfo::TypeInfo
TypeInfo(std::nullptr_t)
Create an empty TypeInfo object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:931
Ort::TypeInfo::GetConst
ConstTypeInfo GetConst() const
Definition: onnxruntime_cxx_api.h:934
Ort::TypeInfo::TypeInfo
TypeInfo(OrtTypeInfo *p)
C API Interop.
Definition: onnxruntime_cxx_api.h:932
Ort::Value
Wrapper around OrtValue.
Definition: onnxruntime_cxx_api.h:1244
Ort::Value::CreateMap
static Value CreateMap(Value &keys, Value &values)
Wraps OrtApi::CreateValue.
Ort::Value::CreateSparseTensor
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 ...
Ort::Value::CreateSparseTensor
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...
Ort::Value::operator=
Value & operator=(Value &&)=default
Ort::Value::CreateSparseTensor
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....
Ort::Value::Value
Value(Value &&)=default
Ort::Value::Value
Value(std::nullptr_t)
Create an empty Value object, must be assigned a valid one to be used.
Definition: onnxruntime_cxx_api.h:1249
Ort::Value::CreateTensor
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.
Ort::Value::Value
Value(OrtValue *p)
Used for interop with the C API.
Definition: onnxruntime_cxx_api.h:1250
Ort::Value::CreateSparseTensor
static Value CreateSparseTensor(OrtAllocator *allocator, const Shape &dense_shape)
This is a simple forwarding method to the below CreateSparseTensor. This helps to specify data type e...
Ort::Value::CreateTensor
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.
Ort::Value::GetUnowned
UnownedValue GetUnowned() const
Definition: onnxruntime_cxx_api.h:1255
Ort::Value::CreateTensor
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.
Ort::Value::CreateOpaque
static Value CreateOpaque(const char *domain, const char *type_name, const T &)
Wraps OrtApi::CreateOpaqueValue.
Ort::Value::CreateTensor
static Value CreateTensor(OrtAllocator *allocator, const int64_t *shape, size_t shape_len)
Creates a tensor using a supplied OrtAllocator. Wraps OrtApi::CreateTensorAsOrtValue.
Ort::Value::CreateSequence
static Value CreateSequence(std::vector< Value > &values)
Wraps OrtApi::CreateValue.
Ort::Value::GetConst
ConstValue GetConst() const
Definition: onnxruntime_cxx_api.h:1254
Ort::detail::AllocatedFree
Definition: onnxruntime_cxx_api.h:324
Ort::detail::AllocatedFree::AllocatedFree
AllocatedFree(OrtAllocator *allocator)
Definition: onnxruntime_cxx_api.h:326
Ort::detail::AllocatedFree::allocator_
OrtAllocator * allocator_
Definition: onnxruntime_cxx_api.h:325
Ort::detail::AllocatedFree::operator()
void operator()(void *ptr) const
Definition: onnxruntime_cxx_api.h:328
Ort::detail::AllocatorImpl
Definition: onnxruntime_cxx_api.h:1389
Ort::detail::AllocatorImpl::GetInfo
ConstMemoryInfo GetInfo() const
Ort::detail::AllocatorImpl::Alloc
void * Alloc(size_t size)
Ort::detail::AllocatorImpl::Free
void Free(void *p)
Ort::detail::AllocatorImpl::GetAllocation
MemoryAllocation GetAllocation(size_t size)
Ort::detail::Base< Unowned< T > >::~Base
~Base()=default
Ort::detail::Base< Unowned< T > >::operator=
Base & operator=(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:311
Ort::detail::Base< Unowned< T > >::contained_type
typename Unowned< T >::Type contained_type
Definition: onnxruntime_cxx_api.h:300
Ort::detail::Base< Unowned< T > >::Base
constexpr Base()=default
Ort::detail::Base< Unowned< T > >::Base
Base(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:310
Ort::detail::Base< Unowned< T > >::Base
Base(const Base &)=default
Ort::detail::Base< Unowned< T > >::Base
constexpr Base(contained_type *p) noexcept
Definition: onnxruntime_cxx_api.h:303
Ort::detail::Base< Unowned< T > >::operator=
Base & operator=(const Base &)=default
Ort::detail::Base
Used internally by the C++ API. C++ wrapper types inherit from this. This is a zero cost abstraction ...
Definition: onnxruntime_cxx_api.h:256
Ort::detail::Base::Base
Base(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:266
Ort::detail::Base::Base
constexpr Base()=default
Ort::detail::Base::release
contained_type * release()
Relinquishes ownership of the contained C object pointer The underlying object is not destroyed.
Definition: onnxruntime_cxx_api.h:277
Ort::detail::Base::Base
Base(const Base &)=delete
Ort::detail::Base::Base
constexpr Base(contained_type *p) noexcept
Definition: onnxruntime_cxx_api.h:260
Ort::detail::Base::operator=
Base & operator=(const Base &)=delete
Ort::detail::Base::operator=
Base & operator=(Base &&v) noexcept
Definition: onnxruntime_cxx_api.h:267
Ort::detail::Base::p_
contained_type * p_
Definition: onnxruntime_cxx_api.h:284
Ort::detail::Base::~Base
~Base()
Definition: onnxruntime_cxx_api.h:261
Ort::detail::Base::contained_type
T contained_type
Definition: onnxruntime_cxx_api.h:257
Ort::detail::ConstIoBindingImpl
Definition: onnxruntime_cxx_api.h:1427
Ort::detail::ConstIoBindingImpl::GetOutputValues
std::vector< Value > GetOutputValues(OrtAllocator *) const
Ort::detail::ConstIoBindingImpl::GetOutputNames
std::vector< std::string > GetOutputNames(OrtAllocator *) const
Ort::detail::ConstIoBindingImpl::GetOutputValues
std::vector< Value > GetOutputValues() const
Ort::detail::ConstIoBindingImpl::GetOutputNames
std::vector< std::string > GetOutputNames() const
Ort::detail::ConstSessionImpl
Definition: onnxruntime_cxx_api.h:691
Ort::detail::ConstSessionImpl::GetInputTypeInfo
TypeInfo GetInputTypeInfo(size_t index) const
Wraps OrtApi::SessionGetInputTypeInfo.
Ort::detail::ConstSessionImpl::GetOutputCount
size_t GetOutputCount() const
Returns the number of model outputs.
Ort::detail::ConstSessionImpl::GetProfilingStartTimeNs
uint64_t GetProfilingStartTimeNs() const
Wraps OrtApi::SessionGetProfilingStartTimeNs.
Ort::detail::ConstSessionImpl::GetModelMetadata
ModelMetadata GetModelMetadata() const
Wraps OrtApi::SessionGetModelMetadata.
Ort::detail::ConstSessionImpl::GetInputCount
size_t GetInputCount() const
Returns the number of model inputs.
Ort::detail::ConstSessionImpl::GetOutputTypeInfo
TypeInfo GetOutputTypeInfo(size_t index) const
Wraps OrtApi::SessionGetOutputTypeInfo.
Ort::detail::ConstSessionImpl::GetOverridableInitializerNameAllocated
AllocatedStringPtr GetOverridableInitializerNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of the overridable initializer name at then specified index.
Ort::detail::ConstSessionImpl::GetOutputNameAllocated
AllocatedStringPtr GetOutputNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of output name at then specified index.
Ort::detail::ConstSessionImpl::GetOverridableInitializerCount
size_t GetOverridableInitializerCount() const
Returns the number of inputs that have defaults that can be overridden.
Ort::detail::ConstSessionImpl::GetInputNameAllocated
AllocatedStringPtr GetInputNameAllocated(size_t index, OrtAllocator *allocator) const
Returns a copy of input name at the specified index.
Ort::detail::ConstSessionImpl::GetOverridableInitializerTypeInfo
TypeInfo GetOverridableInitializerTypeInfo(size_t index) const
Wraps OrtApi::SessionGetOverridableInitializerTypeInfo.
Ort::detail::ConstSessionOptionsImpl
Definition: onnxruntime_cxx_api.h:526
Ort::detail::ConstSessionOptionsImpl::GetConfigEntry
std::string GetConfigEntry(const char *config_key) const
Wraps OrtApi::GetSessionConfigEntry.
Ort::detail::ConstSessionOptionsImpl::GetConfigEntryOrDefault
std::string GetConfigEntryOrDefault(const char *config_key, const std::string &def)
Ort::detail::ConstSessionOptionsImpl::Clone
SessionOptions Clone() const
Creates and returns a copy of this SessionOptions object. Wraps OrtApi::CloneSessionOptions.
Ort::detail::ConstSessionOptionsImpl::HasConfigEntry
bool HasConfigEntry(const char *config_key) const
Wraps OrtApi::HasSessionConfigEntry.
Ort::detail::ConstValueImpl
Definition: onnxruntime_cxx_api.h:963
Ort::detail::ConstValueImpl::GetStringTensorContent
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...
Ort::detail::ConstValueImpl::GetStringTensorElement
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...
Ort::detail::ConstValueImpl::GetSparseTensorIndicesTypeShapeInfo
TensorTypeAndShapeInfo GetSparseTensorIndicesTypeShapeInfo(OrtSparseIndicesFormat format) const
The API returns type and shape information for the specified indices. Each supported indices have the...
Ort::detail::ConstValueImpl::GetTensorRawData
const void * GetTensorRawData() const
Returns a non-typed pointer to a tensor contained data.
Ort::detail::ConstValueImpl::GetStringTensorElementLength
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...
Ort::detail::ConstValueImpl::GetStringTensorDataLength
size_t GetStringTensorDataLength() const
This API returns a full length of string data contained within either a tensor or a sparse Tensor....
Ort::detail::ConstValueImpl::IsSparseTensor
bool IsSparseTensor() const
Returns true if the OrtValue contains a sparse tensor.
Ort::detail::ConstValueImpl::GetTypeInfo
TypeInfo GetTypeInfo() const
The API returns type information for data contained in a tensor. For sparse tensors it returns type i...
Ort::detail::ConstValueImpl::GetSparseTensorIndicesData
const R * 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...
Ort::detail::ConstValueImpl::IsTensor
bool IsTensor() const
Returns true if Value is a tensor, false for other types like map/sequence/etc.
Ort::detail::ConstValueImpl::GetTensorMemoryInfo
ConstMemoryInfo GetTensorMemoryInfo() const
This API returns information about the memory allocation used to hold data.
Ort::detail::ConstValueImpl::GetSparseTensorValues
const R * GetSparseTensorValues() const
The API returns a pointer to an internal buffer of the sparse tensor containing non-zero values....
Ort::detail::ConstValueImpl::GetTensorTypeAndShapeInfo
TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const
The API returns type information for data contained in a tensor. For sparse tensors it returns type i...
Ort::detail::ConstValueImpl::HasValue
bool HasValue() const
Ort::detail::ConstValueImpl::GetValue
Value GetValue(int index, OrtAllocator *allocator) const
Ort::detail::ConstValueImpl::GetCount
size_t GetCount() const
< Return true if OrtValue contains data and returns false if the OrtValue is a None
Ort::detail::ConstValueImpl::GetOpaqueData
void GetOpaqueData(const char *domain, const char *type_name, R &) const
Obtains a pointer to a user defined data for experimental purposes.
Ort::detail::ConstValueImpl::GetSparseTensorValuesTypeAndShapeInfo
TensorTypeAndShapeInfo GetSparseTensorValuesTypeAndShapeInfo() const
The API returns type and shape information for stored non-zero values of the sparse tensor....
Ort::detail::ConstValueImpl::GetTensorData
const R * GetTensorData() const
Returns a const typed pointer to the tensor contained data. No type checking is performed,...
Ort::detail::ConstValueImpl::GetSparseFormat
OrtSparseFormat GetSparseFormat() const
The API returns the sparse data format this OrtValue holds in a sparse tensor. If the sparse tensor w...
Ort::detail::IoBindingImpl
Definition: onnxruntime_cxx_api.h:1438
Ort::detail::IoBindingImpl::BindOutput
void BindOutput(const char *name, const Value &)
Ort::detail::IoBindingImpl::SynchronizeInputs
void SynchronizeInputs()
Ort::detail::IoBindingImpl::ClearBoundInputs
void ClearBoundInputs()
Ort::detail::IoBindingImpl::BindInput
void BindInput(const char *name, const Value &)
Ort::detail::IoBindingImpl::ClearBoundOutputs
void ClearBoundOutputs()
Ort::detail::IoBindingImpl::SynchronizeOutputs
void SynchronizeOutputs()
Ort::detail::IoBindingImpl::BindOutput
void BindOutput(const char *name, const OrtMemoryInfo *)
Ort::detail::KernelInfoImpl
Definition: onnxruntime_cxx_api.h:1525
Ort::detail::KernelInfoImpl::GetTensorAttribute
Value GetTensorAttribute(const char *name, OrtAllocator *allocator) const
Ort::detail::KernelInfoImpl::GetInputTypeInfo
TypeInfo GetInputTypeInfo(size_t index) const
Ort::detail::KernelInfoImpl::GetAttributes
std::vector< R > GetAttributes(const char *name) const
Definition: onnxruntime_cxx_api.h:1539
Ort::detail::KernelInfoImpl::GetAttribute
R GetAttribute(const char *name) const
Definition: onnxruntime_cxx_api.h:1532
Ort::detail::KernelInfoImpl::GetOutputTypeInfo
TypeInfo GetOutputTypeInfo(size_t index) const
Ort::detail::KernelInfoImpl::Copy
KernelInfo Copy() const
Ort::detail::KernelInfoImpl::GetInputName
std::string GetInputName(size_t index) const
Ort::detail::KernelInfoImpl::GetOutputCount
size_t GetOutputCount() const
Ort::detail::KernelInfoImpl::GetInputCount
size_t GetInputCount() const
Ort::detail::KernelInfoImpl::GetOutputName
std::string GetOutputName(size_t index) const
Ort::detail::MapTypeInfoImpl
Definition: onnxruntime_cxx_api.h:886
Ort::detail::MapTypeInfoImpl::GetMapKeyType
ONNXTensorElementDataType GetMapKeyType() const
Wraps OrtApi::GetMapKeyType.
Ort::detail::MapTypeInfoImpl::GetMapValueType
TypeInfo GetMapValueType() const
Wraps OrtApi::GetMapValueType.
Ort::detail::MemoryInfoImpl
Definition: onnxruntime_cxx_api.h:799
Ort::detail::MemoryInfoImpl::GetAllocatorName
std::string GetAllocatorName() const
Ort::detail::MemoryInfoImpl::GetDeviceId
int GetDeviceId() const
Ort::detail::MemoryInfoImpl::GetMemoryType
OrtMemType GetMemoryType() const
Ort::detail::MemoryInfoImpl::GetDeviceType
OrtMemoryInfoDeviceType GetDeviceType() const
Ort::detail::MemoryInfoImpl::GetAllocatorType
OrtAllocatorType GetAllocatorType() const
Ort::detail::MemoryInfoImpl::operator==
bool operator==(const MemoryInfoImpl< U > &o) const
Ort::detail::OrtSparseValuesParam
Definition: onnxruntime_cxx_api.h:946
Ort::detail::OrtSparseValuesParam::data
union Ort::detail::OrtSparseValuesParam::@0 data
Ort::detail::OrtSparseValuesParam::str
const char ** str
Definition: onnxruntime_cxx_api.h:951
Ort::detail::OrtSparseValuesParam::values_shape
const int64_t * values_shape
Definition: onnxruntime_cxx_api.h:947
Ort::detail::OrtSparseValuesParam::values_shape_len
size_t values_shape_len
Definition: onnxruntime_cxx_api.h:948
Ort::detail::OrtSparseValuesParam::p_data
const void * p_data
Definition: onnxruntime_cxx_api.h:950
Ort::detail::SequenceTypeInfoImpl
Definition: onnxruntime_cxx_api.h:865
Ort::detail::SequenceTypeInfoImpl::GetSequenceElementType
TypeInfo GetSequenceElementType() const
Wraps OrtApi::GetSequenceElementType.
Ort::detail::SessionImpl
Definition: onnxruntime_cxx_api.h:735
Ort::detail::SessionImpl::EndProfilingAllocated
AllocatedStringPtr EndProfilingAllocated(OrtAllocator *allocator)
End profiling and return a copy of the profiling file name.
Ort::detail::SessionImpl::Run
void Run(const RunOptions &run_options, const IoBinding &)
Wraps OrtApi::RunWithBinding.
Ort::detail::SessionImpl::Run
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.
Ort::detail::SessionImpl::Run
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&,...
Ort::detail::SessionOptionsImpl
Definition: onnxruntime_cxx_api.h:538
Ort::detail::SessionOptionsImpl::DisableMemPattern
SessionOptionsImpl & DisableMemPattern()
Wraps OrtApi::DisableMemPattern.
Ort::detail::SessionOptionsImpl::SetCustomJoinThreadFn
SessionOptionsImpl & SetCustomJoinThreadFn(OrtCustomJoinThreadFn ort_custom_join_thread_fn)
Wraps OrtApi::SessionOptionsSetCustomJoinThreadFn.
Ort::detail::SessionOptionsImpl::SetLogSeverityLevel
SessionOptionsImpl & SetLogSeverityLevel(int level)
Wraps OrtApi::SetSessionLogSeverityLevel.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider
SessionOptionsImpl & AppendExecutionProvider(const std::string &provider_name, const std::unordered_map< std::string, std::string > &provider_options={})
Wraps OrtApi::SessionOptionsAppendExecutionProvider. Currently supports SNPE and XNNPACK.
Ort::detail::SessionOptionsImpl::EnableOrtCustomOps
SessionOptionsImpl & EnableOrtCustomOps()
Wraps OrtApi::EnableOrtCustomOps.
Ort::detail::SessionOptionsImpl::SetCustomCreateThreadFn
SessionOptionsImpl & SetCustomCreateThreadFn(OrtCustomCreateThreadFn ort_custom_create_thread_fn)
Wraps OrtApi::SessionOptionsSetCustomCreateThreadFn.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_CANN
SessionOptionsImpl & AppendExecutionProvider_CANN(const OrtCANNProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_Dnnl.
Ort::detail::SessionOptionsImpl::SetGraphOptimizationLevel
SessionOptionsImpl & SetGraphOptimizationLevel(GraphOptimizationLevel graph_optimization_level)
Wraps OrtApi::SetSessionGraphOptimizationLevel.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_MIGraphX
SessionOptionsImpl & AppendExecutionProvider_MIGraphX(const OrtMIGraphXProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_CANN.
Ort::detail::SessionOptionsImpl::DisableCpuMemArena
SessionOptionsImpl & DisableCpuMemArena()
Wraps OrtApi::DisableCpuMemArena.
Ort::detail::SessionOptionsImpl::Add
SessionOptionsImpl & Add(OrtCustomOpDomain *custom_op_domain)
Wraps OrtApi::AddCustomOpDomain.
Ort::detail::SessionOptionsImpl::AddConfigEntry
SessionOptionsImpl & AddConfigEntry(const char *config_key, const char *config_value)
Wraps OrtApi::AddSessionConfigEntry.
Ort::detail::SessionOptionsImpl::EnableMemPattern
SessionOptionsImpl & EnableMemPattern()
Wraps OrtApi::EnableMemPattern.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_Dnnl
SessionOptionsImpl & AppendExecutionProvider_Dnnl(const OrtDnnlProviderOptions &provider_options)
Ort::detail::SessionOptionsImpl::SetCustomThreadCreationOptions
SessionOptionsImpl & SetCustomThreadCreationOptions(void *ort_custom_thread_creation_options)
Wraps OrtApi::SessionOptionsSetCustomThreadCreationOptions.
Ort::detail::SessionOptionsImpl::AddExternalInitializers
SessionOptionsImpl & AddExternalInitializers(const std::vector< std::string > &names, const std::vector< Value > &ort_values)
Wraps OrtApi::AddExternalInitializers.
Ort::detail::SessionOptionsImpl::SetLogId
SessionOptionsImpl & SetLogId(const char *logid)
Wraps OrtApi::SetSessionLogId.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_CUDA_V2
SessionOptionsImpl & AppendExecutionProvider_CUDA_V2(const OrtCUDAProviderOptionsV2 &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA_V2.
Ort::detail::SessionOptionsImpl::SetExecutionMode
SessionOptionsImpl & SetExecutionMode(ExecutionMode execution_mode)
Wraps OrtApi::SetSessionExecutionMode.
Ort::detail::SessionOptionsImpl::DisablePerSessionThreads
SessionOptionsImpl & DisablePerSessionThreads()
Wraps OrtApi::DisablePerSessionThreads.
Ort::detail::SessionOptionsImpl::RegisterCustomOpsLibrary
SessionOptionsImpl & RegisterCustomOpsLibrary(const char *library_name, const CustomOpConfigs &custom_op_configs={})
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_TensorRT_V2
SessionOptionsImpl & AppendExecutionProvider_TensorRT_V2(const OrtTensorRTProviderOptionsV2 &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT.
Ort::detail::SessionOptionsImpl::RegisterCustomOpsUsingFunction
SessionOptionsImpl & RegisterCustomOpsUsingFunction(const char *function_name)
Wraps OrtApi::RegisterCustomOpsUsingFunction.
Ort::detail::SessionOptionsImpl::DisableProfiling
SessionOptionsImpl & DisableProfiling()
Wraps OrtApi::DisableProfiling.
Ort::detail::SessionOptionsImpl::SetIntraOpNumThreads
SessionOptionsImpl & SetIntraOpNumThreads(int intra_op_num_threads)
Wraps OrtApi::SetIntraOpNumThreads.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_ROCM
SessionOptionsImpl & AppendExecutionProvider_ROCM(const OrtROCMProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_ROCM.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_OpenVINO
SessionOptionsImpl & AppendExecutionProvider_OpenVINO(const OrtOpenVINOProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_OpenVINO.
Ort::detail::SessionOptionsImpl::EnableCpuMemArena
SessionOptionsImpl & EnableCpuMemArena()
Wraps OrtApi::EnableCpuMemArena.
Ort::detail::SessionOptionsImpl::AddInitializer
SessionOptionsImpl & AddInitializer(const char *name, const OrtValue *ort_val)
Wraps OrtApi::AddInitializer.
Ort::detail::SessionOptionsImpl::SetInterOpNumThreads
SessionOptionsImpl & SetInterOpNumThreads(int inter_op_num_threads)
Wraps OrtApi::SetInterOpNumThreads.
Ort::detail::SessionOptionsImpl::EnableProfiling
SessionOptionsImpl & EnableProfiling(const char *profile_file_prefix)
Wraps OrtApi::EnableProfiling.
Ort::detail::SessionOptionsImpl::SetOptimizedModelFilePath
SessionOptionsImpl & SetOptimizedModelFilePath(const char *optimized_model_file)
Wraps OrtApi::SetOptimizedModelFilePath.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_TensorRT
SessionOptionsImpl & AppendExecutionProvider_TensorRT(const OrtTensorRTProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_TensorRT.
Ort::detail::SessionOptionsImpl::AppendExecutionProvider_CUDA
SessionOptionsImpl & AppendExecutionProvider_CUDA(const OrtCUDAProviderOptions &provider_options)
Wraps OrtApi::SessionOptionsAppendExecutionProvider_CUDA.
Ort::detail::Shape
Definition: onnxruntime_cxx_api.h:957
Ort::detail::Shape::shape
const int64_t * shape
Definition: onnxruntime_cxx_api.h:958
Ort::detail::Shape::shape_len
size_t shape_len
Definition: onnxruntime_cxx_api.h:959
Ort::detail::TensorTypeAndShapeInfoImpl
Definition: onnxruntime_cxx_api.h:830
Ort::detail::TensorTypeAndShapeInfoImpl::GetElementCount
size_t GetElementCount() const
Wraps OrtApi::GetTensorShapeElementCount.
Ort::detail::TensorTypeAndShapeInfoImpl::GetDimensions
void GetDimensions(int64_t *values, size_t values_count) const
Wraps OrtApi::GetDimensions.
Ort::detail::TensorTypeAndShapeInfoImpl::GetShape
std::vector< int64_t > GetShape() const
Uses GetDimensionsCount & GetDimensions to return a std::vector of the shape.
Ort::detail::TensorTypeAndShapeInfoImpl::GetSymbolicDimensions
void GetSymbolicDimensions(const char **values, size_t values_count) const
Wraps OrtApi::GetSymbolicDimensions.
Ort::detail::TensorTypeAndShapeInfoImpl::GetDimensionsCount
size_t GetDimensionsCount() const
Wraps OrtApi::GetDimensionsCount.
Ort::detail::TensorTypeAndShapeInfoImpl::GetElementType
ONNXTensorElementDataType GetElementType() const
Wraps OrtApi::GetTensorElementType.
Ort::detail::TypeInfoImpl
Definition: onnxruntime_cxx_api.h:908
Ort::detail::TypeInfoImpl::GetONNXType
ONNXType GetONNXType() const
Ort::detail::TypeInfoImpl::GetSequenceTypeInfo
ConstSequenceTypeInfo GetSequenceTypeInfo() const
Wraps OrtApi::CastTypeInfoToSequenceTypeInfo.
Ort::detail::TypeInfoImpl::GetMapTypeInfo
ConstMapTypeInfo GetMapTypeInfo() const
Wraps OrtApi::CastTypeInfoToMapTypeInfo.
Ort::detail::TypeInfoImpl::GetTensorTypeAndShapeInfo
ConstTensorTypeAndShapeInfo GetTensorTypeAndShapeInfo() const
Wraps OrtApi::CastTypeInfoToTensorInfo.
Ort::detail::Unowned
This is a tagging template type. Use it with Base<T> to indicate that the C++ interface object has no...
Definition: onnxruntime_cxx_api.h:232
Ort::detail::Unowned::Type
T Type
Definition: onnxruntime_cxx_api.h:233
Ort::detail::ValueImpl
Definition: onnxruntime_cxx_api.h:1116
Ort::detail::ValueImpl::FillStringTensorElement
void FillStringTensorElement(const char *s, size_t index)
Set a single string in a string tensor.
Ort::detail::ValueImpl::GetTensorMutableData
R * GetTensorMutableData()
Returns a non-const typed pointer to an OrtValue/Tensor contained buffer No type checking is performe...
Ort::detail::ValueImpl::At
R & At(const std::vector< int64_t > &location)
Ort::detail::ValueImpl::UseBlockSparseIndices
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...
Ort::detail::ValueImpl::FillSparseTensorBlockSparse
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...
Ort::detail::ValueImpl::GetTensorMutableRawData
void * GetTensorMutableRawData()
Returns a non-typed non-const pointer to a tensor contained data.
Ort::detail::ValueImpl::UseCooIndices
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...
Ort::detail::ValueImpl::FillSparseTensorCoo
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...
Ort::detail::ValueImpl::FillStringTensor
void FillStringTensor(const char *const *s, size_t s_len)
Set all strings at once in a string tensor.
Ort::detail::ValueImpl::UseCsrIndices
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...
Ort::detail::ValueImpl::FillSparseTensorCsr
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...
OrtAllocator
Memory allocation interface.
Definition: onnxruntime_c_api.h:287
OrtAllocator::Free
void(* Free)(struct OrtAllocator *this_, void *p)
Free a block of memory previously allocated with OrtAllocator::Alloc.
Definition: onnxruntime_c_api.h:290
OrtApiBase::GetApi
const OrtApi *(* GetApi)(uint32_t version)
Get a pointer to the requested version of the OrtApi.
Definition: onnxruntime_c_api.h:593
OrtApi
The C API.
Definition: onnxruntime_c_api.h:638
OrtCUDAProviderOptions
CUDA Provider Options.
Definition: onnxruntime_c_api.h:371
OrtCustomOp
Definition: onnxruntime_c_api.h:3989
OrtCustomOp::GetVariadicInputHomogeneity
int(* GetVariadicInputHomogeneity)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4030
OrtCustomOp::GetOutputCharacteristic
OrtCustomOpInputOutputCharacteristic(* GetOutputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:4014
OrtCustomOp::GetInputTypeCount
size_t(* GetInputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4004
OrtCustomOp::GetVariadicOutputMinArity
int(* GetVariadicOutputMinArity)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4034
OrtCustomOp::GetName
const char *(* GetName)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:3997
OrtCustomOp::GetOutputTypeCount
size_t(* GetOutputTypeCount)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4006
OrtCustomOp::KernelDestroy
void(* KernelDestroy)(void *op_kernel)
Definition: onnxruntime_c_api.h:4010
OrtCustomOp::GetVariadicOutputHomogeneity
int(* GetVariadicOutputHomogeneity)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4039
OrtCustomOp::GetInputMemoryType
OrtMemType(* GetInputMemoryType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:4021
OrtCustomOp::CreateKernel
void *(* CreateKernel)(const struct OrtCustomOp *op, const OrtApi *api, const OrtKernelInfo *info)
Definition: onnxruntime_c_api.h:3993
OrtCustomOp::version
uint32_t version
Definition: onnxruntime_c_api.h:3990
OrtCustomOp::GetInputType
ONNXTensorElementDataType(* GetInputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:4003
OrtCustomOp::GetInputCharacteristic
OrtCustomOpInputOutputCharacteristic(* GetInputCharacteristic)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:4013
OrtCustomOp::GetExecutionProviderType
const char *(* GetExecutionProviderType)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4000
OrtCustomOp::GetOutputType
ONNXTensorElementDataType(* GetOutputType)(const struct OrtCustomOp *op, size_t index)
Definition: onnxruntime_c_api.h:4005
OrtCustomOp::GetVariadicInputMinArity
int(* GetVariadicInputMinArity)(const struct OrtCustomOp *op)
Definition: onnxruntime_c_api.h:4025
OrtCustomOp::KernelCompute
void(* KernelCompute)(void *op_kernel, OrtKernelContext *context)
Definition: onnxruntime_c_api.h:4009
OrtMIGraphXProviderOptions
MIGraphX Provider Options.
Definition: onnxruntime_c_api.h:546
OrtOpenVINOProviderOptions
OpenVINO Provider Options.
Definition: onnxruntime_c_api.h:556
OrtROCMProviderOptions
ROCM Provider Options.
Definition: onnxruntime_c_api.h:445
OrtTensorRTProviderOptions
TensorRT Provider Options.
Definition: onnxruntime_c_api.h:518