100 std::vector<Value> input_tensors;
101 auto memory_info = MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
108 auto value = input_values.begin() + input_pos;
109 std::vector<int64_t> input_dims;
110 if (input_shapes.empty()) {
112 input_dims[0] = batch_size;
114 input_dims = input_shapes[input_pos];
116 if (input_dims[0] != batch_size) {
117 throw cms::Exception(
"RuntimeError") <<
"The first element of `input_shapes` (" << input_dims[0]
118 <<
") does not match the given `batch_size` (" << batch_size <<
")";
121 auto expected_len = std::accumulate(input_dims.begin(), input_dims.end(), 1, std::multiplies<int64_t>());
122 if (expected_len != (int64_t)
value->size()) {
124 <<
"Input array " <<
name <<
" has a wrong size of " <<
value->size() <<
", expected " << expected_len;
127 Value::CreateTensor<float>(memory_info,
value->data(),
value->size(), input_dims.data(), input_dims.size());
128 assert(input_tensor.IsTensor());
129 input_tensors.emplace_back(
std::move(input_tensor));
133 std::vector<const char*> run_output_node_names;
138 run_output_node_names.push_back(
name.c_str());
143 auto output_tensors =
session_->Run(RunOptions{
nullptr},
145 input_tensors.data(),
146 input_tensors.size(),
147 run_output_node_names.data(),
148 run_output_node_names.size());
152 for (
auto& output_tensor : output_tensors) {
153 assert(output_tensor.IsTensor());
156 auto tensor_info = output_tensor.GetTensorTypeAndShapeInfo();
157 auto length = tensor_info.GetElementCount();
159 auto floatarr = output_tensor.GetTensorMutableData<
float>();
160 outputs.emplace_back(floatarr, floatarr + length);
std::unique_ptr<::Ort::Session > session_
std::map< std::string, std::vector< int64_t > > input_node_dims_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::vector< float > > FloatArrays
std::vector< const char * > output_node_names_
std::vector< std::string > input_node_strings_
std::vector< const char * > input_node_names_