From eabc1616e60ca41ba94bd282f9f8f8e083069aba Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Thu, 2 Jul 2020 12:27:14 -0700 Subject: [PATCH] Rename variable in InferenceSession class so as to not clash with an existing var (#4391) * Rename variable in InferenceSession class so as to not clash with an existing var * Fix build break --- onnxruntime/core/session/inference_session.cc | 24 +++++++++---------- onnxruntime/core/session/inference_session.h | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 1028b43ae4..d0a2b6a97c 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -158,7 +158,7 @@ static Status FinalizeSessionOptions(const SessionOptions& user_provided_session void InferenceSession::ConstructorCommon(const SessionOptions& session_options, const Environment& session_env) { - auto status = FinalizeSessionOptions(session_options, model_proto_, model_loaded_, session_options_); + auto status = FinalizeSessionOptions(session_options, model_proto_, is_model_proto_parsed_, session_options_); ORT_ENFORCE(status.IsOK(), "Could not finalize session options while constructing the inference session. Error Message: ", status.ErrorMessage()); @@ -236,7 +236,7 @@ InferenceSession::InferenceSession(const SessionOptions& session_options, const auto status = Model::Load(model_location_, model_proto_); ORT_ENFORCE(status.IsOK(), "Given model could not be parsed while creating inference session. Error message: ", status.ErrorMessage()); - model_loaded_ = true; + is_model_proto_parsed_ = true; // Finalize session options and initialize assets of this session instance ConstructorCommon(session_options, session_env); } @@ -252,7 +252,7 @@ InferenceSession::InferenceSession(const SessionOptions& session_options, auto status = Model::Load(model_location_, model_proto_); ORT_ENFORCE(status.IsOK(), "Given model could not be parsed while creating inference session. Error message: ", status.ErrorMessage()); - model_loaded_ = true; + is_model_proto_parsed_ = true; // Finalize session options and initialize assets of this session instance ConstructorCommon(session_options, session_env); } @@ -266,7 +266,7 @@ InferenceSession::InferenceSession(const SessionOptions& session_options, const google::protobuf::io::IstreamInputStream zero_copy_input(&model_istream); const bool result = model_proto_.ParseFromZeroCopyStream(&zero_copy_input) && model_istream.eof(); ORT_ENFORCE(result, "Could not parse model successfully while constructing the inference session"); - model_loaded_ = true; + is_model_proto_parsed_ = true; // Finalize session options and initialize assets of this session instance ConstructorCommon(session_options, session_env); } @@ -278,7 +278,7 @@ InferenceSession::InferenceSession(const SessionOptions& session_options, const insert_cast_transformer_("CastFloat16Transformer") { const bool result = model_proto_.ParseFromArray(model_data, model_data_len); ORT_ENFORCE(result, "Could not parse model successfully while constructing the inference session"); - model_loaded_ = true; + is_model_proto_parsed_ = true; // Finalize session options and initialize assets of this session instance ConstructorCommon(session_options, session_env); } @@ -458,7 +458,7 @@ common::Status InferenceSession::Load(const std::basic_string& model_uri) { } common::Status InferenceSession::Load(const std::string& model_uri) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -469,7 +469,7 @@ common::Status InferenceSession::Load(const std::string& model_uri) { #ifdef _WIN32 common::Status InferenceSession::Load(const std::wstring& model_uri) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -480,7 +480,7 @@ common::Status InferenceSession::Load(const std::wstring& model_uri) { #endif common::Status InferenceSession::Load(const ModelProto& model_proto) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -502,7 +502,7 @@ common::Status InferenceSession::Load(const ModelProto& model_proto) { } common::Status InferenceSession::Load(std::unique_ptr p_model_proto) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -523,7 +523,7 @@ common::Status InferenceSession::Load(std::unique_ptr p_model_proto) } common::Status InferenceSession::Load(std::istream& model_istream) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -552,7 +552,7 @@ common::Status InferenceSession::Load(std::istream& model_istream) { } common::Status InferenceSession::Load(const void* model_data, int model_data_len) { - if (model_loaded_) { + if (is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has already been parsed. " "Invoke Load()."); @@ -581,7 +581,7 @@ common::Status InferenceSession::Load(const void* model_data, int model_data_len } common::Status InferenceSession::Load() { - if (!model_loaded_) { + if (!is_model_proto_parsed_) { return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "ModelProto corresponding to the model to be loaded has not been parsed yet. " "This API should be called in conjunction with a ctor that takes a model abstraction."); diff --git a/onnxruntime/core/session/inference_session.h b/onnxruntime/core/session/inference_session.h index 49e8776d64..9841821eb9 100644 --- a/onnxruntime/core/session/inference_session.h +++ b/onnxruntime/core/session/inference_session.h @@ -552,7 +552,8 @@ class InferenceSession { // used to hold the ModelProto parsed in an applicable ctor to be used while calling parameter-less Load() ONNX_NAMESPACE::ModelProto model_proto_; - bool model_loaded_ = false; + // Flag indicating if ModelProto has been parsed in an applicable ctor + bool is_model_proto_parsed_ = false; }; struct SessionIOBinding {