Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
145a6cbb
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
145a6cbb
编写于
3月 14, 2023
作者:
V
Vvsmile
提交者:
GitHub
3月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjust tolerance without modify grad (#51459)
上级
117df481
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
61 addition
and
16 deletion
+61
-16
python/paddle/fluid/tests/unittests/eager_op_test.py
python/paddle/fluid/tests/unittests/eager_op_test.py
+13
-5
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+11
-6
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_div_op.py
+29
-0
python/paddle/fluid/tests/unittests/test_reduce_op.py
python/paddle/fluid/tests/unittests/test_reduce_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_scale_op.py
python/paddle/fluid/tests/unittests/test_scale_op.py
+6
-1
python/paddle/fluid/tests/unittests/test_sum_op.py
python/paddle/fluid/tests/unittests/test_sum_op.py
+1
-3
未找到文件。
python/paddle/fluid/tests/unittests/eager_op_test.py
浏览文件 @
145a6cbb
...
...
@@ -1717,11 +1717,14 @@ class OpTest(unittest.TestCase):
if
hasattr
(
self
,
'force_fp32_output'
)
and
getattr
(
self
,
'force_fp32_output'
):
atol
=
1e-2
atol
=
1e-2
if
atol
<
1e-2
else
atol
else
:
atol
=
2
atol
=
2
if
atol
<
2
else
atol
else
:
atol
=
1e-1
atol
=
1e-1
if
atol
<
1e-1
else
atol
if
self
.
is_float16_op
():
atol
=
1e-3
if
atol
<
1e-3
else
atol
if
no_check_set
is
not
None
:
if
(
...
...
@@ -2171,7 +2174,7 @@ class OpTest(unittest.TestCase):
if
grad
.
dtype
==
np
.
uint16
:
grad
=
convert_uint16_to_float
(
grad
)
max_relative_error
=
(
0.0
4
if
max_relative_error
<
0.04
else
max_relative_error
0.0
1
if
max_relative_error
<
0.01
else
max_relative_error
)
fp32_analytic_grads
.
append
(
grad
)
analytic_grads
=
fp32_analytic_grads
...
...
@@ -2181,11 +2184,16 @@ class OpTest(unittest.TestCase):
if
grad
.
dtype
==
np
.
uint16
:
grad
=
convert_uint16_to_float
(
grad
)
max_relative_error
=
(
0.0
4
if
max_relative_error
<
0.04
else
max_relative_error
0.0
1
if
max_relative_error
<
0.01
else
max_relative_error
)
fp32_numeric_grads
.
append
(
grad
)
numeric_grads
=
fp32_numeric_grads
if
self
.
is_float16_op
():
max_relative_error
=
(
0.001
if
max_relative_error
<
0.001
else
max_relative_error
)
self
.
_assert_is_close
(
numeric_grads
,
analytic_grads
,
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
145a6cbb
...
...
@@ -1910,14 +1910,14 @@ class OpTest(unittest.TestCase):
if
hasattr
(
self
,
'force_fp32_output'
)
and
getattr
(
self
,
'force_fp32_output'
):
atol
=
1e-2
atol
=
1e-2
if
atol
<
1e-2
else
atol
else
:
atol
=
2
atol
=
2
if
atol
<
2
else
atol
else
:
atol
=
1e-
1
atol
=
1e-
2
if
atol
<
1e-2
else
atol
if
self
.
is_float16_op
():
atol
=
1e-3
atol
=
1e-3
if
atol
<
1e-3
else
atol
if
no_check_set
is
not
None
:
if
(
...
...
@@ -2415,7 +2415,7 @@ class OpTest(unittest.TestCase):
if
grad
.
dtype
==
np
.
uint16
:
grad
=
convert_uint16_to_float
(
grad
)
max_relative_error
=
(
0.0
4
if
max_relative_error
<
0.04
else
max_relative_error
0.0
1
if
max_relative_error
<
0.01
else
max_relative_error
)
fp32_analytic_grads
.
append
(
grad
)
analytic_grads
=
fp32_analytic_grads
...
...
@@ -2425,11 +2425,16 @@ class OpTest(unittest.TestCase):
if
grad
.
dtype
==
np
.
uint16
:
grad
=
convert_uint16_to_float
(
grad
)
max_relative_error
=
(
0.0
4
if
max_relative_error
<
0.04
else
max_relative_error
0.0
1
if
max_relative_error
<
0.01
else
max_relative_error
)
fp32_numeric_grads
.
append
(
grad
)
numeric_grads
=
fp32_numeric_grads
if
self
.
is_float16_op
():
max_relative_error
=
(
0.001
if
max_relative_error
<
0.001
else
max_relative_error
)
self
.
_assert_is_close
(
numeric_grads
,
analytic_grads
,
...
...
python/paddle/fluid/tests/unittests/test_elementwise_div_op.py
浏览文件 @
145a6cbb
...
...
@@ -201,6 +201,35 @@ class TestElementwiseDivOpBF16(ElementwiseDivOp):
self
.
x_shape
=
[
12
,
13
]
self
.
y_shape
=
[
12
,
13
]
def
test_check_gradient
(
self
):
check_list
=
[]
check_list
.
append
(
{
'grad'
:
[
'X'
,
'Y'
],
'no_grad'
:
None
,
'val_grad'
:
[
self
.
grad_x
,
self
.
grad_y
],
}
)
check_list
.
append
(
{
'grad'
:
[
'Y'
],
'no_grad'
:
set
(
'X'
),
'val_grad'
:
[
self
.
grad_y
]}
)
check_list
.
append
(
{
'grad'
:
[
'X'
],
'no_grad'
:
set
(
'Y'
),
'val_grad'
:
[
self
.
grad_x
]}
)
for
check_option
in
check_list
:
check_args
=
[
check_option
[
'grad'
],
'Out'
]
check_kwargs
=
{
'no_grad_set'
:
check_option
[
'no_grad'
],
'user_defined_grads'
:
check_option
[
'val_grad'
],
'user_defined_grad_outputs'
:
[
self
.
grad_out
],
'check_dygraph'
:
self
.
check_dygraph
,
}
if
self
.
place
is
None
:
self
.
check_grad
(
*
check_args
,
**
check_kwargs
)
else
:
check_args
.
insert
(
0
,
self
.
place
)
self
.
check_grad_with_place
(
*
check_args
,
**
check_kwargs
)
# elementwise_pow does't support bfloat16
def
if_check_prim
(
self
):
self
.
check_prim
=
False
...
...
python/paddle/fluid/tests/unittests/test_reduce_op.py
浏览文件 @
145a6cbb
...
...
@@ -115,7 +115,7 @@ class TestSumOp_bf16(OpTest):
def
test_check_output
(
self
):
place
=
core
.
CUDAPlace
(
0
)
self
.
check_output_with_place
(
place
,
check_eager
=
True
)
self
.
check_output_with_place
(
place
,
check_eager
=
True
,
atol
=
0.1
)
def
test_check_grad
(
self
):
place
=
core
.
CUDAPlace
(
0
)
...
...
python/paddle/fluid/tests/unittests/test_scale_op.py
浏览文件 @
145a6cbb
...
...
@@ -171,7 +171,12 @@ class TestScaleBF16Op(OpTest):
self
.
check_output
(
check_eager
=
True
)
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
numeric_grad_delta
=
0.8
,
check_eager
=
True
)
self
.
check_grad
(
[
'X'
],
'Out'
,
numeric_grad_delta
=
0.8
,
check_eager
=
True
,
)
@
unittest
.
skipIf
(
...
...
python/paddle/fluid/tests/unittests/test_sum_op.py
浏览文件 @
145a6cbb
...
...
@@ -356,9 +356,7 @@ class TestSumBF16Op(OpTest):
def
test_check_grad
(
self
):
# new dynamic graph mode does not support unit16 type
self
.
check_grad
(
[
'x0'
],
'Out'
,
numeric_grad_delta
=
0.5
,
check_dygraph
=
False
)
self
.
check_grad
([
'x0'
],
'Out'
,
check_dygraph
=
False
)
class
API_Test_Add_n
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录