|
| Session (const std::string filename) |
| Constructs a new ONNX Runtime Session using the specified model file.
|
|
void | run (const std::map< std::string, std::shared_ptr< BaseTensor > > &inputMap, const std::map< std::string, std::shared_ptr< BaseTensor > > &outputMap) |
| Runs inference on the model using named Tensor maps.
|
|
void | run (const std::vector< const char * > &inputNames, std::vector< Ort::Value > &inputs, const std::vector< const char * > &outputNames, std::vector< Ort::Value > &outputs) |
| Runs inference on the model using raw ONNX Runtime inputs and outputs.
|
|
A wrapper around Ort::Session providing model execution.
This class encapsulates an ONNX Runtime session, pre-configured with default settings such as single-threaded execution. It offers a more user-friendly interface to run inference using a custom Tensor
class, which is easier to work with than raw Ort::Value
instances.
Example usage:
#include <mva/methods/ONNX.h>
input_b->
at({0, 2, 4}) = 42;
session.run({{"a", input_a}, {"b", input_b}}, {{"output", output}});
int output_3 = output->at(3);
A wrapper around Ort::Session providing model execution.
Represents an input or output tensor for an ONNX model.
static auto make_shared(std::vector< int64_t > shape)
Convenience method to create a shared pointer to a Tensor from shape.
auto & at(size_t index)
Accesses the element at the specified flat index.
- Note
- This method will not work with
Tensor<bool>
since the underlying std::vector<bool>
does not support getting a pointer to an array. If you have a model with boolean inputs, either convert it to accept a different type (e.g. uint8_t) or use the Session::run
overload thet works directl with Ort::Value
instances.
Definition at line 301 of file ONNX.h.