OnnxRuntime
Ort::Session Struct Reference

Wrapper around OrtSession. More...

#include <onnxruntime_cxx_api.h>

Inherits Ort::Base< OrtSession >.

Public Member Functions

 Session (std::nullptr_t)
 Create an empty Session object, must be assigned a valid one to be used. More...
 
 Session (Env &env, const char *model_path, const SessionOptions &options)
 Wraps OrtApi::CreateSession. More...
 
 Session (Env &env, const char *model_path, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
 Wraps OrtApi::CreateSessionWithPrepackedWeightsContainer. More...
 
 Session (Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options)
 Wraps OrtApi::CreateSessionFromArray. More...
 
 Session (Env &env, const void *model_data, size_t model_data_length, const SessionOptions &options, OrtPrepackedWeightsContainer *prepacked_weights_container)
 Wraps OrtApi::CreateSessionFromArrayWithPrepackedWeightsContainer. More...
 
std::vector< ValueRun (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. More...
 
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&, const char* const*, const Value*, size_t,const char* const*, size_t) More...
 
void Run (const RunOptions &run_options, const struct IoBinding &)
 Wraps OrtApi::RunWithBinding. More...
 
size_t GetInputCount () const
 Returns the number of model inputs. More...
 
size_t GetOutputCount () const
 Returns the number of model outputs. More...
 
size_t GetOverridableInitializerCount () const
 Returns the number of inputs that have defaults that can be overridden. More...
 
char * GetInputName (size_t index, OrtAllocator *allocator) const
 Wraps OrtApi::SessionGetInputName. More...
 
AllocatedStringPtr GetInputNameAllocated (size_t index, OrtAllocator *allocator) const
 Returns a copy of input name at the specified index. More...
 
char * GetOutputName (size_t index, OrtAllocator *allocator) const
 Wraps OrtApi::SessionGetOutputName. More...
 
AllocatedStringPtr GetOutputNameAllocated (size_t index, OrtAllocator *allocator) const
 Returns a copy of output name at then specified index. More...
 
char * GetOverridableInitializerName (size_t index, OrtAllocator *allocator) const
 Wraps OrtApi::SessionGetOverridableInitializerName. More...
 
AllocatedStringPtr GetOverridableInitializerNameAllocated (size_t index, OrtAllocator *allocator) const
 Returns a copy of the overridable initializer name at then specified index. More...
 
char * EndProfiling (OrtAllocator *allocator) const
 Wraps OrtApi::SessionEndProfiling. More...
 
AllocatedStringPtr EndProfilingAllocated (OrtAllocator *allocator) const
 Returns a copy of the profiling file name. More...
 
uint64_t GetProfilingStartTimeNs () const
 Wraps OrtApi::SessionGetProfilingStartTimeNs. More...
 
ModelMetadata GetModelMetadata () const
 Wraps OrtApi::SessionGetModelMetadata. More...
 
TypeInfo GetInputTypeInfo (size_t index) const
 Wraps OrtApi::SessionGetInputTypeInfo. More...
 
TypeInfo GetOutputTypeInfo (size_t index) const
 Wraps OrtApi::SessionGetOutputTypeInfo. More...
 
TypeInfo GetOverridableInitializerTypeInfo (size_t index) const
 Wraps OrtApi::SessionGetOverridableInitializerTypeInfo. More...
 
- Public Member Functions inherited from Ort::Base< OrtSession >
 Base ()=default
 
 Base (OrtSession *p)
 
 ~Base ()
 
 operator OrtSession * ()
 
 operator const OrtSession * () const
 
OrtSessionrelease ()
 Releases ownership of the contained pointer. More...
 

Additional Inherited Members

- Public Types inherited from Ort::Base< OrtSession >
using contained_type = OrtSession
 
- Protected Member Functions inherited from Ort::Base< OrtSession >
 Base (const Base &)=delete
 
 Base (Base &&v) noexcept
 
Baseoperator= (const Base &)=delete
 
void operator= (Base &&v) noexcept
 
- Protected Attributes inherited from Ort::Base< OrtSession >
OrtSessionp_
 

Detailed Description

Wrapper around OrtSession.

Constructor & Destructor Documentation

◆ Session() [1/5]

Ort::Session::Session ( std::nullptr_t  )
inlineexplicit

Create an empty Session object, must be assigned a valid one to be used.

◆ Session() [2/5]

Ort::Session::Session ( Env env,
const char *  model_path,
const SessionOptions options 
)

◆ Session() [3/5]

Ort::Session::Session ( Env env,
const char *  model_path,
const SessionOptions options,
OrtPrepackedWeightsContainer prepacked_weights_container 
)

◆ Session() [4/5]

Ort::Session::Session ( Env env,
const void *  model_data,
size_t  model_data_length,
const SessionOptions options 
)

◆ Session() [5/5]

Ort::Session::Session ( Env env,
const void *  model_data,
size_t  model_data_length,
const SessionOptions options,
OrtPrepackedWeightsContainer prepacked_weights_container 
)

Member Function Documentation

◆ EndProfiling()

char * Ort::Session::EndProfiling ( OrtAllocator allocator) const

Wraps OrtApi::SessionEndProfiling.

Deprecated:
use EndProfilingAllocated() [[deprecated]] This interface produces a pointer that must be released by the specified allocator and is often leaked. Not exception safe.

◆ EndProfilingAllocated()

AllocatedStringPtr Ort::Session::EndProfilingAllocated ( OrtAllocator allocator) const

Returns a copy of the profiling file name.

Parameters
allocatorto allocate memory for the copy of the string returned
Returns
a instance of smart pointer that would deallocate the buffer when out of scope. The OrtAllocator instances must be valid at the point of memory release. Wraps OrtApi::SessionEndProfiling

◆ GetInputCount()

size_t Ort::Session::GetInputCount ( ) const

Returns the number of model inputs.

◆ GetInputName()

char * Ort::Session::GetInputName ( size_t  index,
OrtAllocator allocator 
) const

Wraps OrtApi::SessionGetInputName.

Deprecated:
use GetInputNameAllocated() [[deprecated]] This interface produces a pointer that must be released by the specified allocator and is often leaked. Not exception safe.

◆ GetInputNameAllocated()

AllocatedStringPtr Ort::Session::GetInputNameAllocated ( size_t  index,
OrtAllocator allocator 
) const

Returns a copy of input name at the specified index.

Parameters
indexmust less than the value returned by GetInputCount()
allocatorto allocate memory for the copy of the name returned
Returns
a instance of smart pointer that would deallocate the buffer when out of scope. The OrtAllocator instances must be valid at the point of memory release.

◆ GetInputTypeInfo()

TypeInfo Ort::Session::GetInputTypeInfo ( size_t  index) const

◆ GetModelMetadata()

ModelMetadata Ort::Session::GetModelMetadata ( ) const

◆ GetOutputCount()

size_t Ort::Session::GetOutputCount ( ) const

Returns the number of model outputs.

◆ GetOutputName()

char * Ort::Session::GetOutputName ( size_t  index,
OrtAllocator allocator 
) const

Wraps OrtApi::SessionGetOutputName.

Deprecated:
use GetOutputNameAllocated() [[deprecated]] This interface produces a pointer that must be released by the specified allocator and is often leaked. Not exception safe.

◆ GetOutputNameAllocated()

AllocatedStringPtr Ort::Session::GetOutputNameAllocated ( size_t  index,
OrtAllocator allocator 
) const

Returns a copy of output name at then specified index.

Parameters
indexmust less than the value returned by GetOutputCount()
allocatorto allocate memory for the copy of the name returned
Returns
a instance of smart pointer that would deallocate the buffer when out of scope. The OrtAllocator instances must be valid at the point of memory release.

◆ GetOutputTypeInfo()

TypeInfo Ort::Session::GetOutputTypeInfo ( size_t  index) const

◆ GetOverridableInitializerCount()

size_t Ort::Session::GetOverridableInitializerCount ( ) const

Returns the number of inputs that have defaults that can be overridden.

◆ GetOverridableInitializerName()

char * Ort::Session::GetOverridableInitializerName ( size_t  index,
OrtAllocator allocator 
) const

Wraps OrtApi::SessionGetOverridableInitializerName.

Deprecated:
use GetOverridableInitializerNameAllocated() [[deprecated]] This interface produces a pointer that must be released by the specified allocator and is often leaked. Not exception safe.

◆ GetOverridableInitializerNameAllocated()

AllocatedStringPtr Ort::Session::GetOverridableInitializerNameAllocated ( size_t  index,
OrtAllocator allocator 
) const

Returns a copy of the overridable initializer name at then specified index.

Parameters
indexmust less than the value returned by GetOverridableInitializerCount()
allocatorto allocate memory for the copy of the name returned
Returns
a instance of smart pointer that would deallocate the buffer when out of scope. The OrtAllocator instances must be valid at the point of memory release. Wraps OrtApi::SessionGetOverridableInitializerName

◆ GetOverridableInitializerTypeInfo()

TypeInfo Ort::Session::GetOverridableInitializerTypeInfo ( size_t  index) const

◆ GetProfilingStartTimeNs()

uint64_t Ort::Session::GetProfilingStartTimeNs ( ) const

◆ Run() [1/3]

std::vector< Value > Ort::Session::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.

Wraps OrtApi::Run

The caller provides a list of inputs and a list of the desired outputs to return.

See the output logs for more information on warnings/errors that occur while processing the model. Common errors are.. (TODO)

Parameters
[in]run_options
[in]input_namesArray of null terminated strings of length input_count that is the list of input names
[in]input_valuesArray of Value objects of length input_count that is the list of input values
[in]input_countNumber of inputs (the size of the input_names & input_values arrays)
[in]output_namesArray of C style strings of length output_count that is the list of output names
[in]output_countNumber of outputs (the size of the output_names array)
Returns
A std::vector of Value objects that directly maps to the output_count (eg. output_name[0] is the first entry of the returned vector)

◆ Run() [2/3]

void Ort::Session::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&, const char* const*, const Value*, size_t,const char* const*, size_t)

◆ Run() [3/3]

void Ort::Session::Run ( const RunOptions run_options,
const struct IoBinding  
)