Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
csdn_franckjun
Paddle
提交
c50ebeac
P
Paddle
项目概览
csdn_franckjun
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c50ebeac
编写于
12月 19, 2019
作者:
L
Leo Chen
提交者:
Tao Luo
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add comments of inplace_atol (#21819)
上级
8b7c50f4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
7 deletion
+25
-7
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+13
-2
python/paddle/fluid/tests/unittests/test_group_norm_op.py
python/paddle/fluid/tests/unittests/test_group_norm_op.py
+12
-5
未找到文件。
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
c50ebeac
...
...
@@ -520,6 +520,10 @@ class OpTest(unittest.TestCase):
"""
# compare expect_outs and actual_outs
for
i
,
name
in
enumerate
(
fetch_list
):
# Note(zhiqiu): inplace_atol should be only set when op doesn't ensure
# computational consistency.
# When inplace_atol is not None, the inplace check uses numpy.allclose
# to check inplace result instead of numpy.array_equal.
if
inplace_atol
is
not
None
:
self
.
assertTrue
(
np
.
allclose
(
...
...
@@ -971,10 +975,17 @@ class OpTest(unittest.TestCase):
"Output ("
+
out_name
+
") has different lod at "
+
str
(
place
)
+
" in dygraph mode"
)
# inplace_atol only used when op doesn't ensure computational consistency
# Note(zhiqiu): inplace_atol should be only set when op doesn't ensure
# computational consistency.
# For example, group_norm uses AtomicAdd on CUDAPlace, which do not ensure
# computation order when multiple threads write the same address. So the
# result of group_norm is non-deterministic when datatype is float.
# When inplace_atol is not None, the inplace check uses numpy.allclose
# to check inplace result instead of numpy.array_equal.
if
inplace_atol
is
not
None
:
warnings
.
warn
(
"By default, inplace_atol should not be set, please check it"
)
"inplace_atol should only be set when op doesn't ensure computational consistency, please check it!"
)
# Check inplace for given op, its grad op, its grad_grad op, etc.
# No effect on original OpTest
self
.
check_inplace_output_with_place
(
...
...
python/paddle/fluid/tests/unittests/test_group_norm_op.py
浏览文件 @
c50ebeac
...
...
@@ -68,15 +68,22 @@ class TestGroupNormOp(OpTest):
self
.
attrs
[
'data_layout'
]
=
self
.
data_format
def
test_check_output
(
self
):
atol
=
1e-4
inplace_atol
=
1e-4
atol
=
0.0
inplace_atol
=
0.0
place
=
core
.
CPUPlace
()
# add inplace_atol bacause group_norm doesn't ensure computational consistency
self
.
check_output_with_place
(
place
,
atol
=
atol
,
inplace_atol
=
inplace_atol
)
self
.
check_output_with_place
(
place
,
atol
=
atol
)
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
# group_norm uses AtomicAdd on CUDAPlace, which do not ensure
# computation order when multiple threads write the same address. So the
# result of group_norm is non-deterministic when datatype is float.
# When inplace_atol is not None, the inplace check uses numpy.allclose
# to check inplace result instead of numpy.array_equal.
# Set to inplace_atol to 0, which means the absolute error is 0, and the
# relative error is 1e-05 in numpy.allclose by default.
# Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.allclose.html
self
.
check_output_with_place
(
place
,
atol
=
atol
,
inplace_atol
=
inplace_atol
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录