From 5b39a3ea6e83e669531355d0074331fc06c77f37 Mon Sep 17 00:00:00 2001 From: lvliang Date: Thu, 23 Apr 2020 20:40:00 +0800 Subject: [PATCH] fix-check-nullptr-by-calling-function --- mindspore/ccsrc/session/session_basic.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/session/session_basic.cc b/mindspore/ccsrc/session/session_basic.cc index b2daa07d7..40b69b75b 100755 --- a/mindspore/ccsrc/session/session_basic.cc +++ b/mindspore/ccsrc/session/session_basic.cc @@ -572,7 +572,6 @@ KernelGraphPtr SessionBasic::ConstructKernelGraph(const AnfNodePtrList &lst, con // run graph steps void SessionBasic::LoadInputData(const std::shared_ptr &kernel_graph, const std::vector &inputs_const) const { - MS_EXCEPTION_IF_NULL(kernel_graph); std::vector inputs(inputs_const); size_t input_ctrl_size = 1; MS_EXCEPTION_IF_NULL(context_); @@ -585,6 +584,8 @@ void SessionBasic::LoadInputData(const std::shared_ptr &kernel_grap MS_LOG(EXCEPTION) << "tensor input:" << inputs.size() << " is not equal graph inputs:" << input_nodes.size() << ", input_ctrl_size:" << input_ctrl_size; } + auto ms_context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(ms_context); for (size_t i = 0; i < inputs.size(); ++i) { auto tensor = inputs[i]; MS_EXCEPTION_IF_NULL(tensor); @@ -594,8 +595,7 @@ void SessionBasic::LoadInputData(const std::shared_ptr &kernel_grap auto pk_node = input_node->cast(); auto device_address = AnfAlgo::GetMutableOutputAddr(pk_node, 0); bool need_sync = false; - MS_EXCEPTION_IF_NULL(MsContext::GetInstance()); - if (MsContext::GetInstance()->enable_pynative_infer()) { + if (ms_context->enable_pynative_infer()) { if (tensor->device_address().get() == nullptr || tensor->device_address() != device_address) { need_sync = true; } -- GitLab