SourceXtractorPlusPlus  0.16
Please provide a description of the project.
Public Member Functions | Private Attributes | List of all members
SourceXtractor::OnnxModel Class Reference

#include <OnnxModel.h>

Collaboration diagram for SourceXtractor::OnnxModel:
[legend]

Public Member Functions

 OnnxModel (const std::string &model_path)
 
template<typename T , typename U >
void run (std::vector< T > &input_data, std::vector< U > &output_data) const
 
template<typename T , typename U >
void runMultiInput (std::map< std::string, std::vector< T >> &input_data, std::vector< U > &output_data) const
 
ONNXTensorElementDataType getInputType () const
 
ONNXTensorElementDataType getOutputType () const
 
const std::vector< std::int64_t > & getInputShape () const
 
const std::vector< std::int64_t > & getOutputShape () const
 
std::string getDomain () const
 
std::string getGraphName () const
 
std::string getInputName () const
 
std::string getOutputName () const
 
std::string getModelPath () const
 
size_t getInputNb () const
 
size_t getOutputNb () const
 

Private Attributes

std::string m_domain_name
 domain name More...
 
std::string m_graph_name
 graph name More...
 
std::vector< std::stringm_input_names
 Input tensor name. More...
 
std::string m_output_name
 Output tensor name. More...
 
std::vector< ONNXTensorElementDataType > m_input_types
 Input type. More...
 
ONNXTensorElementDataType m_output_type
 Output type. More...
 
std::vector< std::vector< std::int64_t > > m_input_shapes
 Input tensor shape. More...
 
std::vector< std::int64_tm_output_shape
 Output tensor shape. More...
 
std::string m_model_path
 Path to the ONNX model. More...
 
std::unique_ptr< Ort::Session > m_session
 Session, one per model. In theory, it is thread-safe. More...
 

Detailed Description

Definition at line 21 of file OnnxModel.h.

Constructor & Destructor Documentation

◆ OnnxModel()

SourceXtractor::OnnxModel::OnnxModel ( const std::string model_path)
explicit

Definition at line 32 of file OnnxModel.cpp.

References std::string::c_str(), std::vector< T >::emplace_back(), Elements::Logging::getLogger(), Elements::Logging::info(), m_domain_name, m_graph_name, m_input_names, m_input_shapes, m_input_types, m_model_path, m_output_name, m_output_shape, m_output_type, m_session, SourceXtractor::onnx_logger, and SourceXtractor::ORT_ENV.

Here is the call graph for this function:

Member Function Documentation

◆ getDomain()

std::string SourceXtractor::OnnxModel::getDomain ( ) const
inline

Definition at line 108 of file OnnxModel.h.

References m_domain_name.

Referenced by SourceXtractor::generatePropertyName().

◆ getGraphName()

std::string SourceXtractor::OnnxModel::getGraphName ( ) const
inline

Definition at line 112 of file OnnxModel.h.

References m_graph_name.

Referenced by SourceXtractor::generatePropertyName().

◆ getInputName()

std::string SourceXtractor::OnnxModel::getInputName ( ) const
inline

Definition at line 116 of file OnnxModel.h.

References m_input_names.

◆ getInputNb()

size_t SourceXtractor::OnnxModel::getInputNb ( ) const
inline

Definition at line 128 of file OnnxModel.h.

References m_input_names, and std::vector< T >::size().

Referenced by SourceXtractor::MLSegmentation::labelImage().

Here is the call graph for this function:

◆ getInputShape()

const std::vector<std::int64_t>& SourceXtractor::OnnxModel::getInputShape ( ) const
inline

◆ getInputType()

ONNXTensorElementDataType SourceXtractor::OnnxModel::getInputType ( ) const
inline

Definition at line 92 of file OnnxModel.h.

References m_input_types.

Referenced by SourceXtractor::MLSegmentation::labelImage().

◆ getModelPath()

std::string SourceXtractor::OnnxModel::getModelPath ( ) const
inline

Definition at line 124 of file OnnxModel.h.

References m_model_path.

◆ getOutputName()

std::string SourceXtractor::OnnxModel::getOutputName ( ) const
inline

Definition at line 120 of file OnnxModel.h.

References m_output_name.

Referenced by SourceXtractor::generatePropertyName().

◆ getOutputNb()

