From a0cc983445ce50a7404a8c85c146723c934972fc Mon Sep 17 00:00:00 2001 From: fary86 Date: Wed, 20 May 2020 17:11:01 +0800 Subject: [PATCH] Set submodule id for init.cc --- mindspore/ccsrc/CMakeLists.txt | 1 + mindspore/ccsrc/ir/meta_func_graph.cc | 23 +++++++++++++++++++++++ mindspore/ccsrc/ir/meta_func_graph.h | 23 +---------------------- mindspore/ccsrc/utils/convert_utils.cc | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index fb348ebbd2..a7513699fa 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -172,6 +172,7 @@ endif() # set c_expression building set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +set_property(SOURCE "pipeline/init.cc" PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_PIPELINE) pybind11_add_module(_c_expression "pipeline/init.cc") MESSAGE(STATUS "operation system is ${CMAKE_SYSTEM}") diff --git a/mindspore/ccsrc/ir/meta_func_graph.cc b/mindspore/ccsrc/ir/meta_func_graph.cc index 58a500a28c..3b2704613a 100644 --- a/mindspore/ccsrc/ir/meta_func_graph.cc +++ b/mindspore/ccsrc/ir/meta_func_graph.cc @@ -32,4 +32,27 @@ abstract::AbstractBasePtr MetaFuncGraph::MakeAbstractClosure(const AnfNodePtr &a } return meta_func_graph_fn; } + +FuncGraphPtr MetaFuncGraph::GenerateFuncGraph(const abstract::AbstractBasePtrList &args_spec_list) { + TypePtrList types; + (void)std::transform(args_spec_list.begin(), args_spec_list.end(), std::back_inserter(types), + [](const AbstractBasePtr &arg) -> TypePtr { + MS_EXCEPTION_IF_NULL(arg); + return arg->BuildType(); + }); + // filter unsafe characters in log print since name_ is from outside + auto iter = cache_.find(types); + if (iter == cache_.end()) { + FuncGraphPtr fg = GenerateFromTypes(types); + MS_EXCEPTION_IF_NULL(fg); + MS_LOG(INFO) << "MetaFuncgraph: cache miss for types: " << mindspore::ToString(args_spec_list) + << ", g: " << fg->ToString(); + cache_[types] = fg; + return fg; + } else { + MS_LOG(DEBUG) << "MetaFuncgraph: cache hit for types: " << mindspore::ToString(args_spec_list) + << ", g: " << iter->second->ToString(); + return iter->second; + } +} } // namespace mindspore diff --git a/mindspore/ccsrc/ir/meta_func_graph.h b/mindspore/ccsrc/ir/meta_func_graph.h index 533c66d40a..f63f812f9e 100644 --- a/mindspore/ccsrc/ir/meta_func_graph.h +++ b/mindspore/ccsrc/ir/meta_func_graph.h @@ -58,28 +58,7 @@ class MetaFuncGraph : public FuncGraphBase { const std::vector &signatures() const { return signatures_; } void set_signatures(const std::vector &signatures) { signatures_ = signatures; } // Generate a Graph for the given abstract arguments. - virtual FuncGraphPtr GenerateFuncGraph(const abstract::AbstractBasePtrList &args_spec_list) { - TypePtrList types; - (void)std::transform(args_spec_list.begin(), args_spec_list.end(), std::back_inserter(types), - [](const AbstractBasePtr &arg) -> TypePtr { - MS_EXCEPTION_IF_NULL(arg); - return arg->BuildType(); - }); - // filter unsafe characters in log print since name_ is from outside - auto iter = cache_.find(types); - if (iter == cache_.end()) { - FuncGraphPtr fg = GenerateFromTypes(types); - MS_EXCEPTION_IF_NULL(fg); - MS_LOG(INFO) << "MetaFuncgraph: cache miss for types: " << mindspore::ToString(args_spec_list) - << ", g: " << fg->ToString(); - cache_[types] = fg; - return fg; - } else { - MS_LOG(DEBUG) << "MetaFuncgraph: cache hit for types: " << mindspore::ToString(args_spec_list) - << ", g: " << iter->second->ToString(); - return iter->second; - } - } + virtual FuncGraphPtr GenerateFuncGraph(const abstract::AbstractBasePtrList &args_spec_list); // Generate a Graph for this type signature. virtual FuncGraphPtr GenerateFromTypes(const TypePtrList &) { diff --git a/mindspore/ccsrc/utils/convert_utils.cc b/mindspore/ccsrc/utils/convert_utils.cc index 0d4ca74095..d5bbc2603b 100644 --- a/mindspore/ccsrc/utils/convert_utils.cc +++ b/mindspore/ccsrc/utils/convert_utils.cc @@ -172,7 +172,7 @@ py::object AnyToPyData(const Any &value) { py::object BaseRefToPyData(const BaseRef &value) { py::object ret; - MS_LOG(DEBUG) << "BaseRefToPyData " << common::SafeCStr(value.ToString()); + MS_LOG(DEBUG) << "BaseRefToPyData " << value.ToString(); if (utils::isa(value) || utils::isa(value) || utils::isa(value) || utils::isa(value)) { ret = BuiltinsToPyData(value); } else if (utils::isa(value)) {