HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
onnxruntime_cxx_api.h File Reference
#include "onnxruntime_c_api.h"
#include "onnxruntime_float16.h"
#include <cstddef>
#include <cstdio>
#include <array>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
#include <type_traits>
#include "onnxruntime_cxx_inline.h"
+ Include dependency graph for onnxruntime_cxx_api.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Ort::Exception
 All C++ methods that can fail will throw an exception of this type. More...
 
struct  Ort::Global< T >
 
struct  Ort::Float16_t
 IEEE 754 half-precision floating point data type. More...
 
struct  Ort::BFloat16_t
 bfloat16 (Brain Floating Point) data type More...
 
struct  Ort::Float8E4M3FN_t
 float8e4m3fn (Float8 Floating Point) data type More...
 
struct  Ort::Float8E4M3FNUZ_t
 float8e4m3fnuz (Float8 Floating Point) data type More...
 
struct  Ort::Float8E5M2_t
 float8e5m2 (Float8 Floating Point) data type More...
 
struct  Ort::Float8E5M2FNUZ_t
 float8e5m2fnuz (Float8 Floating Point) data type More...
 
struct  Ort::detail::Unowned< T >
 This is a tagging template type. Use it with Base<T> to indicate that the C++ interface object has no ownership of the underlying C object. More...
 
struct  Ort::detail::Base< T >
 Used internally by the C++ API. C++ wrapper types inherit from this. This is a zero cost abstraction to wrap the C API objects and delete them on destruction. More...
 
struct  Ort::detail::Base< Unowned< T > >
 Covers unowned pointers owned by either the ORT or some other instance of CPP wrappers. Used for ConstXXX and UnownedXXXX types that are copyable. Also convenient to wrap raw OrtXX pointers . More...
 
struct  Ort::detail::AllocatedFree
 
struct  Ort::Status
 The Status that holds ownership of OrtStatus received from C API Use it to safely destroy OrtStatus* returned from the C API. Use appropriate constructors to construct an instance of a Status object from exceptions. More...
 
struct  Ort::ThreadingOptions
 The ThreadingOptions. More...
 
struct  Ort::Env
 The Env (Environment) More...
 
struct  Ort::CustomOpDomain
 Custom Op Domain. More...
 
struct  Ort::RunOptions
 RunOptions. More...
 
struct  Ort::CustomOpConfigs
 Class that represents session configuration entries for one or more custom operators. More...
 
struct  Ort::detail::ConstSessionOptionsImpl< T >
 
struct  Ort::detail::SessionOptionsImpl< T >
 
struct  Ort::SessionOptions
 Wrapper around ::OrtSessionOptions. More...
 
struct  Ort::ModelMetadata
 Wrapper around ::OrtModelMetadata. More...
 
struct  Ort::detail::ConstSessionImpl< T >
 
struct  Ort::detail::SessionImpl< T >
 
struct  Ort::Session
 Wrapper around ::OrtSession. More...
 
struct  Ort::detail::MemoryInfoImpl< T >
 
struct  Ort::MemoryInfo
 Wrapper around OrtMemoryInfo. More...
 
struct  Ort::detail::TensorTypeAndShapeInfoImpl< T >
 
struct  Ort::TensorTypeAndShapeInfo
 Wrapper around ::OrtTensorTypeAndShapeInfo. More...
 
struct  Ort::detail::SequenceTypeInfoImpl< T >
 
struct  Ort::SequenceTypeInfo
 Wrapper around ::OrtSequenceTypeInfo. More...
 
struct  Ort::detail::OptionalTypeInfoImpl< T >
 
struct  Ort::detail::MapTypeInfoImpl< T >
 
struct  Ort::MapTypeInfo
 Wrapper around ::OrtMapTypeInfo. More...
 
struct  Ort::detail::TypeInfoImpl< T >
 
struct  Ort::TypeInfo
 Type information that may contain either TensorTypeAndShapeInfo or the information about contained sequence or map depending on the ONNXType. More...
 
struct  Ort::detail::OrtSparseValuesParam
 
struct  Ort::detail::Shape
 
struct  Ort::detail::ConstValueImpl< T >
 
struct  Ort::detail::ValueImpl< T >
 
struct  Ort::Value
 Wrapper around OrtValue. More...
 
struct  Ort::MemoryAllocation
 Represents native memory allocation coming from one of the OrtAllocators registered with OnnxRuntime. Use it to wrap an allocation made by an allocator so it can be automatically released when no longer needed. More...
 
