Skip to content

Commit 1cdcb2b

Browse files
committed
Create Ort::Env once per application and reuse it for all sessions
1 parent 37e6912 commit 1cdcb2b

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/algorithms/machinelearning/onnxpredict.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,14 @@ std::string OnnxPredict::getTensorInfos(const std::vector<TensorInfo>& infos, co
181181
}
182182

183183
void OnnxPredict::reset() {
184-
//if (!_isConfigured) return;
184+
185185
input_names.clear();
186186
output_names.clear();
187187
_inputNodes.clear();
188188
_outputNodes.clear();
189-
190-
// TODO: execute the reset() at the beginning in configure()
191-
// TODO: include here the model and session creation
192189

193190
try{
194-
// Define environment
195-
_env = Ort::Env(ORT_LOGGING_LEVEL_WARNING, "multi_io_inference"); // {"default", "test", "multi_io_inference"}
196-
191+
197192
// Reset session
198193
_session.reset();
199194

src/algorithms/machinelearning/onnxpredict.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class OnnxPredict : public Algorithm {
101101

102102
public:
103103

104-
OnnxPredict() : _env(Ort::Env(ORT_LOGGING_LEVEL_WARNING, "test")),
104+
OnnxPredict() : _env(Ort::Env(ORT_LOGGING_LEVEL_WARNING, "multi_io_inference")), // {"default", "test", "multi_io_inference"} - reuse it for all sessions
105105
_sessionOptions(Ort::SessionOptions()), _session(nullptr), _runOptions(NULL), _isConfigured(false){
106106
declareInput(_poolIn, "poolIn", "the pool where to get the feature tensors");
107107
declareOutput(_poolOut, "poolOut", "the pool where to store the output tensors");

0 commit comments

Comments
 (0)