Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions onnxruntime/hosting/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ std::unique_ptr<logging::Logger> HostingEnvironment::GetLogger(const std::string
return default_logging_manager_.CreateLogger(id, severity_, false);
}

onnxruntime::InferenceSession* HostingEnvironment::GetSession() const {
return session.get();
}

} // namespace hosting
} // namespace onnxruntime
6 changes: 3 additions & 3 deletions onnxruntime/hosting/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ class HostingEnvironment {
std::unique_ptr<logging::Logger> GetLogger(const std::string& id);
logging::Severity GetLogSeverity() const;

common::Status
InitializeModel(const std::string& model_path);
onnxruntime::InferenceSession* GetSession() const;
common::Status InitializeModel(const std::string& model_path);
const std::vector<std::string>& GetModelOutputNames() const;

std::unique_ptr<onnxruntime::InferenceSession> session;

private:
const logging::Severity severity_;
Expand All @@ -38,6 +37,7 @@ class HostingEnvironment {

std::unique_ptr<onnxruntime::Environment> runtime_environment_;
onnxruntime::SessionOptions options_;
std::unique_ptr<onnxruntime::InferenceSession> session;
std::vector<std::string> model_output_names_;
};

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/hosting/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protobufutil::Status Executor::Predict(const std::string& model_name,
run_options.run_log_verbosity_level = static_cast<unsigned int>(env_->GetLogSeverity());
run_options.run_tag = request_id_;

auto status = env_->session->Run(run_options, name_ml_value_map, output_names, &outputs);
auto status = env_->GetSession()->Run(run_options, name_ml_value_map, output_names, &outputs);

if (!status.IsOK()) {
LOGS(*logger, ERROR) << "Run() failed."
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/hosting/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) {
LOGS(logger, VERBOSE) << "Initialize Model Successfully!";
}

status = env->session->Initialize();
status = env->GetSession()->Initialize();
if (!status.IsOK()) {
LOGS(logger, FATAL) << "Session Initialization Failed:" << status.Code() << " ---- Error: [" << status.ErrorMessage() << "]";
exit(EXIT_FAILURE);
Expand Down