Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
74c0bc1c
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看板
未验证
提交
74c0bc1c
编写于
2月 22, 2022
作者:
J
jakpiase
提交者:
GitHub
2月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added round fwd onednn kernel (#39653)
上级
b95cd3b7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
0 deletion
+22
-0
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
+10
-0
python/paddle/fluid/tests/unittests/mkldnn/test_activation_mkldnn_op.py
...fluid/tests/unittests/mkldnn/test_activation_mkldnn_op.py
+12
-0
未找到文件。
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
浏览文件 @
74c0bc1c
...
@@ -262,6 +262,10 @@ using EluMKLDNNFunctor = MKLDNNActivationFunc<T, dnnl::algorithm::eltwise_elu>;
...
@@ -262,6 +262,10 @@ using EluMKLDNNFunctor = MKLDNNActivationFunc<T, dnnl::algorithm::eltwise_elu>;
template
<
typename
T
>
template
<
typename
T
>
using
ExpMKLDNNFunctor
=
MKLDNNActivationFunc
<
T
,
dnnl
::
algorithm
::
eltwise_exp
>
;
using
ExpMKLDNNFunctor
=
MKLDNNActivationFunc
<
T
,
dnnl
::
algorithm
::
eltwise_exp
>
;
template
<
typename
T
>
using
RoundMKLDNNFunctor
=
MKLDNNActivationFunc
<
T
,
dnnl
::
algorithm
::
eltwise_round
>
;
template
<
typename
T
>
template
<
typename
T
>
using
ReluMKLDNNGradFunctor
=
using
ReluMKLDNNGradFunctor
=
MKLDNNActivationGradFunc
<
T
,
dnnl
::
algorithm
::
eltwise_relu
>
;
MKLDNNActivationGradFunc
<
T
,
dnnl
::
algorithm
::
eltwise_relu
>
;
...
@@ -330,6 +334,10 @@ namespace ops = paddle::operators;
...
@@ -330,6 +334,10 @@ namespace ops = paddle::operators;
ops::MKLDNNActivationGradKernel< \
ops::MKLDNNActivationGradKernel< \
ops::grad_functor<paddle::platform::bfloat16>>);
ops::grad_functor<paddle::platform::bfloat16>>);
#define REGISTER_ACTIVATION_MKLDNN_KERNEL_FWD_ONLY(act_type, functor) \
REGISTER_OP_KERNEL(act_type, MKLDNN, ::paddle::platform::CPUPlace, \
ops::MKLDNNActivationKernel<ops::functor<float>>);
#define FOR_EACH_MKLDNN_KERNEL_FUNCTOR(__macro) \
#define FOR_EACH_MKLDNN_KERNEL_FUNCTOR(__macro) \
__macro(relu6, Relu6MKLDNNFunctor, Relu6MKLDNNGradFunctor); \
__macro(relu6, Relu6MKLDNNFunctor, Relu6MKLDNNGradFunctor); \
__macro(leaky_relu, ReluMKLDNNFunctor, ReluMKLDNNGradFunctor); \
__macro(leaky_relu, ReluMKLDNNFunctor, ReluMKLDNNGradFunctor); \
...
@@ -341,6 +349,8 @@ namespace ops = paddle::operators;
...
@@ -341,6 +349,8 @@ namespace ops = paddle::operators;
__macro(exp, ExpMKLDNNFunctor, ExpMKLDNNGradUseOutFunctor);
__macro(exp, ExpMKLDNNFunctor, ExpMKLDNNGradUseOutFunctor);
FOR_EACH_MKLDNN_KERNEL_FUNCTOR
(
REGISTER_ACTIVATION_MKLDNN_KERNEL
);
FOR_EACH_MKLDNN_KERNEL_FUNCTOR
(
REGISTER_ACTIVATION_MKLDNN_KERNEL
);
REGISTER_ACTIVATION_MKLDNN_KERNEL_FWD_ONLY
(
round
,
RoundMKLDNNFunctor
);
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL
(
relu
,
ReluMKLDNNFunctor
,
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL
(
relu
,
ReluMKLDNNFunctor
,
ReluMKLDNNGradFunctor
);
ReluMKLDNNGradFunctor
);
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL
(
gelu
,
GeluMKLDNNFunctor
,
REGISTER_ACTIVATION_MKLDNN_BF16_KERNEL
(
gelu
,
GeluMKLDNNFunctor
,
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_activation_mkldnn_op.py
浏览文件 @
74c0bc1c
...
@@ -328,6 +328,18 @@ class TestMKLDNNMish(TestActivation):
...
@@ -328,6 +328,18 @@ class TestMKLDNNMish(TestActivation):
self
.
attrs
=
{
"use_mkldnn"
:
True
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
class
TestMKLDNNRound
(
TestActivation
):
def
setUp
(
self
):
self
.
op_type
=
"round"
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
2
,
4
,
3
,
5
]).
astype
(
np
.
float32
)
out
=
np
.
round
(
x
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
out
}
self
.
attrs
=
{
"use_mkldnn"
:
True
}
class
TestMKLDNNSigmoidDim4
(
TestSigmoid
):
class
TestMKLDNNSigmoidDim4
(
TestSigmoid
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestMKLDNNSigmoidDim4
,
self
).
setUp
()
super
(
TestMKLDNNSigmoidDim4
,
self
).
setUp
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录