size_t SourceXtractor::OnnxModel::getOutputNb ( ) const
inline

Definition at line 132 of file OnnxModel.h.

◆ getOutputShape()

const std::vector<std::int64_t>& SourceXtractor::OnnxModel::getOutputShape ( ) const
inline

◆ getOutputType()

ONNXTensorElementDataType SourceXtractor::OnnxModel::getOutputType ( ) const
inline

◆ run()

template<typename T , typename U >
void SourceXtractor::OnnxModel::run ( std::vector< T > &  input_data,
std::vector< U > &  output_data 
) const
inline

Definition at line 27 of file OnnxModel.h.

References std::accumulate(), std::vector< T >::begin(), std::begin(), std::string::c_str(), std::vector< T >::data(), std::vector< T >::end(), std::end(), m_input_names, m_input_shapes, m_output_name, m_output_shape, m_session, and std::vector< T >::size().

Referenced by SourceXtractor::computePropertiesSpecialized(), and SourceXtractor::MLSegmentation::labelImage().

Here is the call graph for this function:

◆ runMultiInput()

template<typename T , typename U >
void SourceXtractor::OnnxModel::runMultiInput ( std::map< std::string, std::vector< T >> &  input_data,
std::vector< U > &  output_data 
) const
inline

Definition at line 56 of file OnnxModel.h.

References std::accumulate(), std::vector< T >::begin(), std::begin(), std::string::c_str(), std::vector< T >::data(), std::vector< T >::emplace_back(), std::vector< T >::end(), std::end(), m_input_names, m_input_shapes, m_output_name, m_output_shape, m_session, and std::vector< T >::size().

Referenced by ModelFitting::OnnxCompactModel< ImageType >::getRasterizedImage().

Here is the call graph for this function:

Member Data Documentation

◆ m_domain_name

std::string SourceXtractor::OnnxModel::m_domain_name
private

domain name

Definition at line 137 of file OnnxModel.h.

Referenced by getDomain(), and OnnxModel().

◆ m_graph_name

std::string SourceXtractor::OnnxModel::m_graph_name
private

graph name

Definition at line 138 of file OnnxModel.h.

Referenced by getGraphName(), and OnnxModel().

◆ m_input_names

std::vector<std::string> SourceXtractor::OnnxModel::m_input_names
private

Input tensor name.

Definition at line 139 of file OnnxModel.h.

Referenced by getInputName(), getInputNb(), OnnxModel(), run(), and runMultiInput().

◆ m_input_shapes

std::vector<std::vector<std::int64_t> > SourceXtractor::OnnxModel::m_input_shapes
private

Input tensor shape.

Definition at line 143 of file OnnxModel.h.

Referenced by getInputShape(), OnnxModel(), run(), and runMultiInput().

◆ m_input_types

std::vector<ONNXTensorElementDataType> SourceXtractor::OnnxModel::m_input_types
private

Input type.

Definition at line 141 of file OnnxModel.h.

Referenced by getInputType(), and OnnxModel().

◆ m_model_path

std::string SourceXtractor::OnnxModel::m_model_path
private

Path to the ONNX model.

Definition at line 145 of file OnnxModel.h.

Referenced by getModelPath(), and OnnxModel().

◆ m_output_name

std::string SourceXtractor::OnnxModel::m_output_name
private

Output tensor name.

Definition at line 140 of file OnnxModel.h.

Referenced by getOutputName(), OnnxModel(), run(), and runMultiInput().

◆ m_output_shape

std::vector<std::int64_t> SourceXtractor::OnnxModel::m_output_shape
private

Output tensor shape.

Definition at line 144 of file OnnxModel.h.

Referenced by getOutputShape(), OnnxModel(), run(), and runMultiInput().

◆ m_output_type

ONNXTensorElementDataType SourceXtractor::OnnxModel::m_output_type
private

Output type.

Definition at line 142 of file OnnxModel.h.

Referenced by getOutputType(), and OnnxModel().

◆ m_session

std::unique_ptr<Ort::Session> SourceXtractor::OnnxModel::m_session
private

Session, one per model. In theory, it is thread-safe.

Definition at line 146 of file OnnxModel.h.

Referenced by OnnxModel(), run(), and runMultiInput().


The documentation for this class was generated from the following files: