Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d55120d7
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看板
未验证
提交
d55120d7
编写于
3月 18, 2021
作者:
L
liym27
提交者:
GitHub
3月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NPU] Support testing grad of NPU ops in OpTest (#31697)
上级
e4247120
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
33 deletion
+38
-33
python/paddle/fluid/tests/unittests/npu/test_elementwise_add_op_npu.py
.../fluid/tests/unittests/npu/test_elementwise_add_op_npu.py
+22
-26
python/paddle/fluid/tests/unittests/npu/test_pow_op_npu.py
python/paddle/fluid/tests/unittests/npu/test_pow_op_npu.py
+3
-6
python/paddle/fluid/tests/unittests/npu/test_slice_op_npu.py
python/paddle/fluid/tests/unittests/npu/test_slice_op_npu.py
+4
-0
python/paddle/fluid/tests/unittests/op_test.py
python/paddle/fluid/tests/unittests/op_test.py
+9
-1
未找到文件。
python/paddle/fluid/tests/unittests/npu/test_elementwise_add_op_npu.py
浏览文件 @
d55120d7
...
...
@@ -64,28 +64,28 @@ class TestElementwiseAddOp(OpTest):
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
,
check_dygraph
=
False
)
# TODO(ascendrc): Test grad op after it is implemented.
# def test_check_grad_normal(self):
# self.check_grad_with_place(
# self.place, ['X', 'Y']
,
# 'Out'
,
# max_relative_error=0.006,
# check_dygraph=False)
#
# def test_check_grad_ingore_x(self):
# self.check_grad_with_place(
# self.place, ['Y']
,
# 'Out'
,
# no_grad_set=set("X")
,
# max_relative_error=0.006,
# check_dygraph=False)
#
# def test_check_grad_ingore_y(self):
# self.check_grad_with_place(
# self.place, ['X']
,
# 'Out'
,
# no_grad_set=set("Y")
,
# max_relative_error=0.006,
check_dygraph=False)
def
test_check_grad_normal
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
,
'Y'
],
'Out'
,
max_relative_error
=
0.006
,
check_dygraph
=
False
)
def
test_check_grad_ingore_x
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'Y'
],
'Out'
,
no_grad_set
=
set
(
"X"
)
,
max_relative_error
=
0.006
,
check_dygraph
=
False
)
def
test_check_grad_ingore_y
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
no_grad_set
=
set
(
"Y"
)
,
max_relative_error
=
0.006
,
check_dygraph
=
False
)
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_npu
(),
...
...
@@ -133,10 +133,6 @@ class TestAddAPI(unittest.TestCase):
True
,
msg
=
"z_value = {}, but expected {}"
.
format
(
z_value
,
z_expected
))
def
test_backward
(
self
):
# TODO(ascendrc): Test backward after add grad npu op implemented.
pass
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_npu
(),
"core is not compiled with NPU"
)
...
...
python/paddle/fluid/tests/unittests/npu/test_pow_op_npu.py
浏览文件 @
d55120d7
...
...
@@ -52,12 +52,9 @@ class TestPow(OpTest):
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
,
check_dygraph
=
False
)
# TODO(ascendrc): Add grad test
# def test_check_grad(self):
# if self.dtype == np.float16:
# return
# self.check_grad(['X'], 'Out')
#
def
test_check_grad
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
check_dygraph
=
False
)
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_npu
(),
...
...
python/paddle/fluid/tests/unittests/npu/test_slice_op_npu.py
浏览文件 @
d55120d7
...
...
@@ -62,6 +62,10 @@ class TestSliceOp(OpTest):
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
,
check_dygraph
=
False
)
def
test_check_grad_normal
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'Input'
],
'Out'
,
check_dygraph
=
False
)
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_npu
(),
"core is not compiled with NPU"
)
...
...
python/paddle/fluid/tests/unittests/op_test.py
浏览文件 @
d55120d7
...
...
@@ -1416,9 +1416,17 @@ class OpTest(unittest.TestCase):
if
not
type
(
output_names
)
is
list
:
output_names
=
[
output_names
]
# FIXME: Replace numeric_place with place to calculate numeric_grads.
# NOTE(liym27): There is an unknown error when call op.run() on NPUPlace, which
# needs to be fixed.
if
self
.
__class__
.
use_npu
==
True
:
numeric_place
=
paddle
.
CPUPlace
()
else
:
numeric_place
=
place
numeric_grads
=
user_defined_grads
or
[
get_numeric_gradient
(
place
,
numeric_
place
,
self
.
scope
,
self
.
op
,
self
.
inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录