From 5f6e15058d071ee4da829ff173ade147c89054ce Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Tue, 23 Feb 2021 12:52:30 +0800 Subject: [PATCH] error when loadmodel a unexist file Signed-off-by: zhoufeng --- .../ccsrc/cxx_api/graph/ascend/ascend_graph_impl.cc | 1 + mindspore/ccsrc/cxx_api/serialization.cc | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/cxx_api/graph/ascend/ascend_graph_impl.cc b/mindspore/ccsrc/cxx_api/graph/ascend/ascend_graph_impl.cc index 3c471243417..f928e0184c0 100644 --- a/mindspore/ccsrc/cxx_api/graph/ascend/ascend_graph_impl.cc +++ b/mindspore/ccsrc/cxx_api/graph/ascend/ascend_graph_impl.cc @@ -24,6 +24,7 @@ #include "backend/session/session_factory.h" #include "backend/session/executor_manager.h" #include "runtime/device/kernel_runtime_manager.h" +#include "runtime/dev.h" namespace mindspore { API_FACTORY_REG(GraphCell::GraphImpl, Ascend910, AscendGraphImpl); diff --git a/mindspore/ccsrc/cxx_api/serialization.cc b/mindspore/ccsrc/cxx_api/serialization.cc index 43dc06952c9..ad41849d2e7 100644 --- a/mindspore/ccsrc/cxx_api/serialization.cc +++ b/mindspore/ccsrc/cxx_api/serialization.cc @@ -86,13 +86,10 @@ Graph Serialization::LoadModel(const void *model_data, size_t data_size, ModelTy Graph Serialization::LoadModel(const std::string &file, ModelType model_type) { if (model_type == kMindIR) { - FuncGraphPtr anf_graph = nullptr; - try { - anf_graph = LoadMindIR(file); - } catch (const std::exception &) { - MS_LOG(EXCEPTION) << "Load MindIR failed."; + FuncGraphPtr anf_graph = LoadMindIR(file); + if (anf_graph == nullptr) { + MS_LOG(EXCEPTION) << "Load model failed."; } - return Graph(std::make_shared(anf_graph, kMindIR)); } else if (model_type == kOM) { Buffer data = ReadFile(file);