Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
f7d08b7d
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f7d08b7d
编写于
9月 09, 2020
作者:
D
Dong Daxiang
提交者:
GitHub
9月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【paddle.fleet】refine launch and distributed repr string for print (#27093)
* refine launch and distributed repr string for print
上级
43b0445b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
102 addition
and
6 deletion
+102
-6
python/paddle/distributed/fleet/base/distributed_strategy.py
python/paddle/distributed/fleet/base/distributed_strategy.py
+87
-2
python/paddle/distributed/fleet/launch_utils.py
python/paddle/distributed/fleet/launch_utils.py
+5
-4
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+2
-0
python/paddle/fluid/tests/unittests/test_fleet_distributed_strategy.py
.../fluid/tests/unittests/test_fleet_distributed_strategy.py
+8
-0
未找到文件。
python/paddle/distributed/fleet/base/distributed_strategy.py
浏览文件 @
f7d08b7d
...
...
@@ -17,6 +17,7 @@ from paddle.distributed.fleet.proto import distributed_strategy_pb2
from
paddle.fluid.framework
import
Variable
,
set_flags
,
core
from
paddle.fluid.wrapped_decorator
import
wrap_decorator
import
google.protobuf.text_format
import
google.protobuf
__all__
=
[
"DistributedStrategy"
]
...
...
@@ -1133,7 +1134,91 @@ class DistributedStrategy(object):
return
False
def
__repr__
(
self
):
spacing
=
2
max_k
=
38
max_v
=
38
length
=
max_k
+
max_v
+
spacing
h1_format
=
" "
+
"|{{:^{}s}}|
\n
"
.
format
(
length
)
h2_format
=
" "
+
"|{{:>{}s}}{}{{:^{}s}}|
\n
"
.
format
(
max_k
,
" "
*
spacing
,
max_v
)
border
=
" +"
+
""
.
join
([
"="
]
*
length
)
+
"+"
line
=
" +"
+
""
.
join
([
"-"
]
*
length
)
+
"+"
draws
=
border
+
"
\n
"
draws
+=
h1_format
.
format
(
""
)
draws
+=
h1_format
.
format
(
"DistributedStrategy Overview"
)
draws
+=
h1_format
.
format
(
""
)
fields
=
self
.
strategy
.
DESCRIPTOR
.
fields
str_res
=
""
env_draws
=
line
+
"
\n
"
for
f
in
fields
:
if
"build_strategy"
in
f
.
name
or
"execution_strategy"
in
f
.
name
:
continue
if
"_configs"
in
f
.
name
:
continue
else
:
if
isinstance
(
getattr
(
self
.
strategy
,
f
.
name
),
bool
):
if
hasattr
(
self
.
strategy
,
f
.
name
+
"_configs"
):
if
getattr
(
self
.
strategy
,
f
.
name
):
draws
+=
border
+
"
\n
"
draws
+=
h1_format
.
format
(
"{} = True, please check {}_configs"
.
format
(
f
.
name
,
f
.
name
))
draws
+=
line
+
"
\n
"
my_configs
=
getattr
(
self
.
strategy
,
f
.
name
+
"_configs"
)
config_fields
=
my_configs
.
DESCRIPTOR
.
fields
for
ff
in
config_fields
:
if
isinstance
(
getattr
(
my_configs
,
ff
.
name
),
google
.
protobuf
.
pyext
.
_message
.
RepeatedScalarContainer
):
values
=
getattr
(
my_configs
,
ff
.
name
)
for
i
,
v
in
enumerate
(
values
):
if
i
==
0
:
draws
+=
h2_format
.
format
(
ff
.
name
,
str
(
v
))
else
:
draws
+=
h2_format
.
format
(
""
,
str
(
v
))
else
:
draws
+=
h2_format
.
format
(
ff
.
name
,
str
(
getattr
(
my_configs
,
ff
.
name
)))
else
:
env_draws
+=
h2_format
.
format
(
f
.
name
,
str
(
getattr
(
self
.
strategy
,
f
.
name
)))
else
:
env_draws
+=
h2_format
.
format
(
f
.
name
,
str
(
getattr
(
self
.
strategy
,
f
.
name
)))
result_res
=
draws
+
border
+
"
\n
"
+
h1_format
.
format
(
"Environment Flags, Communication Flags"
)
result_res
+=
env_draws
build_strategy_str
=
border
+
"
\n
"
build_strategy_str
+=
h1_format
.
format
(
"Build Strategy"
)
build_strategy_str
+=
line
+
"
\n
"
fields
=
self
.
strategy
.
build_strategy
.
DESCRIPTOR
.
fields
for
f
in
fields
:
print
(
"{}: {}"
.
format
(
f
.
name
,
f
.
default_value
))
return
str
(
self
.
strategy
)
build_strategy_str
+=
h2_format
.
format
(
f
.
name
,
str
(
getattr
(
self
.
strategy
.
build_strategy
,
f
.
name
)))
build_strategy_str
+=
border
+
"
\n
"
execution_strategy_str
=
h1_format
.
format
(
"Execution Strategy"
)
execution_strategy_str
+=
line
+
"
\n
"
fields
=
self
.
strategy
.
execution_strategy
.
DESCRIPTOR
.
fields
for
f
in
fields
:
execution_strategy_str
+=
h2_format
.
format
(
f
.
name
,
str
(
getattr
(
self
.
strategy
.
execution_strategy
,
f
.
name
)))
execution_strategy_str
+=
border
+
"
\n
"
result_res
+=
build_strategy_str
+
execution_strategy_str
return
result_res
python/paddle/distributed/fleet/launch_utils.py
浏览文件 @
f7d08b7d
...
...
@@ -347,12 +347,13 @@ def pretty_print_envs(envs, header=None):
for
k
,
v
in
envs
.
items
():
max_k
=
max
(
max_k
,
len
(
k
))
h_format
=
"{{:^{}s}}{}{{:<{}s}}
\n
"
.
format
(
max_k
,
" "
*
spacing
,
max_v
)
l_format
=
"{{:<{}s}}{{}}{{:<{}s}}
\n
"
.
format
(
max_k
,
max_v
)
h_format
=
" "
+
"|{{:>{}s}}{}{{:^{}s}}|
\n
"
.
format
(
max_k
,
" "
*
spacing
,
max_v
)
l_format
=
" "
+
"|{{:>{}s}}{{}}{{:^{}s}}|
\n
"
.
format
(
max_k
,
max_v
)
length
=
max_k
+
max_v
+
spacing
border
=
"
"
.
join
([
"="
]
*
length
)
line
=
"
"
.
join
([
"-"
]
*
length
)
border
=
"
+"
+
""
.
join
([
"="
]
*
length
)
+
"+"
line
=
"
+"
+
""
.
join
([
"-"
]
*
length
)
+
"+"
draws
=
""
draws
+=
border
+
"
\n
"
...
...
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
f7d08b7d
...
...
@@ -47,6 +47,7 @@ list(APPEND MIXED_DIST_TEST_OPS test_fleet_dgc_meta_optimizer)
list
(
APPEND MIXED_DIST_TEST_OPS test_fleet_private_function
)
list
(
APPEND MIXED_DIST_TEST_OPS test_fleet_graph_executor
)
list
(
APPEND MIXED_DIST_TEST_OPS test_fleet_meta_optimizer_base
)
list
(
APPEND MIXED_DIST_TEST_OPS test_fleet_distributed_strategy
)
list
(
APPEND MIXED_DIST_TEST_OPS test_fleet_auto
)
foreach
(
TEST_OP
${
MIXED_DIST_TEST_OPS
}
)
list
(
REMOVE_ITEM TEST_OPS
${
TEST_OP
}
)
...
...
@@ -461,6 +462,7 @@ if(WITH_DISTRIBUTE)
py_test_modules
(
test_fleet_pipeline_meta_optimizer MODULES test_fleet_pipeline_meta_optimizer ENVS
${
dist_ENVS
}
)
py_test_modules
(
test_fleet_private_function MODULES test_fleet_private_function ENVS
${
dist_ENVS
}
)
py_test_modules
(
test_fleet_meta_optimizer_base MODULES test_fleet_meta_optimizer_base ENVS
${
dist_ENVS
}
)
py_test_modules
(
test_fleet_distributed_strategy MODULES test_fleet_distributed_strategy
)
py_test_modules
(
test_fleet_auto MODULES test_fleet_auto ENVS
${
dist_ENVS
}
)
if
(
NOT WIN32
)
py_test_modules
(
test_fleet_localsgd_meta_optimizer MODULES test_fleet_localsgd_meta_optimizer ENVS
${
dist_ENVS
}
)
...
...
python/paddle/fluid/tests/unittests/test_fleet_distributed_strategy.py
浏览文件 @
f7d08b7d
...
...
@@ -316,6 +316,14 @@ class TestStrategyConfig(unittest.TestCase):
self
.
assertEqual
(
strategy
.
conv_workspace_size_limit
,
1000
)
strategy
.
_enable_env
()
def
test_distributed_strategy_repr
(
self
):
strategy
=
paddle
.
distributed
.
fleet
.
DistributedStrategy
()
strategy
.
recompute
=
True
strategy
.
recompute_configs
=
{
"checkpoints"
:
[
"a1"
,
"a2"
,
"a3"
]}
strategy
.
amp
=
True
strategy
.
localsgd
=
True
print
(
str
(
strategy
))
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录