struct  Ort::detail::AllocatorImpl< T >
 
struct  Ort::AllocatorWithDefaultOptions
 Wrapper around ::OrtAllocator default instance that is owned by Onnxruntime. More...
 
struct  Ort::Allocator
 Wrapper around ::OrtAllocator. More...
 
struct  Ort::detail::ConstIoBindingImpl< T >
 
struct  Ort::detail::IoBindingImpl< T >
 
struct  Ort::IoBinding
 Wrapper around ::OrtIoBinding. More...
 
struct  Ort::ArenaCfg
 it is a structure that represents the configuration of an arena based allocator More...
 
struct  Ort::OpAttr
 This struct provides life time management for custom op attribute More...
 
struct  Ort::Logger
 This class represents an ONNX Runtime logger that can be used to log information with an associated severity level and source code location (file path, line number, function name). More...
 
struct  Ort::KernelContext
 This class wraps a raw pointer OrtKernelContext* that is being passed to the custom kernel Compute() method. Use it to safely access context attributes, input and output parameters with exception safety guarantees. See usage example in onnxruntime/test/testdata/custom_op_library/custom_op_library.cc More...
 
struct  Ort::detail::KernelInfoImpl< T >
 
struct  Ort::KernelInfo
 This struct owns the OrtKernInfo* pointer when a copy is made. For convenient wrapping of OrtKernelInfo* passed to kernel constructor and query attributes, warp the pointer with Ort::Unowned<KernelInfo> instance so it does not destroy the pointer the kernel does not own. More...
 
struct  Ort::Op
 Create and own custom defined operation. More...
 
struct  Ort::ShapeInferContext
 Provide access to per-node attributes and input shapes, so one could compute and set output shapes. More...
 
struct  Ort::ShapeInferContext::SymbolicInteger
 
struct  Ort::CustomOpBase< TOp, TKernel, WithStatus >
 

Namespaces

 Ort
 All C++ Onnxruntime APIs are defined inside this namespace.
 
 Ort::detail
 
 Ort::detail::binding_utils
 
 Ort::detail::attr_utils
 

Macros

#define ORT_CXX_API_THROW(string, code)   throw Ort::Exception(string, code)
 
#define ORT_DEFINE_RELEASE(NAME)   inline void OrtRelease(Ort##NAME* ptr) { GetApi().Release##NAME(ptr); }
 
#define ORT_CXX_LOG(logger, message_severity, message)
 
#define ORT_CXX_LOG_NOEXCEPT(logger, message_severity, message)
 
#define ORT_CXX_LOGF(logger, message_severity,...)
 
#define ORT_CXX_LOGF_NOEXCEPT(logger, message_severity,...)
 
#define MAX_CUSTOM_OP_END_VER   (1UL << 31) - 1
 

Typedefs

using Ort::AllocatedStringPtr = std::unique_ptr< char, detail::AllocatedFree >
 unique_ptr typedef used to own strings allocated by OrtAllocators and release them at the end of the scope. The lifespan of the given allocator must eclipse the lifespan of AllocatedStringPtr instance More...
 
using Ort::UnownedSessionOptions = detail::SessionOptionsImpl< detail::Unowned< OrtSessionOptions >>
 
using Ort::ConstSessionOptions = detail::ConstSessionOptionsImpl< detail::Unowned< const OrtSessionOptions >>
 
using Ort::ConstSession = detail::ConstSessionImpl< detail::Unowned< const OrtSession >>
 
using Ort::UnownedSession = detail::SessionImpl< detail::Unowned< OrtSession >>
 
using Ort::ConstMemoryInfo = detail::MemoryInfoImpl< detail::Unowned< const OrtMemoryInfo >>
 
using Ort::ConstTensorTypeAndShapeInfo = detail::TensorTypeAndShapeInfoImpl< detail::Unowned< const OrtTensorTypeAndShapeInfo >>
 
using Ort::ConstSequenceTypeInfo = detail::SequenceTypeInfoImpl< detail::Unowned< const OrtSequenceTypeInfo >>
 
using Ort::ConstOptionalTypeInfo = detail::OptionalTypeInfoImpl< detail::Unowned< const OrtOptionalTypeInfo >>
 
using Ort::ConstMapTypeInfo = detail::MapTypeInfoImpl< detail::Unowned< const OrtMapTypeInfo >>
 
