Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
6461e800
P
Paddle
项目概览
机器未来
/
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看板
提交
6461e800
编写于
3月 22, 2018
作者:
K
Krzysztof Binias
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Inheritance added for MKLDNN tests
上级
d8bd436f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
34 deletion
+16
-34
python/paddle/fluid/tests/unittests/test_activation_op.py
python/paddle/fluid/tests/unittests/test_activation_op.py
+16
-34
未找到文件。
python/paddle/fluid/tests/unittests/test_activation_op.py
浏览文件 @
6461e800
...
@@ -507,58 +507,46 @@ class TestSwish(OpTest):
...
@@ -507,58 +507,46 @@ class TestSwish(OpTest):
#--------------------test MKLDNN--------------------
#--------------------test MKLDNN--------------------
class
TestMKLDNNRelu
(
OpTest
):
class
TestMKLDNNRelu
(
TestRelu
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"relu"
super
(
TestMKLDNNRelu
,
self
).
setUp
()
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
# The same reason with TestAbs
# The same reason with TestAbs
x
[
np
.
abs
(
x
)
<
0.005
]
=
0.02
x
[
np
.
abs
(
x
)
<
0.005
]
=
0.02
self
.
inputs
=
{
'X'
:
x
}
out
=
np
.
maximum
(
x
,
0
)
self
.
outputs
=
{
'Out'
:
np
.
maximum
(
self
.
inputs
[
'X'
],
0
)}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
x
)}
self
.
check_grad
([
'X'
],
'Out'
,
max_relative_error
=
0.007
)
self
.
outputs
=
{
'Out'
:
out
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
class
TestMKLDNNTanh
(
OpTest
):
class
TestMKLDNNTanh
(
TestTanh
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"tanh"
super
(
TestMKLDNNTanh
,
self
).
setUp
()
self
.
inputs
=
{
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
}
}
self
.
outputs
=
{
'Out'
:
np
.
tanh
(
self
.
inputs
[
'X'
])}
self
.
outputs
=
{
'Out'
:
np
.
tanh
(
self
.
inputs
[
'X'
])}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
class
TestMKLDNNSqrt
(
TestSqrt
):
self
.
check_grad
([
'X'
],
'Out'
,
max_relative_error
=
0.007
)
class
TestMKLDNNSqrt
(
OpTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"sqrt"
super
(
TestMKLDNNSqrt
,
self
).
setUp
()
self
.
inputs
=
{
self
.
inputs
=
{
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
'X'
:
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
}
}
self
.
outputs
=
{
'Out'
:
np
.
sqrt
(
self
.
inputs
[
'X'
])}
self
.
outputs
=
{
'Out'
:
np
.
sqrt
(
self
.
inputs
[
'X'
])}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
max_relative_error
=
0.007
)
class
TestMKLDNNAbs
(
OpTest
):
class
TestMKLDNNAbs
(
TestAbs
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"abs"
super
(
TestMKLDNNAbs
,
self
).
setUp
()
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
x
=
np
.
random
.
uniform
(
-
1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
"float32"
)
# The same reason with TestAbs
# The same reason with TestAbs
x
[
np
.
abs
(
x
)
<
0.005
]
=
0.02
x
[
np
.
abs
(
x
)
<
0.005
]
=
0.02
...
@@ -566,12 +554,6 @@ class TestMKLDNNAbs(OpTest):
...
@@ -566,12 +554,6 @@ class TestMKLDNNAbs(OpTest):
self
.
outputs
=
{
'Out'
:
np
.
abs
(
self
.
inputs
[
'X'
])}
self
.
outputs
=
{
'Out'
:
np
.
abs
(
self
.
inputs
[
'X'
])}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
def
test_check_output
(
self
):
self
.
check_output
()
def
test_check_grad
(
self
):
self
.
check_grad
([
'X'
],
'Out'
,
max_relative_error
=
0.007
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录