FCCAnalyses
Loading...
Searching...
No Matches
ONNXRuntime.h
Go to the documentation of this file.
1#ifndef ONNXRuntime_ONNXRuntime_h
2#define ONNXRuntime_ONNXRuntime_h
3
4#include "onnxruntime_cxx_api.h"
5
6#include <string>
7#include <vector>
8#include <map>
9#include <memory>
10
12public:
13 explicit ONNXRuntime(const std::string& = "", const std::vector<std::string>& = {});
14 virtual ~ONNXRuntime();
15
16 template <typename T>
17 using Tensor = std::vector<std::vector<T>>;
18
19 ONNXRuntime(const ONNXRuntime&) = delete;
21
22 const std::vector<std::string>& inputNames() const { return input_names_; }
23
24 template <typename T>
25 Tensor<T> run(Tensor<T>&, const Tensor<long>& = {}, unsigned long long = 1ull) const;
26
27private:
28 size_t variablePos(const std::string&) const;
29
30 std::unique_ptr<Ort::Env> env_;
31 std::unique_ptr<Ort::Session> session_;
32 Ort::MemoryInfo memoryInfo_;
33
34 std::vector<const char*> input_node_strings_, output_node_strings_;
35 std::vector<std::string> input_names_;
36 std::map<std::string, std::vector<int64_t>> input_node_dims_, output_node_dims_;
37};
38
39#endif
Definition ONNXRuntime.h:11
std::unique_ptr< Ort::Session > session_
Definition ONNXRuntime.h:31
const std::vector< std::string > & inputNames() const
Definition ONNXRuntime.h:22
std::vector< const char * > output_node_strings_
Definition ONNXRuntime.h:34
std::vector< std::string > input_names_
Definition ONNXRuntime.h:35
ONNXRuntime(const ONNXRuntime &)=delete
size_t variablePos(const std::string &) const
Definition ONNXRuntime.cc:113
std::unique_ptr< Ort::Env > env_
Definition ONNXRuntime.h:30
ONNXRuntime & operator=(const ONNXRuntime &)=delete
std::map< std::string, std::vector< int64_t > > input_node_dims_
Definition ONNXRuntime.h:36
std::vector< const char * > input_node_strings_
Definition ONNXRuntime.h:34
Tensor< T > run(Tensor< T > &, const Tensor< long > &={}, unsigned long long=1ull) const
Definition ONNXRuntime.cc:60
ONNXRuntime(const std::string &="", const std::vector< std::string > &={})
Definition ONNXRuntime.cc:6
Ort::MemoryInfo memoryInfo_
Definition ONNXRuntime.h:32
std::vector< std::vector< T > > Tensor
Definition ONNXRuntime.h:17
virtual ~ONNXRuntime()
Definition ONNXRuntime.cc:57
std::map< std::string, std::vector< int64_t > > output_node_dims_
Definition ONNXRuntime.h:36