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...
 
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...
 
char * GetOutputName (size_t index, OrtAllocator *allocator) const
 Wraps OrtApi::SessionGetOutputName. More...
 
char * GetOverridableInitializerName (size_t index, OrtAllocator *allocator) const
 Wraps OrtApi::SessionGetOverridableInitializerName. More...
 
char * EndProfiling (OrtAllocator *allocator) const
 Wraps OrtApi::SessionEndProfiling. 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/4]

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

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

◆ Session() [2/4]

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

◆ Session() [3/4]

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

◆ Session() [4/4]

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

Member Function Documentation

◆ EndProfiling()

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

◆ GetInputCount()

size_t Ort::Session::GetInputCount ( ) const

Returns the number of model inputs.

◆ GetInputName()

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

◆ 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

◆ 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

◆ 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  
)