Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d74bfefe
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d74bfefe
编写于
9月 02, 2023
作者:
L
Leo Chen
提交者:
GitHub
9月 02, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish code of pass and executor (#56886)
* polish code of pass and executor * update ut
上级
061bb9d5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
40 deletion
+41
-40
paddle/fluid/framework/new_executor/program_interpreter.cc
paddle/fluid/framework/new_executor/program_interpreter.cc
+38
-36
paddle/fluid/pybind/ir.cc
paddle/fluid/pybind/ir.cc
+1
-1
paddle/ir/transforms/dead_code_elimination_pass.cc
paddle/ir/transforms/dead_code_elimination_pass.cc
+1
-1
test/ir/new_ir/test_pass_manager.py
test/ir/new_ir/test_pass_manager.py
+1
-2
未找到文件。
paddle/fluid/framework/new_executor/program_interpreter.cc
浏览文件 @
d74bfefe
...
...
@@ -123,9 +123,8 @@ void ProgramInterpreter::RunImpl() {
#endif
}
FetchList
ProgramInterpreter
::
Run
(
const
std
::
vector
<
std
::
string
>&
feed_names
,
const
std
::
vector
<
phi
::
DenseTensor
>&
feed_tensors
)
{
FetchList
ProgramInterpreter
::
Run
(
const
std
::
vector
<
std
::
string
>&
feed_names
,
bool
need_fetch
)
{
SetDeviceId
(
place_
);
CheckCUDAGraphBeforeRun
(
feed_names
);
...
...
@@ -133,10 +132,32 @@ FetchList ProgramInterpreter::Run(
platform
::
AttachPointerHashToMKLDNNKey
(
this
,
place_
);
#endif
bool
is_build
=
is_build_
;
Prepare
(
feed_names
,
feed_tensors
,
is_build
);
if
(
!
is_build_
)
{
LOG_FIRST_N
(
INFO
,
1
)
<<
"New Executor is Running."
;
paddle
::
framework
::
interpreter
::
BuildVariableScope
(
block_
,
execution_config_
,
&
var_scope_
);
if
(
is_build
)
{
std
::
vector
<
paddle
::
framework
::
OpFuncNode
>
op_func_nodes
;
paddle
::
framework
::
interpreter
::
BuildOpFuncList
(
place_
,
block_
,
execution_config_
.
skip_gc_vars
,
&
op_func_nodes
,
&
var_scope_
,
execution_config_
,
HasLocalScope
(),
static_build_
);
SetFeedVarsInplaceSkip
(
feed_names
);
// convert vec func_list to graph
Convert
(
&
op_func_nodes
);
UpdateSyncOpNum
();
if
(
static_build_
)
{
VLOG
(
4
)
<<
"RUN impl"
;
RunImpl
();
}
is_build_
=
true
;
is_shared_results_build_
=
true
;
}
else
{
RunImpl
();
}
...
...
@@ -145,8 +166,10 @@ FetchList ProgramInterpreter::Run(
}
// return Fetch Tensors
auto
*
fetch_var
=
local_scope_
->
FindVar
(
interpreter
::
kFetchVarName
);
if
(
fetch_var
)
{
Scope
*
inner_scope
=
HasLocalScope
()
?
local_scope_
:
var_scope_
.
GetMutableScope
();
auto
*
fetch_var
=
inner_scope
->
FindVar
(
interpreter
::
kFetchVarName
);
if
(
fetch_var
&&
need_fetch
)
{
auto
fetch_list
=
std
::
move
(
*
fetch_var
->
GetMutable
<
framework
::
FetchList
>
());
#ifdef PADDLE_WITH_CUDA
if
(
platform
::
IsCUDAGraphCapturing
())
{
...
...
@@ -162,8 +185,9 @@ FetchList ProgramInterpreter::Run(
}
}
FetchList
ProgramInterpreter
::
Run
(
const
std
::
vector
<
std
::
string
>&
feed_names
,
bool
need_fetch
)
{
FetchList
ProgramInterpreter
::
Run
(
const
std
::
vector
<
std
::
string
>&
feed_names
,
const
std
::
vector
<
phi
::
DenseTensor
>&
feed_tensors
)
{
SetDeviceId
(
place_
);
CheckCUDAGraphBeforeRun
(
feed_names
);
...
...
@@ -171,32 +195,10 @@ FetchList ProgramInterpreter::Run(const std::vector<std::string>& feed_names,
platform
::
AttachPointerHashToMKLDNNKey
(
this
,
place_
);
#endif
if
(
!
is_build_
)
{
LOG_FIRST_N
(
INFO
,
1
)
<<
"New Executor is Running."
;
paddle
::
framework
::
interpreter
::
BuildVariableScope
(
block_
,
execution_config_
,
&
var_scope_
);
bool
is_build
=
is_build_
;
Prepare
(
feed_names
,
feed_tensors
,
is_build
);
std
::
vector
<
paddle
::
framework
::
OpFuncNode
>
op_func_nodes
;
paddle
::
framework
::
interpreter
::
BuildOpFuncList
(
place_
,
block_
,
execution_config_
.
skip_gc_vars
,
&
op_func_nodes
,
&
var_scope_
,
execution_config_
,
HasLocalScope
(),
static_build_
);
SetFeedVarsInplaceSkip
(
feed_names
);
// convert vec func_list to graph
Convert
(
&
op_func_nodes
);
UpdateSyncOpNum
();
if
(
static_build_
)
{
VLOG
(
4
)
<<
"RUN impl"
;
RunImpl
();
}
is_build_
=
true
;
is_shared_results_build_
=
true
;
}
else
{
if
(
is_build
)
{
RunImpl
();
}
...
...
@@ -208,7 +210,7 @@ FetchList ProgramInterpreter::Run(const std::vector<std::string>& feed_names,
Scope
*
inner_scope
=
HasLocalScope
()
?
local_scope_
:
var_scope_
.
GetMutableScope
();
auto
*
fetch_var
=
inner_scope
->
FindVar
(
interpreter
::
kFetchVarName
);
if
(
fetch_var
&&
need_fetch
)
{
if
(
fetch_var
)
{
auto
fetch_list
=
std
::
move
(
*
fetch_var
->
GetMutable
<
framework
::
FetchList
>
());
#ifdef PADDLE_WITH_CUDA
if
(
platform
::
IsCUDAGraphCapturing
())
{
...
...
paddle/fluid/pybind/ir.cc
浏览文件 @
d74bfefe
...
...
@@ -507,7 +507,7 @@ void BindPassManager(pybind11::module *m) {
},
py
::
arg
(
"opt_level"
)
=
2
)
.
def
(
"add_pass"
,
[](
PassManager
&
self
,
std
::
string
pass_name
)
{
[](
PassManager
&
self
,
const
std
::
string
&
pass_name
)
{
self
.
AddPass
(
std
::
move
(
ir
::
PassRegistry
::
Instance
().
Get
(
pass_name
)));
})
...
...
paddle/ir/transforms/dead_code_elimination_pass.cc
浏览文件 @
d74bfefe
...
...
@@ -26,7 +26,7 @@ namespace {
// Now just a naive implementation.
class
DeadCodeEliminationPass
:
public
ir
::
Pass
{
public:
DeadCodeEliminationPass
()
:
ir
::
Pass
(
"
DeadCodeEliminationPass
"
,
0
)
{}
DeadCodeEliminationPass
()
:
ir
::
Pass
(
"
dead_code_elimination
"
,
0
)
{}
void
Run
(
ir
::
Operation
*
op
)
override
{
auto
module_op
=
op
->
dyn_cast
<
ir
::
ModuleOp
>
();
...
...
test/ir/new_ir/test_pass_manager.py
浏览文件 @
d74bfefe
...
...
@@ -56,8 +56,7 @@ class TestShadowOutputSlice(unittest.TestCase):
pm
.
run
(
new_program
)
op_names
=
[
op
.
name
()
for
op
in
new_program
.
block
().
ops
]
# print(op_names)
# TODO(zhiqiu): unify the name of pass
self
.
assertEqual
(
pm
.
passes
(),
[
'DeadCodeEliminationPass'
])
self
.
assertEqual
(
pm
.
passes
(),
[
'dead_code_elimination'
])
self
.
assertFalse
(
pm
.
empty
())
self
.
assertTrue
(
'pd.uniform'
not
in
op_names
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录