using Ort::ConstTypeInfo = detail::TypeInfoImpl< detail::Unowned< const OrtTypeInfo >>
 Contains a constant, unowned OrtTypeInfo that can be copied and passed around by value. Provides access to const OrtTypeInfo APIs. More...
 
using Ort::ConstValue = detail::ConstValueImpl< detail::Unowned< const OrtValue >>
 
using Ort::UnownedValue = detail::ValueImpl< detail::Unowned< OrtValue >>
 
using Ort::UnownedAllocator = detail::AllocatorImpl< detail::Unowned< OrtAllocator >>
 
using Ort::ConstIoBinding = detail::ConstIoBindingImpl< detail::Unowned< const OrtIoBinding >>
 
using Ort::UnownedIoBinding = detail::IoBindingImpl< detail::Unowned< OrtIoBinding >>
 
using Ort::ConstKernelInfo = detail::KernelInfoImpl< detail::Unowned< const OrtKernelInfo >>
 
using Ort::ShapeInferFn = Ort::Status(*)(Ort::ShapeInferContext &)
 

Functions

const OrtApi & Ort::GetApi () noexcept
 This returns a reference to the OrtApi interface in use. More...
 
std::string Ort::GetVersionString ()
 This function returns the onnxruntime version string More...
 
std::string Ort::GetBuildInfoString ()
 This function returns the onnxruntime build information: including git branch, git commit id, build type(Debug/Release/RelWithDebInfo) and cmake cpp flags. More...
 
std::vector< std::stringOrt::GetAvailableProviders ()
 This is a C++ wrapper for OrtApi::GetAvailableProviders() and returns a vector of strings representing the available execution providers. More...
 
 Ort::detail::ORT_DEFINE_RELEASE (Allocator)
 
 Ort::detail::ORT_DEFINE_RELEASE (MemoryInfo)
 
 Ort::detail::ORT_DEFINE_RELEASE (CustomOpDomain)
 
 Ort::detail::ORT_DEFINE_RELEASE (ThreadingOptions)
 
 Ort::detail::ORT_DEFINE_RELEASE (Env)
 
 Ort::detail::ORT_DEFINE_RELEASE (RunOptions)
 
 Ort::detail::ORT_DEFINE_RELEASE (Session)
 
 Ort::detail::ORT_DEFINE_RELEASE (SessionOptions)
 
 Ort::detail::ORT_DEFINE_RELEASE (TensorTypeAndShapeInfo)
 
 Ort::detail::ORT_DEFINE_RELEASE (SequenceTypeInfo)
 
 Ort::detail::ORT_DEFINE_RELEASE (MapTypeInfo)
 
 Ort::detail::ORT_DEFINE_RELEASE (TypeInfo)
 
 Ort::detail::ORT_DEFINE_RELEASE (Value)
 
 Ort::detail::ORT_DEFINE_RELEASE (ModelMetadata)
 
 Ort::detail::ORT_DEFINE_RELEASE (IoBinding)
 
 Ort::detail::ORT_DEFINE_RELEASE (ArenaCfg)
 
 Ort::detail::ORT_DEFINE_RELEASE (Status)
 
 Ort::detail::ORT_DEFINE_RELEASE (OpAttr)
 
 Ort::detail::ORT_DEFINE_RELEASE (Op)
 
 Ort::detail::ORT_DEFINE_RELEASE (KernelInfo)
 
std::string Ort::detail::MakeCustomOpConfigEntryKey (const char *custom_op_name, const char *config)
 CustomOpConfigs. More...
 
std::vector< std::stringOrt::detail::binding_utils::GetOutputNamesHelper (const OrtIoBinding *binding, OrtAllocator *)
 
std::vector< ValueOrt::detail::binding_utils::GetOutputValuesHelper (const OrtIoBinding *binding, OrtAllocator *)
 
void Ort::detail::attr_utils::GetAttr (const OrtKernelInfo *p, const char *name, float &)
 
void Ort::detail::attr_utils::GetAttr (const OrtKernelInfo *p, const char *name, int64_t &)
 
void Ort::detail::attr_utils::GetAttr (const OrtKernelInfo *p, const char *name, std::string &)
 
void Ort::detail::attr_utils::GetAttrs (const OrtKernelInfo *p, const char *name, std::vector< float > &)
 
void Ort::detail::attr_utils::GetAttrs (const OrtKernelInfo *p, const char *name, std::vector< int64_t > &)
 

Macro Definition Documentation

#define MAX_CUSTOM_OP_END_VER   (1UL << 31) - 1

