Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2dfcdf21
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
2dfcdf21
编写于
11月 23, 2021
作者:
L
Leo Chen
提交者:
GitHub
11月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[new-exec] skip compiled program with places > 1 (#37457)
* skip compiled program with places > 1 * fix corner case and add ut
上级
33653195
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
45 addition
and
11 deletion
+45
-11
python/paddle/fluid/executor.py
python/paddle/fluid/executor.py
+18
-5
python/paddle/fluid/tests/unittests/interpreter/test_standalone_executor.py
...d/tests/unittests/interpreter/test_standalone_executor.py
+27
-6
未找到文件。
python/paddle/fluid/executor.py
浏览文件 @
2dfcdf21
...
...
@@ -1330,13 +1330,26 @@ class Executor(object):
if
scope
is
None
:
scope
=
global_scope
()
def
_can_use_interpreter_core
(
program
,
place
):
compiled
=
isinstance
(
program
,
compiler
.
CompiledProgram
)
# NOTE(zhiqiu): only single card compiled program is supported
if
compiled
:
if
program
.
_is_data_parallel
and
len
(
program
.
_get_places
(
place
,
program
.
_places
))
==
1
:
return
True
else
:
return
False
else
:
assert
isinstance
(
program
,
Program
)
return
True
# NOTE: This is an experimental feature. If `export FLAGS_USE_STANDALONE_EXECUTOR=1 `,
# use StandaloneExecutor to run the program.
if
self
.
_enable_interpreter_core
:
inner_program_
=
program
.
_program
if
isinstance
(
if
self
.
_enable_interpreter_core
and
_can_use_interpreter_core
(
program
,
self
.
place
):
inner_program
=
program
.
_program
if
isinstance
(
program
,
compiler
.
CompiledProgram
)
else
program
assert
isinstance
(
inner_program_
,
framework
.
Program
)
if
not
inner_program_
.
_is_start_up_program_
:
if
not
inner_program
.
_is_start_up_program_
:
if
feed
is
None
:
feed
=
{}
elif
isinstance
(
feed
,
(
list
,
tuple
)):
...
...
@@ -1348,7 +1361,7 @@ class Executor(object):
%
(
type
(
feed
)))
feed
=
self
.
_update_feed
(
program
,
feed
)
program
=
self
.
_add_feed_fetch_ops
(
program
=
inner_program
_
,
program
=
inner_program
,
feed
=
feed
,
fetch_list
=
fetch_list
,
feed_var_name
=
feed_var_name
,
...
...
python/paddle/fluid/tests/unittests/interpreter/test_standalone_executor.py
浏览文件 @
2dfcdf21
...
...
@@ -195,7 +195,12 @@ class SwitchExecutorInterfaceWithFeed(unittest.TestCase):
return
main_program
,
startup_program
,
[
c
]
def
_run
(
self
,
feed
,
use_str
=
False
,
is_double
=
False
,
add_wrong_fetch
=
False
):
def
_run
(
self
,
feed
,
use_str
=
False
,
is_double
=
False
,
add_wrong_fetch
=
False
,
use_compiled
=
False
):
paddle
.
seed
(
2020
)
main_program
,
startup_program
,
fetch_vars
=
self
.
build_program
(
...
...
@@ -204,6 +209,11 @@ class SwitchExecutorInterfaceWithFeed(unittest.TestCase):
exe
=
paddle
.
static
.
Executor
(
self
.
place
)
exe
.
run
(
startup_program
)
if
use_compiled
:
main_program
=
paddle
.
static
.
CompiledProgram
(
main_program
).
with_data_parallel
(
fetch_vars
[
0
].
name
,
places
=
[
self
.
place
])
if
use_str
:
# test for fetch name
fetch_vars
=
[
x
.
name
for
x
in
fetch_vars
]
if
add_wrong_fetch
:
# test for wrong fetch type
...
...
@@ -216,17 +226,19 @@ class SwitchExecutorInterfaceWithFeed(unittest.TestCase):
return
outs
def
run_raw_executor
(
self
,
feed
):
def
run_raw_executor
(
self
,
feed
,
use_compiled
=
False
):
# run construct program 1
out1
=
self
.
_run
(
feed
,
use_str
=
False
,
is_double
=
False
)
out1
=
self
.
_run
(
feed
,
use_str
=
False
,
is_double
=
False
,
use_compiled
=
use_compiled
)
# run construct program 2 with same executor
out2
=
self
.
_run
(
feed
,
use_str
=
True
,
is_double
=
True
)
out2
=
self
.
_run
(
feed
,
use_str
=
True
,
is_double
=
True
,
use_compiled
=
use_compiled
)
return
[
out1
,
out2
]
def
run_new_executor
(
self
,
feed
):
def
run_new_executor
(
self
,
feed
,
use_compiled
=
False
):
os
.
environ
[
'FLAGS_USE_STANDALONE_EXECUTOR'
]
=
'1'
out
=
self
.
run_raw_executor
(
feed
)
out
=
self
.
run_raw_executor
(
feed
,
use_compiled
=
use_compiled
)
del
os
.
environ
[
'FLAGS_USE_STANDALONE_EXECUTOR'
]
return
out
...
...
@@ -247,6 +259,15 @@ class SwitchExecutorInterfaceWithFeed(unittest.TestCase):
self
.
_run
(
feed
[
0
],
add_wrong_fetch
=
True
)
del
os
.
environ
[
'FLAGS_USE_STANDALONE_EXECUTOR'
]
def
test_compiled_program
(
self
):
data
=
np
.
ones
([
2
,
2
],
dtype
=
"float32"
)
feed
=
{
"a"
:
data
,
'fake_input'
:
data
}
res
=
self
.
run_new_executor
(
feed
,
use_compiled
=
True
)
gt
=
self
.
run_raw_executor
(
feed
,
use_compiled
=
True
)
for
x
,
y
in
zip
(
gt
,
res
):
self
.
assertTrue
(
np
.
array_equal
(
x
,
y
))
class
TestException
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录