提交 2f2dc390 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!3079 Move abstract/base into core, and remove static_analysis symbols in ir.

Merge pull request !3079 from ZhangQinghua/master
......@@ -138,7 +138,7 @@ set(SUB_COMP
frontend/operator
pipeline/jit
pipeline/pynative
common debug gvar predict pybind_api utils vm base abstract
common debug gvar predict pybind_api utils vm
)
foreach (_comp ${SUB_COMP})
......@@ -149,9 +149,13 @@ foreach (_comp ${SUB_COMP})
add_dependencies(_mindspore_${sub}_obj proto_input flat_input)
endif ()
endforeach ()
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/base base)
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_base_obj>)
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/abstract abstract)
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_abstract_obj>)
add_subdirectory(${CMAKE_SOURCE_DIR}/mindspore/core/ir ir)
list(APPEND SUB_OBJECTS_SRC $<TARGET_OBJECTS:_mindspore_ir_obj>)
add_dependencies(_mindspore_ir_obj proto_input flat_input)
add_dependencies(_mindspore_base_obj _mindspore_ir_obj _mindspore_abstract_obj proto_input flat_input)
set_property(SOURCE ${SUB_OBJECTS_SRC} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_ME)
add_library(mindspore STATIC ${SUB_OBJECTS_SRC})
......
......@@ -612,10 +612,34 @@ EvalResultPtr AnfNodeConfig::GetEvaluatedValue() {
return engine_.lock()->GetEvaluatedValue(self);
}
abstract::AbstractBasePtr MakeAbstractClosure(const FuncGraphPtr &func_graph,
const abstract::AnalysisContextPtr &context) {
AnalysisContextPtr temp_context = context;
if (temp_context == nullptr) {
temp_context = abstract::AnalysisContext::DummyContext();
}
return std::make_shared<abstract::FuncGraphAbstractClosure>(func_graph, temp_context);
}
abstract::AbstractBasePtr MakeAbstractClosure(const MetaFuncGraphPtr &meta_func_graph, const AnfNodePtr &anf_node) {
abstract::MetaFuncGraphAbstractClosurePtr meta_func_graph_fn;
if (anf_node == nullptr) {
meta_func_graph_fn = std::make_shared<abstract::MetaFuncGraphAbstractClosure>(meta_func_graph);
} else {
meta_func_graph_fn = std::make_shared<abstract::MetaFuncGraphAbstractClosure>(meta_func_graph, anf_node->scope());
}
return meta_func_graph_fn;
}
abstract::AbstractBasePtr MakeAbstractClosure(const PrimitivePtr &primitive, const AnfNodePtr &anf_node) {
auto prim_func = std::make_shared<abstract::PrimitiveAbstractClosure>(primitive, anf_node);
return prim_func;
}
AbstractBasePtr ToAbstract(const ValuePtr &value, const AnalysisContextPtr &context, const AnfNodeConfigPtr &conf) {
if (value->isa<FuncGraph>()) {
auto func_graph = value->cast<FuncGraphPtr>();
return func_graph->MakeAbstractClosure(context);
return MakeAbstractClosure(func_graph, context);
}
AnfNodePtr anf_node = nullptr;
if (conf != nullptr) {
......@@ -623,11 +647,11 @@ AbstractBasePtr ToAbstract(const ValuePtr &value, const AnalysisContextPtr &cont
}
if (value->isa<MetaFuncGraph>()) {
auto meta_func_graph = value->cast<MetaFuncGraphPtr>();
return meta_func_graph->MakeAbstractClosure(anf_node);
return MakeAbstractClosure(meta_func_graph, anf_node);
}
if (value->isa<Primitive>()) {
auto prim = value->cast<PrimitivePtr>();
return prim->ToPrimAbstract(anf_node);
return MakeAbstractClosure(prim, anf_node);
}
return value->ToAbstract();
}
......
......@@ -22,7 +22,7 @@
#include <unordered_map>
#include "ir/visitor.h"
#include "pipeline/jit/static_analysis/static_analysis.h"
#include "ir/func_graph.h"
#include "frontend/operator/ops.h"
#include "frontend/parallel/ops_info/ops_utils.h"
#include "debug/label.h"
......
......@@ -149,7 +149,6 @@ class FuncGraph : public FuncGraphBase {
// get the graph's abstract
abstract::AbstractFunctionPtr abstract();
abstract::AbstractBasePtr MakeAbstractClosure(const abstract::AnalysisContextPtr &context);
// return the graph's output, or nullptr if not yet deduced
AnfNodePtr output() const;
......
......@@ -25,9 +25,6 @@
#include "frontend/operator/ops.h"
#include "utils/ordered_set.h"
#include "abstract/abstract_value.h"
#include "pipeline/jit/static_analysis/static_analysis.h"
#include "pipeline/jit/static_analysis/abstract_function.h"
#include "debug/anf_ir_dump.h"
#include "debug/trace.h"
#include "debug/draw.h"
......@@ -60,14 +57,6 @@ AbstractFunctionPtr FuncGraph::abstract() {
return std::make_shared<VirtualAbstractClosure>(args_spec_list, output()->abstract());
}
abstract::AbstractBasePtr FuncGraph::MakeAbstractClosure(const abstract::AnalysisContextPtr &context) {
AnalysisContextPtr temp_context = context;
if (temp_context == nullptr) {
temp_context = abstract::AnalysisContext::DummyContext();
}
return std::make_shared<abstract::FuncGraphAbstractClosure>(shared_from_base<FuncGraph>(), temp_context);
}
void FuncGraph::set_output(const AnfNodePtr &value, bool force_new_ret) {
if (force_new_ret || return_ == nullptr) {
std::vector<AnfNodePtr> params({NewValueNode(prim::kPrimReturn), value});
......
......@@ -17,22 +17,9 @@
*/
#include "ir/meta_func_graph.h"
#include "pipeline/jit/static_analysis/static_analysis.h"
#include "pipeline/jit/static_analysis/abstract_function.h"
// namespace to support intermediate representation definition
namespace mindspore {
abstract::AbstractBasePtr MetaFuncGraph::MakeAbstractClosure(const AnfNodePtr &anf_node) {
abstract::MetaFuncGraphAbstractClosurePtr meta_func_graph_fn;
if (anf_node == nullptr) {
meta_func_graph_fn = std::make_shared<abstract::MetaFuncGraphAbstractClosure>(shared_from_base<MetaFuncGraph>());
} else {
meta_func_graph_fn =
std::make_shared<abstract::MetaFuncGraphAbstractClosure>(shared_from_base<MetaFuncGraph>(), anf_node->scope());
}
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),
......
......@@ -44,7 +44,6 @@ class MetaFuncGraph : public FuncGraphBase {
~MetaFuncGraph() override = default;
MS_DECLARE_PARENT(MetaFuncGraph, FuncGraphBase);
abstract::AbstractBasePtr MakeAbstractClosure(const AnfNodePtr &anf_node);
// Return normalized versions of the arguments.
// By default, this returns args unchanged.
virtual abstract::AbstractBasePtrList NormalizeArgs(const abstract::AbstractBasePtrList &args_spec_list) const {
......
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ir/primitive.h"
#include "pipeline/jit/static_analysis/abstract_function.h"
namespace mindspore {
abstract::AbstractBasePtr Primitive::ToPrimAbstract(const AnfNodePtr &anf_node) {
auto prim_func = std::make_shared<abstract::PrimitiveAbstractClosure>(shared_from_base<Primitive>(), anf_node);
return prim_func;
}
} // namespace mindspore
......@@ -52,8 +52,8 @@ else()
endif()
file(GLOB_RECURSE MINDSPORE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"../../../mindspore/ccsrc/base/*.cc"
"../../../mindspore/ccsrc/abstract/*.cc"
"../../../mindspore/core/base/*.cc"
"../../../mindspore/core/abstract/*.cc"
"../../../mindspore/core/ir/*.cc"
"../../../mindspore/ccsrc/common/*.cc"
"../../../mindspore/ccsrc/utils/*.cc"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册