11 #include <onnxruntime_cxx_api.h>
14 std::vector<const char*>& inputNames,
15 std::vector<Ort::Value>& inputData,
16 std::vector<const char*>& outputNames,
17 std::vector<Ort::Value>& outputData) {
18 if (inputNames.size() < 1) {
19 throw std::runtime_error(
"Onnxruntime input data mapping cannot be empty");
21 if (inputNames.size() != inputData.size()) {
22 throw std::runtime_error(
"inputData size mismatch");
25 Ort::IoBinding iobinding(sess);
26 for (
size_t idx = 0;
idx < inputNames.size(); ++
idx) {
27 iobinding.BindInput(inputNames[
idx], inputData[idx]);
30 for (
size_t idx = 0;
idx < outputNames.size(); ++
idx) {
31 iobinding.BindOutput(outputNames[
idx], outputData[idx]);
34 sess.Run(Ort::RunOptions{
nullptr}, iobinding);