9 m_onnxEnv = std::make_unique< Ort::Env >(ORT_LOGGING_LEVEL_WARNING,
"");
14 GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
50 std::map<std::string, std::vector<float>>
inputs,
int n_batches) {
58 if ( (
p.second.size() %
n) != 0){
60 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()));
62 if (
p.second.size()!=(n_batches*
n)){
63 throw std::invalid_argument(
"Number of batches not compatible with length of vector");
67 Ort::MemoryInfo memory_info(
"Cpu", OrtDeviceAllocator, 0, OrtMemTypeDefault);
70 std::vector<Ort::Value> output_tensor;
71 std::vector<Ort::Value> input_tensor;
76 std::vector<int64_t> in_dims =
p.second;
77 in_dims.at(0) = n_batches;
78 input_tensor.push_back(Ort::Value::CreateTensor<float>(memory_info,
86 std::map<std::string, std::vector<float>>
outputs;
88 std::vector<int64_t> out_dims =
p.second;
89 out_dims.at(0) = n_batches;
96 output_tensor.push_back(Ort::Value::CreateTensor<float>(memory_info,
106 session.Run(Ort::RunOptions{
nullptr},
111 output_tensor.data(),
119 std::map<std::string, std::vector<int64_t>> ModelInputINFO_map;
124 return ModelInputINFO_map;
128 std::map<std::string, std::vector<int64_t>> ModelOutputINFO_map;
133 return ModelOutputINFO_map;
137 std::map<std::string, std::string> METAData_map;
142 for (
size_t i = 0;
i <
keys.size();
i++) {
180 auto tensor_info = model_info.GetTensorTypeAndShapeInfo();
181 std::vector<int64_t> dims = tensor_info.GetShape();