11 m_onnxEnv(std::
make_unique< Ort::Env >(ORT_LOGGING_LEVEL_WARNING,
"")) {
16 GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
52 std::map<std::string, std::vector<float>>
inputs,
int n_batches) {
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(),
121 std::map<std::string, std::vector<int64_t>> ModelInputINFO_map;
126 return ModelInputINFO_map;
130 std::map<std::string, std::vector<int64_t>> ModelOutputINFO_map;
135 return ModelOutputINFO_map;
139 std::map<std::string, std::string> METAData_map;
144 for (
size_t i = 0;
i <
keys.size();
i++) {
182 auto tensor_info = model_info.GetTensorTypeAndShapeInfo();
183 std::vector<int64_t> dims = tensor_info.GetShape();