Definition at line 2235 of file onnxruntime_cxx_api.h.

#define ORT_CXX_API_THROW (   string,
  code 
)    throw Ort::Exception(string, code)

Definition at line 77 of file onnxruntime_cxx_api.h.

#define ORT_CXX_LOG (   logger,
  message_severity,
  message 
)
Value:
do { \
if (message_severity >= logger.GetLoggingSeverityLevel()) { \
Ort::ThrowOnError(logger.LogMessage(message_severity, ORT_FILE, __LINE__, \
static_cast<const char*>(__FUNCTION__), message)); \
} \
} while (false)
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
void ThrowOnError(OrtStatus *ort_status)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Macro that logs a message using the provided logger. Throws an exception if OrtApi::Logger_LogMessage fails. Example: ORT_CXX_LOG(logger, ORT_LOGGING_LEVEL_INFO, "Log a message");

Parameters
loggerThe Ort::Logger instance to use. Must be a value or reference.
message_severityThe logging severity level of the message.
messageA null-terminated UTF-8 message to log.

Definition at line 1901 of file onnxruntime_cxx_api.h.

#define ORT_CXX_LOG_NOEXCEPT (   logger,
  message_severity,
  message 
)
Value:
do { \
if (message_severity >= logger.GetLoggingSeverityLevel()) { \
static_cast<void>(logger.LogMessage(message_severity, ORT_FILE, __LINE__, \
static_cast<const char*>(__FUNCTION__), message)); \
} \
} while (false)
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Macro that logs a message using the provided logger. Can be used in noexcept code since errors are silently ignored. Example: ORT_CXX_LOG_NOEXCEPT(logger, ORT_LOGGING_LEVEL_INFO, "Log a message");

Parameters
loggerThe Ort::Logger instance to use. Must be a value or reference.
message_severityThe logging severity level of the message.
messageA null-terminated UTF-8 message to log.

Definition at line 1917 of file onnxruntime_cxx_api.h.

#define ORT_CXX_LOGF (   logger,
  message_severity,
  ... 
)
Value:
do { \
if (message_severity >= logger.GetLoggingSeverityLevel()) { \
Ort::ThrowOnError(logger.LogFormattedMessage(message_severity, ORT_FILE, __LINE__, \
static_cast<const char*>(__FUNCTION__), __VA_ARGS__)); \
} \
} while (false)
void ThrowOnError(OrtStatus *ort_status)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Macro that logs a printf-like formatted message using the provided logger. Throws an exception if OrtApi::Logger_LogMessage fails or if a formatting error occurs. Example: ORT_CXX_LOGF(logger, ORT_LOGGING_LEVEL_INFO, "Log an int: %d", 12);

Parameters
loggerThe Ort::Logger instance to use. Must be a value or reference.
message_severityThe logging severity level of the message.
formatA null-terminated UTF-8 format string forwarded to a printf-like function. Refer to https://en.cppreference.com/w/cpp/io/c/fprintf for information on valid formats.
...Zero or more variadic arguments referenced by the format string.

Definition at line 1936 of file onnxruntime_cxx_api.h.

#define ORT_CXX_LOGF_NOEXCEPT (   logger,
  message_severity,
  ... 
)
Value:
do { \
if (message_severity >= logger.GetLoggingSeverityLevel()) { \
static_cast<void>(logger.LogFormattedMessage(message_severity, ORT_FILE, __LINE__, \
static_cast<const char*>(__FUNCTION__), __VA_ARGS__)); \
} \
} while (false)
if(num_boxed_items<=0)
Definition: UT_RTreeImpl.h:697

Macro that logs a printf-like formatted message using the provided logger. Can be used in noexcept code since errors are silently ignored. Example: ORT_CXX_LOGF_NOEXCEPT(logger, ORT_LOGGING_LEVEL_INFO, "Log an int: %d", 12);

Parameters
loggerThe Ort::Logger instance to use. Must be a value or reference.
message_severityThe logging severity level of the message.
formatA null-terminated UTF-8 format string forwarded to a printf-like function. Refer to https://en.cppreference.com/w/cpp/io/c/fprintf for information on valid formats.
...Zero or more variadic arguments referenced by the format string.

Definition at line 1955 of file onnxruntime_cxx_api.h.

#define ORT_DEFINE_RELEASE (   NAME)    inline void OrtRelease(Ort##NAME* ptr) { GetApi().Release##NAME(ptr); }

Definition at line 502 of file onnxruntime_cxx_api.h.