Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
174acbec
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
174acbec
编写于
7月 22, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
7月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
!3265 Decouple ir from optimizer
Merge pull request !3265 from hewei/decouple_ir_optimizer
上级
cd9dd380
60d168ad
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
90 addition
and
64 deletion
+90
-64
mindspore/ccsrc/frontend/optimizer/anf_visitor.h
mindspore/ccsrc/frontend/optimizer/anf_visitor.h
+27
-0
mindspore/ccsrc/frontend/optimizer/irpass.h
mindspore/ccsrc/frontend/optimizer/irpass.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h
...ore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h
mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.cc
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.cc
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.h
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/convert.h
mindspore/ccsrc/frontend/optimizer/irpass/convert.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/env_item_eliminate.h
...pore/ccsrc/frontend/optimizer/irpass/env_item_eliminate.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.cc
...spore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.cc
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.h
mindspore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/gradient_eliminate.h
...pore/ccsrc/frontend/optimizer/irpass/gradient_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h
mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h
...ore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/indexed_slices_eliminate.h
...csrc/frontend/optimizer/irpass/indexed_slices_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/inline.h
mindspore/ccsrc/frontend/optimizer/irpass/inline.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/item_tuple_eliminate.h
...re/ccsrc/frontend/optimizer/irpass/item_tuple_eliminate.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h
...e/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/merge_addn.h
mindspore/ccsrc/frontend/optimizer/irpass/merge_addn.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/minmax_grad.h
mindspore/ccsrc/frontend/optimizer/irpass/minmax_grad.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/param_replace.h
mindspore/ccsrc/frontend/optimizer/irpass/param_replace.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h
...spore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/prim_eliminate.h
mindspore/ccsrc/frontend/optimizer/irpass/prim_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h
mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/reshape_eliminate.h
...spore/ccsrc/frontend/optimizer/irpass/reshape_eliminate.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h
...re/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h
+2
-2
mindspore/ccsrc/frontend/optimizer/irpass/specialize_transform.h
...re/ccsrc/frontend/optimizer/irpass/specialize_transform.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h
mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/tile_eliminate.h
mindspore/ccsrc/frontend/optimizer/irpass/tile_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/irpass/transpose_eliminate.h
...ore/ccsrc/frontend/optimizer/irpass/transpose_eliminate.h
+1
-1
mindspore/ccsrc/frontend/optimizer/opt.h
mindspore/ccsrc/frontend/optimizer/opt.h
+1
-1
mindspore/ccsrc/frontend/optimizer/optimizer_caller.h
mindspore/ccsrc/frontend/optimizer/optimizer_caller.h
+5
-5
mindspore/ccsrc/utils/graph_utils_extends.cc
mindspore/ccsrc/utils/graph_utils_extends.cc
+2
-2
mindspore/core/ir/anf.h
mindspore/core/ir/anf.h
+5
-5
mindspore/core/ir/anf_extends.cc
mindspore/core/ir/anf_extends.cc
+3
-3
mindspore/core/ir/pattern_matcher.h
mindspore/core/ir/pattern_matcher.h
+2
-3
mindspore/core/ir/visitor.cc
mindspore/core/ir/visitor.cc
+5
-5
mindspore/core/ir/visitor.h
mindspore/core/ir/visitor.h
+5
-4
tests/ut/cpp/optimizer/lib_test.cc
tests/ut/cpp/optimizer/lib_test.cc
+0
-1
tests/ut/cpp/optimizer/opt_test.cc
tests/ut/cpp/optimizer/opt_test.cc
+1
-1
未找到文件。
mindspore/ccsrc/frontend/optimizer/anf_visitor.h
0 → 100644
浏览文件 @
174acbec
/**
* 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.
*/
#ifndef MINDSPORE_CCSRC_OPTIMIZER_ANF_VISITOR_H_
#define MINDSPORE_CCSRC_OPTIMIZER_ANF_VISITOR_H_
#include <vector>
#include "ir/visitor.h"
#include "frontend/optimizer/optimizer_caller.h"
namespace
mindspore
{
class
AnfVisitor
:
public
AnfIrVisitor
,
public
OptimizerCaller
{};
}
// namespace mindspore
#endif // MINDSPORE_CCSRC_OPTIMIZER_ANF_VISITOR_H_
mindspore/ccsrc/frontend/optimizer/irpass.h
浏览文件 @
174acbec
...
...
@@ -21,7 +21,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/opt.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
namespace
mindspore
{
namespace
opt
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/arithmetic_simplify.h
浏览文件 @
174acbec
...
...
@@ -23,9 +23,9 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/irpass/prim_eliminate.h"
#include "ir/optimizer_caller.h"
#include "frontend/optimizer/optimizer_caller.h"
#include "frontend/optimizer/anf_visitor.h"
#include "ir/pattern_matcher.h"
#include "ir/visitor.h"
namespace
mindspore
{
namespace
opt
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/branch_culling.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
#include "
i
r/optimizer_caller.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "ir/pattern_matcher.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.cc
浏览文件 @
174acbec
...
...
@@ -17,7 +17,7 @@
#include "frontend/optimizer/irpass/cast_eliminate.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "ir/func_graph.h"
#include "pipeline/jit/parse/data_converter.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/cast_eliminate.h
浏览文件 @
174acbec
...
...
@@ -17,7 +17,7 @@
#ifndef MINDSPORE_CCSRC_FRONTEND_OPTIMIZER_IRPASS_CAST_ELIMINATE_H_
#define MINDSPORE_CCSRC_FRONTEND_OPTIMIZER_IRPASS_CAST_ELIMINATE_H_
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/convert.h
浏览文件 @
174acbec
...
...
@@ -21,7 +21,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/func_graph.h"
#include "frontend/operator/ops.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/env_item_eliminate.h
浏览文件 @
174acbec
...
...
@@ -25,8 +25,8 @@
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
#include "
i
r/optimizer_caller.h"
#include "
ir/
visitor.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.cc
浏览文件 @
174acbec
...
...
@@ -24,7 +24,7 @@
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/grad_var_prepare.h
浏览文件 @
174acbec
...
...
@@ -26,7 +26,7 @@
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/gradient_eliminate.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "common/utils.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/ad/grad.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/incorporate_call.h
浏览文件 @
174acbec
...
...
@@ -24,7 +24,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
#include "frontend/operator/ops.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/incorporate_getitem.h
浏览文件 @
174acbec
...
...
@@ -25,8 +25,8 @@
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
#include "
i
r/optimizer_caller.h"
#include "
ir/
visitor.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/indexed_slices_eliminate.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/inline.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
#include "frontend/operator/ops.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/item_tuple_eliminate.h
浏览文件 @
174acbec
...
...
@@ -21,8 +21,8 @@
#include <memory>
#include <vector>
#include "
i
r/optimizer_caller.h"
#include "
ir/
visitor.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/mark_interface_fusion.h
浏览文件 @
174acbec
...
...
@@ -24,7 +24,7 @@
#include "backend/session/anf_runtime_algorithm.h"
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "utils/graph_utils.h"
#include "frontend/operator/composite/composite.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/merge_addn.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/minmax_grad.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/param_replace.h
浏览文件 @
174acbec
...
...
@@ -21,7 +21,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "pipeline/jit/parse/parse.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/partial_eliminate.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/prim_eliminate.h
浏览文件 @
174acbec
...
...
@@ -19,7 +19,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
namespace
mindspore
{
namespace
opt
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/reduce_eliminate.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "abstract/dshape.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/reshape_eliminate.h
浏览文件 @
174acbec
...
...
@@ -20,8 +20,8 @@
#include <vector>
#include "ir/func_graph.h"
#include "
i
r/optimizer_caller.h"
#include "
ir/
visitor.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/special_op_eliminate.h
浏览文件 @
174acbec
...
...
@@ -22,9 +22,9 @@
#include <memory>
#include <vector>
#include "
i
r/optimizer_caller.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "ir/pattern_matcher.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/irpass/prim_eliminate.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/specialize_transform.h
浏览文件 @
174acbec
...
...
@@ -26,7 +26,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "ir/manager.h"
#include "ir/func_graph.h"
#include "ir/func_graph_cloner.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/symbol_resolver.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/irpass.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
#include "pipeline/jit/parse/data_converter.h"
#include "pipeline/jit/parse/python_adapter.h"
...
...
mindspore/ccsrc/frontend/optimizer/irpass/tile_eliminate.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/irpass/transpose_eliminate.h
浏览文件 @
174acbec
...
...
@@ -22,7 +22,7 @@
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/optimizer.h"
#include "
ir/
visitor.h"
#include "
frontend/optimizer/anf_
visitor.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/ccsrc/frontend/optimizer/opt.h
浏览文件 @
174acbec
...
...
@@ -23,7 +23,7 @@
#include "ir/anf.h"
#include "ir/func_graph.h"
#include "
i
r/optimizer_caller.h"
#include "
frontend/optimize
r/optimizer_caller.h"
#include "frontend/operator/ops.h"
namespace
mindspore
{
...
...
mindspore/c
ore/i
r/optimizer_caller.h
→
mindspore/c
csrc/frontend/optimize
r/optimizer_caller.h
浏览文件 @
174acbec
...
...
@@ -14,20 +14,20 @@
* limitations under the License.
*/
#ifndef MINDSPORE_C
ORE_I
R_OPTIMIZER_CALLER_H_
#define MINDSPORE_C
ORE_I
R_OPTIMIZER_CALLER_H_
#ifndef MINDSPORE_C
CSRC_OPTIMIZE
R_OPTIMIZER_CALLER_H_
#define MINDSPORE_C
CSRC_OPTIMIZE
R_OPTIMIZER_CALLER_H_
#include <memory>
#include "ir/anf.h"
#include "ir/visitor.h"
namespace
mindspore
{
namespace
opt
{
class
Optimizer
;
using
OptimizerPtr
=
std
::
shared_ptr
<
Optimizer
>
;
using
OptimizerWeakPtr
=
std
::
weak_ptr
<
Optimizer
>
;
using
PredicateFuncType
=
std
::
function
<
bool
(
const
AnfNodePtr
&
)
>
;
using
PredicateFuncType
=
mindspore
::
PredicateFuncType
;
}
// namespace opt
class
OptimizerCaller
{
...
...
@@ -36,4 +36,4 @@ class OptimizerCaller {
};
using
OptimizerCallerPtr
=
std
::
shared_ptr
<
OptimizerCaller
>
;
}
// namespace mindspore
#endif // MINDSPORE_C
ORE_I
R_OPTIMIZER_CALLER_H_
#endif // MINDSPORE_C
CSRC_OPTIMIZE
R_OPTIMIZER_CALLER_H_
mindspore/ccsrc/utils/graph_utils_extends.cc
浏览文件 @
174acbec
...
...
@@ -36,7 +36,7 @@
namespace
mindspore
{
namespace
{
class
DeepFirstSearcher
:
public
AnfVisitor
{
class
DeepFirstSearcher
:
public
Anf
Ir
Visitor
{
public:
explicit
DeepFirstSearcher
(
const
IncludeFunc
&
include
,
const
FilterFunc
&
filter
=
nullptr
)
:
include_
(
include
),
filter_
(
filter
)
{}
...
...
@@ -67,7 +67,7 @@ class DeepFirstSearcher : public AnfVisitor {
res_
.
push_back
(
node
);
}
if
(
incl
==
FOLLOW
)
{
AnfVisitor
::
Visit
(
node
);
Anf
Ir
Visitor
::
Visit
(
node
);
}
}
...
...
mindspore/core/ir/anf.h
浏览文件 @
174acbec
...
...
@@ -67,7 +67,7 @@ class BaseRef;
class
Var
;
using
VarPtr
=
std
::
shared_ptr
<
Var
>
;
class
AnfVisitor
;
class
Anf
Ir
Visitor
;
class
ParamValue
;
using
ParamValuePtr
=
std
::
shared_ptr
<
ParamValue
>
;
...
...
@@ -100,7 +100,7 @@ class AnfNode : public Base {
~
AnfNode
()
override
=
default
;
MS_DECLARE_PARENT
(
AnfNode
,
Base
);
virtual
void
accept
(
AnfVisitor
*
)
{}
virtual
void
accept
(
Anf
Ir
Visitor
*
)
{}
FuncGraphPtr
func_graph
()
const
{
return
func_graph_
.
lock
();
}
void
set_func_graph
(
const
FuncGraphPtr
&
func_graph
)
{
func_graph_
=
FuncGraphWeakPtr
(
func_graph
);
}
...
...
@@ -214,7 +214,7 @@ class CNode : public AnfNode {
~
CNode
()
override
=
default
;
MS_DECLARE_PARENT
(
CNode
,
AnfNode
);
void
accept
(
AnfVisitor
*
v
)
override
;
void
accept
(
Anf
Ir
Visitor
*
v
)
override
;
// check whether this cnode has some primitive value as the first input.
bool
IsApply
(
const
PrimitivePtr
&
)
const
;
...
...
@@ -265,7 +265,7 @@ class Parameter : public ANode {
~
Parameter
()
override
=
default
;
MS_DECLARE_PARENT
(
Parameter
,
ANode
);
void
accept
(
AnfVisitor
*
v
)
override
;
void
accept
(
Anf
Ir
Visitor
*
v
)
override
;
std
::
string
DebugString
(
int
recursive_level
=
1
)
const
override
;
std
::
string
name
()
const
{
return
name_
;
}
void
set_name
(
const
std
::
string
&
name
)
{
name_
=
name
;
}
...
...
@@ -332,7 +332,7 @@ class ValueNode : public ANode {
~
ValueNode
()
override
=
default
;
MS_DECLARE_PARENT
(
ValueNode
,
ANode
);
void
accept
(
AnfVisitor
*
v
)
override
;
void
accept
(
Anf
Ir
Visitor
*
v
)
override
;
const
ValuePtr
&
value
()
const
{
return
value_
;
}
std
::
string
fullname_with_scope
()
override
;
...
...
mindspore/core/ir/anf_extends.cc
浏览文件 @
174acbec
...
...
@@ -93,7 +93,7 @@ std::string CNode::fullname_with_scope() {
return
fullname_with_scope_
;
}
void
CNode
::
accept
(
AnfVisitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
CNode
>
());
}
void
ValueNode
::
accept
(
AnfVisitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
ValueNode
>
());
}
void
Parameter
::
accept
(
AnfVisitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
Parameter
>
());
}
void
CNode
::
accept
(
Anf
Ir
Visitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
CNode
>
());
}
void
ValueNode
::
accept
(
Anf
Ir
Visitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
ValueNode
>
());
}
void
Parameter
::
accept
(
Anf
Ir
Visitor
*
v
)
{
v
->
Visit
(
shared_from_base
<
Parameter
>
());
}
}
// namespace mindspore
mindspore/core/ir/pattern_matcher.h
浏览文件 @
174acbec
...
...
@@ -22,8 +22,7 @@
#include <tuple>
#include <vector>
#include "ir/anf.h"
#include "ir/optimizer_caller.h"
#include "ir/visitor.h"
#include "base/core_ops.h"
namespace
mindspore
{
...
...
@@ -41,7 +40,7 @@ namespace mindspore {
template
<
typename
T
>
class
PBase
{
public:
bool
CheckFunc
(
const
opt
::
PredicateFuncType
&
func
,
const
AnfNodePtr
&
node
)
{
bool
CheckFunc
(
const
PredicateFuncType
&
func
,
const
AnfNodePtr
&
node
)
{
return
func
(
get_object
().
GetNode
(
node
));
}
...
...
mindspore/core/ir/visitor.cc
浏览文件 @
174acbec
...
...
@@ -18,24 +18,24 @@
#include "ir/visitor.h"
namespace
mindspore
{
void
AnfVisitor
::
Visit
(
const
AnfNodePtr
&
node
)
{
node
->
accept
(
this
);
}
void
Anf
Ir
Visitor
::
Visit
(
const
AnfNodePtr
&
node
)
{
node
->
accept
(
this
);
}
void
AnfVisitor
::
Visit
(
const
CNodePtr
&
cnode
)
{
void
Anf
Ir
Visitor
::
Visit
(
const
CNodePtr
&
cnode
)
{
for
(
auto
&
input
:
cnode
->
inputs
())
{
Visit
(
input
);
}
}
void
AnfVisitor
::
Visit
(
const
ValueNodePtr
&
vnode
)
{
void
Anf
Ir
Visitor
::
Visit
(
const
ValueNodePtr
&
vnode
)
{
if
(
IsValueNode
<
FuncGraph
>
(
vnode
))
{
auto
func_graph
=
GetValueNode
<
FuncGraphPtr
>
(
vnode
);
Visit
(
func_graph
->
output
());
}
}
void
AnfVisitor
::
Visit
(
const
ParameterPtr
&
)
{}
void
Anf
Ir
Visitor
::
Visit
(
const
ParameterPtr
&
)
{}
VisitFuncType
Anf
Visitor
::
Match
(
const
PrimitivePtr
&
prim
,
const
std
::
vector
<
opt
::
PredicateFuncType
>
&
funcs
)
{
VisitFuncType
Anf
IrVisitor
::
Match
(
const
PrimitivePtr
&
prim
,
const
std
::
vector
<
PredicateFuncType
>
&
funcs
)
{
auto
fn
=
[
prim
,
funcs
,
this
](
const
AnfNodePtr
&
node
)
{
if
(
!
IsPrimitiveCNode
(
node
,
prim
))
{
return
;
...
...
mindspore/core/ir/visitor.h
浏览文件 @
174acbec
...
...
@@ -18,18 +18,19 @@
#define MINDSPORE_CORE_IR_VISITOR_H_
#include <vector>
#include "ir/
optimizer_caller
.h"
#include "ir/
anf
.h"
namespace
mindspore
{
using
VisitFuncType
=
std
::
function
<
void
(
const
AnfNodePtr
&
)
>
;
class
AnfVisitor
:
public
OptimizerCaller
{
using
PredicateFuncType
=
std
::
function
<
bool
(
const
AnfNodePtr
&
)
>
;
class
AnfIrVisitor
{
public:
virtual
void
Visit
(
const
AnfNodePtr
&
);
virtual
void
Visit
(
const
CNodePtr
&
);
virtual
void
Visit
(
const
ValueNodePtr
&
);
virtual
void
Visit
(
const
ParameterPtr
&
);
VisitFuncType
Match
(
const
PrimitivePtr
&
,
const
std
::
vector
<
opt
::
PredicateFuncType
>
&
=
{});
virtual
~
AnfVisitor
()
=
default
;
VisitFuncType
Match
(
const
PrimitivePtr
&
,
const
std
::
vector
<
PredicateFuncType
>
&
=
{});
virtual
~
Anf
Ir
Visitor
()
=
default
;
};
}
// namespace mindspore
#endif // MINDSPORE_CORE_IR_VISITOR_H_
tests/ut/cpp/optimizer/lib_test.cc
浏览文件 @
174acbec
...
...
@@ -24,7 +24,6 @@
#include "ir/func_graph_cloner.h"
#include "ir/manager.h"
#include "ir/value.h"
#include "ir/visitor.h"
#include "frontend/operator/ops.h"
#include "frontend/optimizer/irpass.h"
#include "pipeline/jit/resource.h"
...
...
tests/ut/cpp/optimizer/opt_test.cc
浏览文件 @
174acbec
...
...
@@ -20,9 +20,9 @@
#include "common/py_func_graph_fetcher.h"
#include "ir/anf.h"
#include "ir/visitor.h"
#include "ir/func_graph_cloner.h"
#include "frontend/optimizer/opt.h"
#include "frontend/optimizer/anf_visitor.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/irpass/arithmetic_simplify.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录