#include <ONNXWrapper.h>
Definition at line 20 of file ONNXWrapper.h.
◆ ONNXWrapper()
ONNXWrapper::ONNXWrapper |
( |
const std::string & |
model_path | ) |
|
Definition at line 9 of file ONNXWrapper.cxx.
11 m_onnxEnv(std::make_unique< Ort::Env >(ORT_LOGGING_LEVEL_WARNING,
"")) {
16 GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
◆ getInputNames()
const std::vector< const char * > & ONNXWrapper::getInputNames |
( |
| ) |
|
◆ getInputShape()
const std::vector< int64_t > & ONNXWrapper::getInputShape |
( |
int |
input_nr = 0 | ) |
|
◆ GetMETAData()
const std::map< std::string, std::string > ONNXWrapper::GetMETAData |
( |
| ) |
|
Definition at line 138 of file ONNXWrapper.cxx.
139 std::map<std::string, std::string> METAData_map;
144 for (
size_t i = 0;
i <
keys.size();
i++) {
◆ GetMETADataByKey()
std::string ONNXWrapper::GetMETADataByKey |
( |
const char * |
key | ) |
|
◆ GetModelInputs()
const std::map< std::string, std::vector< int64_t > > ONNXWrapper::GetModelInputs |
( |
| ) |
|
Definition at line 120 of file ONNXWrapper.cxx.
121 std::map<std::string, std::vector<int64_t>> ModelInputINFO_map;
126 return ModelInputINFO_map;
◆ GetModelOutputs()
const std::map< std::string, std::vector< int64_t > > ONNXWrapper::GetModelOutputs |
( |
| ) |
|
Definition at line 129 of file ONNXWrapper.cxx.
130 std::map<std::string, std::vector<int64_t>> ModelOutputINFO_map;
135 return ModelOutputINFO_map;
◆ getNumInputs()
int ONNXWrapper::getNumInputs |
( |
| ) |
const |
◆ getNumOutputs()
int ONNXWrapper::getNumOutputs |
( |
| ) |
const |
◆ getOutputNames()
const std::vector< const char * > & ONNXWrapper::getOutputNames |
( |
| ) |
|
◆ getOutputShape()
const std::vector< int64_t > & ONNXWrapper::getOutputShape |
( |
int |
output_nr = 0 | ) |
|
◆ getShape()
const std::vector< int64_t > ONNXWrapper::getShape |
( |
Ort::TypeInfo |
model_info | ) |
|
|
private |
Definition at line 181 of file ONNXWrapper.cxx.
182 auto tensor_info = model_info.GetTensorTypeAndShapeInfo();
183 std::vector<int64_t> dims = tensor_info.GetShape();
◆ Run()
std::map< std::string, std::vector< float > > ONNXWrapper::Run |
( |
std::map< std::string, std::vector< float >> |
inputs, |
|
|
int |
n_batches = 1 |
|
) |
| |
Definition at line 51 of file ONNXWrapper.cxx.
60 if ( (
p.second.size() %
n) != 0){
62 throw std::invalid_argument(
"For input '"+
p.first+
"' length not compatible with model. Expect a multiple of "+
std::to_string(
n)+
", got "+
std::to_string(
p.second.size()));
64 if (
p.second.size()!=(n_batches*
n)){
65 throw std::invalid_argument(
"Number of batches not compatible with length of vector");
69 Ort::MemoryInfo memory_info(
"Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
72 std::vector<Ort::Value> output_tensor;
73 std::vector<Ort::Value> input_tensor;
78 std::vector<int64_t> in_dims =
p.second;
79 in_dims.at(0) = n_batches;
80 input_tensor.push_back(Ort::Value::CreateTensor<float>(memory_info,
88 std::map<std::string, std::vector<float>>
outputs;
90 std::vector<int64_t> out_dims =
p.second;
91 out_dims.at(0) = n_batches;
98 output_tensor.push_back(Ort::Value::CreateTensor<float>(memory_info,
108 session.Run(Ort::RunOptions{
nullptr},
113 output_tensor.data(),
◆ m_allocator
Ort::AllocatorWithDefaultOptions ONNXWrapper::m_allocator |
|
private |
◆ m_input_dims
std::map<std::string, std::vector<int64_t> > ONNXWrapper::m_input_dims |
|
private |
◆ m_input_names
std::vector<const char*> ONNXWrapper::m_input_names |
|
private |
◆ m_modelName
std::string ONNXWrapper::m_modelName |
|
private |
◆ m_modelPath
std::string ONNXWrapper::m_modelPath |
|
private |
◆ m_nr_inputs
size_t ONNXWrapper::m_nr_inputs |
|
private |
◆ m_nr_output
size_t ONNXWrapper::m_nr_output |
|
private |
◆ m_onnxEnv
std::unique_ptr< Ort::Env > ONNXWrapper::m_onnxEnv |
|
private |
◆ m_onnxSession
std::unique_ptr<Ort::Session> ONNXWrapper::m_onnxSession |
|
private |
◆ m_output_dims
std::map<std::string, std::vector<int64_t> > ONNXWrapper::m_output_dims |
|
private |
◆ m_output_names
std::vector<const char*> ONNXWrapper::m_output_names |
|
private |
◆ m_session_options
Ort::SessionOptions ONNXWrapper::m_session_options |
|
private |
The documentation for this class was generated from the following files: