|
virtual void | setBatchSize (int64_t batchSize)=0 |
| set batch size. More...
|
|
virtual int64_t | getBatchSize (int64_t dataSize, int idx=0) const =0 |
| methods for determining batch size from the data size More...
|
|
template<typename T > |
StatusCode | addInput (std::vector< Ort::Value > &inputTensors, std::vector< T > &data, unsigned idx=0, int64_t batchSize=-1) const |
| add the input data to the input tensors More...
|
|
template<typename T > |
StatusCode | addOutput (std::vector< Ort::Value > &outputTensors, std::vector< T > &data, unsigned idx=0, int64_t batchSize=-1) const |
| add the output data to the output tensors More...
|
|
virtual StatusCode | inference (std::vector< Ort::Value > &inputTensors, std::vector< Ort::Value > &outputTensors) const =0 |
| perform inference More...
|
|
virtual void | printModelInfo () const =0 |
|
virtual void | print () const =0 |
| Print the state of the tool. More...
|
|
Interface class for creating Onnx Runtime sessions.
Interface class for creating Onnx Runtime sessions. It is thread safe, supports models with various number of inputs and outputs, supports models with dynamic batch size, and usess . It defines a standardized procedure to perform Onnx Runtime inference. The procedure is as follows, assuming the tool m_onnxTool
is created and initialized:
- create input tensors from the input data: ```c++ std::vector<Ort::Value> inputTensors; std::vector<float> inputData_1; // The input data is filled by users, possibly from the event information. int64_t batchSize = m_onnxTool->getBatchSize(inputData_1.size(), 0); // The batch size is determined by the input data size to support dynamic batch size. m_onnxTool->addInput(inputTensors, inputData_1, 0, batchSize); std::vector<int64_t> inputData_2; // Some models may have multiple inputs. Add inputs one by one. int64_t batchSize_2 = m_onnxTool->getBatchSize(inputData_2.size(), 1); m_onnxTool->addInput(inputTensors, inputData_2, 1, batchSize_2); ```
- create output tensors: ```c++ std::vector<Ort::Value> outputTensors; std::vector<float> outputData; // The output data will be filled by the onnx session. m_onnxTool->addOutput(outputTensors, outputData, 0, batchSize); ```
perform inference: ```c++ m_onnxTool->inference(inputTensors, outputTensors); ```
- Model outputs will be automatically filled to outputData.
- Author
- Xiangyang Ju xju@c.nosp@m.ern..nosp@m.ch
Definition at line 47 of file IOnnxRuntimeInferenceTool.h.