Project
Loading...
Searching...
No Matches
o2::zdc::fastsim::NeuralFastSimulation Class Referenceabstract

Abstract class providing interface for various specialized implementations. More...

#include <FastSimulations.h>

Inherited by o2::zdc::fastsim::ConditionalModelSimulation.

Public Member Functions

 NeuralFastSimulation (const std::string &modelPath, OrtAllocatorType allocatorType, OrtMemType memoryType, int64_t batchSize)
 
virtual ~NeuralFastSimulation ()=default
 
void initRunSession ()
 (late) init session and provide mechanism to customize ONNX session with external options
 
virtual bool setInput (std::vector< std::vector< float > > &input)=0
 Wrapper for converting raw input to Ort::Value.
 
virtual void run ()=0
 Wraps Session.Run() Result should be stored as private member.
 
virtual const std::vector< Ort::Value > & getResult ()=0
 returns model output as const &.
 
size_t getBatchSize () const
 

Protected Member Functions

void setInputOutputData ()
 Sets models metadata (input/output layers names, inputs shape) in onnx session.
 
void setTensors (std::vector< std::vector< float > > &input)
 Converts flattend input data to Ort::Value. Tensor shapes are taken from loaded model metadata.
 

Protected Attributes

std::string mModelPath
 model path (where to find the ONNX model)
 
Ort::Env mEnv
 
Ort::Session * mSession = nullptr
 
Ort::AllocatorWithDefaultOptions mAllocator
 
Ort::MemoryInfo mMemoryInfo
 
std::vector< std::string > mInputNames
 Input/Output names and input shape.
 
std::vector< std::string > mOutputNames
 
std::vector< std::vector< int64_t > > mInputShapes
 
int64_t mBatchSize
 
std::vector< Ort::Value > mInputTensors
 Container for input tensors.
 

Detailed Description

Abstract class providing interface for various specialized implementations.

Definition at line 34 of file FastSimulations.h.

Constructor & Destructor Documentation

◆ NeuralFastSimulation()

NeuralFastSimulation::NeuralFastSimulation ( const std::string &  modelPath,
OrtAllocatorType  allocatorType,
OrtMemType  memoryType,
int64_t  batchSize 
)

Definition at line 27 of file FastSimulations.cxx.

◆ ~NeuralFastSimulation()

virtual o2::zdc::fastsim::NeuralFastSimulation::~NeuralFastSimulation ( )
virtualdefault

Member Function Documentation

◆ getBatchSize()

size_t NeuralFastSimulation::getBatchSize ( ) const

Definition at line 43 of file FastSimulations.cxx.

◆ getResult()

virtual const std::vector< Ort::Value > & o2::zdc::fastsim::NeuralFastSimulation::getResult ( )
pure virtual

returns model output as const &.

Implemented in o2::zdc::fastsim::ConditionalModelSimulation.

◆ initRunSession()

void NeuralFastSimulation::initRunSession ( )

(late) init session and provide mechanism to customize ONNX session with external options

Definition at line 34 of file FastSimulations.cxx.

◆ run()

virtual void o2::zdc::fastsim::NeuralFastSimulation::run ( )
pure virtual

Wraps Session.Run() Result should be stored as private member.

Implemented in o2::zdc::fastsim::ConditionalModelSimulation.

◆ setInput()

virtual bool o2::zdc::fastsim::NeuralFastSimulation::setInput ( std::vector< std::vector< float > > &  input)
pure virtual

Wrapper for converting raw input to Ort::Value.

Parameters
inputflattened input data
Returns
true on success
false on failure

Implemented in o2::zdc::fastsim::ConditionalModelSimulation.

◆ setInputOutputData()

void NeuralFastSimulation::setInputOutputData ( )
protected

Sets models metadata (input/output layers names, inputs shape) in onnx session.

Definition at line 48 of file FastSimulations.cxx.

◆ setTensors()

void NeuralFastSimulation::setTensors ( std::vector< std::vector< float > > &  input)
protected

Converts flattend input data to Ort::Value. Tensor shapes are taken from loaded model metadata.

Definition at line 72 of file FastSimulations.cxx.

Member Data Documentation

◆ mAllocator

Ort::AllocatorWithDefaultOptions o2::zdc::fastsim::NeuralFastSimulation::mAllocator
protected

Definition at line 81 of file FastSimulations.h.

◆ mBatchSize

int64_t o2::zdc::fastsim::NeuralFastSimulation::mBatchSize
protected

If model has dynamic axis (for batch processing) this will tell ONNX expected size of those axis otherwise mBatchSize has no effect during runtime

Definition at line 90 of file FastSimulations.h.

◆ mEnv

Ort::Env o2::zdc::fastsim::NeuralFastSimulation::mEnv
protected

ONNX specific attributes User shoudn't has direct access to those in derived classes

Definition at line 79 of file FastSimulations.h.

◆ mInputNames

std::vector<std::string> o2::zdc::fastsim::NeuralFastSimulation::mInputNames
protected

Input/Output names and input shape.

Definition at line 85 of file FastSimulations.h.

◆ mInputShapes

std::vector<std::vector<int64_t> > o2::zdc::fastsim::NeuralFastSimulation::mInputShapes
protected

Definition at line 87 of file FastSimulations.h.

◆ mInputTensors

std::vector<Ort::Value> o2::zdc::fastsim::NeuralFastSimulation::mInputTensors
protected

Container for input tensors.

Definition at line 93 of file FastSimulations.h.

◆ mMemoryInfo

Ort::MemoryInfo o2::zdc::fastsim::NeuralFastSimulation::mMemoryInfo
protected

Definition at line 82 of file FastSimulations.h.

◆ mModelPath

std::string o2::zdc::fastsim::NeuralFastSimulation::mModelPath
protected

model path (where to find the ONNX model)

Definition at line 75 of file FastSimulations.h.

◆ mOutputNames

std::vector<std::string> o2::zdc::fastsim::NeuralFastSimulation::mOutputNames
protected

Definition at line 86 of file FastSimulations.h.

◆ mSession

Ort::Session* o2::zdc::fastsim::NeuralFastSimulation::mSession = nullptr
protected

Definition at line 80 of file FastSimulations.h.


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