Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
bc902044
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
bc902044
编写于
11月 27, 2020
作者:
A
arlesniak
提交者:
GitHub
11月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes mkldnn dygraph learning rate scheduler crashes (#28988)
上级
0fca8cdf
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
58 addition
and
45 deletion
+58
-45
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+17
-0
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+5
-0
paddle/fluid/operators/activation_op.cc
paddle/fluid/operators/activation_op.cc
+1
-1
paddle/fluid/operators/addmm_op.cc
paddle/fluid/operators/addmm_op.cc
+1
-1
paddle/fluid/operators/batch_norm_op.cc
paddle/fluid/operators/batch_norm_op.cc
+2
-4
paddle/fluid/operators/concat_op.cc
paddle/fluid/operators/concat_op.cc
+1
-1
paddle/fluid/operators/conv_op.cc
paddle/fluid/operators/conv_op.cc
+2
-3
paddle/fluid/operators/conv_transpose_op.cc
paddle/fluid/operators/conv_transpose_op.cc
+1
-1
paddle/fluid/operators/data_norm_op.cc
paddle/fluid/operators/data_norm_op.cc
+2
-2
paddle/fluid/operators/detection/prior_box_op.cc
paddle/fluid/operators/detection/prior_box_op.cc
+1
-1
paddle/fluid/operators/elementwise/elementwise_div_op.h
paddle/fluid/operators/elementwise/elementwise_div_op.h
+1
-1
paddle/fluid/operators/elementwise/elementwise_mul_op.h
paddle/fluid/operators/elementwise/elementwise_mul_op.h
+1
-1
paddle/fluid/operators/elementwise/elementwise_op.h
paddle/fluid/operators/elementwise/elementwise_op.h
+5
-6
paddle/fluid/operators/fused/fusion_gru_op.cc
paddle/fluid/operators/fused/fusion_gru_op.cc
+1
-1
paddle/fluid/operators/gaussian_random_op.cc
paddle/fluid/operators/gaussian_random_op.cc
+1
-1
paddle/fluid/operators/gelu_op.cc
paddle/fluid/operators/gelu_op.cc
+2
-2
paddle/fluid/operators/layer_norm_op.cc
paddle/fluid/operators/layer_norm_op.cc
+1
-1
paddle/fluid/operators/lrn_op.cc
paddle/fluid/operators/lrn_op.cc
+2
-2
paddle/fluid/operators/matmul_op.cc
paddle/fluid/operators/matmul_op.cc
+1
-1
paddle/fluid/operators/mul_op.cc
paddle/fluid/operators/mul_op.cc
+1
-1
paddle/fluid/operators/pool_op.cc
paddle/fluid/operators/pool_op.cc
+2
-2
paddle/fluid/operators/softmax_op.cc
paddle/fluid/operators/softmax_op.cc
+2
-2
paddle/fluid/operators/sum_op.cc
paddle/fluid/operators/sum_op.cc
+1
-1
paddle/fluid/operators/transpose_op.cc
paddle/fluid/operators/transpose_op.cc
+4
-4
paddle/fluid/platform/mkldnn_helper.h
paddle/fluid/platform/mkldnn_helper.h
+0
-5
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
bc902044
...
...
@@ -1007,6 +1007,23 @@ static void CheckTensorNANOrInf(const std::string& op_type,
op_type
,
name
));
}
bool
OperatorWithKernel
::
SupportsMKLDNN
()
const
{
auto
&
op_kernels
=
OperatorWithKernel
::
AllOpKernels
().
at
(
type_
);
return
std
::
any_of
(
op_kernels
.
begin
(),
op_kernels
.
end
(),
[](
OpKernelMap
::
const_reference
kern_pair
)
{
return
platform
::
is_cpu_place
(
kern_pair
.
first
.
place_
)
&&
kern_pair
.
first
.
library_type_
==
LibraryType
::
kMKLDNN
;
});
}
bool
OperatorWithKernel
::
CanMKLDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
bool
use_mkldnn_ctx
=
ctx
.
Attr
<
bool
>
(
"use_mkldnn"
)
&&
platform
::
is_cpu_place
(
ctx
.
GetPlace
());
return
use_mkldnn_ctx
&&
this
->
SupportsMKLDNN
();
}
void
OperatorWithKernel
::
RuntimeInferShape
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
,
const
RuntimeContext
&
ctx
)
const
{
...
...
paddle/fluid/framework/operator.h
浏览文件 @
bc902044
...
...
@@ -156,6 +156,8 @@ class OperatorBase {
virtual
bool
SupportGPU
()
const
{
return
false
;
}
virtual
bool
SupportsMKLDNN
()
const
{
return
false
;
}
const
std
::
string
&
Type
()
const
{
return
type_
;
}
bool
HasAttr
(
const
std
::
string
&
name
)
const
{
return
attrs_
.
count
(
name
);
}
...
...
@@ -490,6 +492,9 @@ class OperatorWithKernel : public OperatorBase {
return
platform
::
is_gpu_place
(
kern_pair
.
first
.
place_
);
});
}
bool
SupportsMKLDNN
()
const
override
;
bool
CanMKLDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
const
;
virtual
void
InferShape
(
InferShapeContext
*
ctx
)
const
=
0
;
...
...
paddle/fluid/operators/activation_op.cc
100755 → 100644
浏览文件 @
bc902044
...
...
@@ -106,7 +106,7 @@ framework::OpKernelType GetKernelType(const framework::ExecutionContext& ctx,
#ifdef PADDLE_WITH_MKLDNN
auto
it
=
oper
.
Attrs
().
find
(
"use_mkldnn"
);
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
it
!=
oper
.
Attrs
().
end
()
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
oper
.
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/addmm_op.cc
浏览文件 @
bc902044
...
...
@@ -119,7 +119,7 @@ class AddMMOp : public framework::OperatorWithKernel {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
paddle/fluid/operators/batch_norm_op.cc
浏览文件 @
bc902044
...
...
@@ -157,8 +157,7 @@ framework::OpKernelType BatchNormOp::GetExpectedKernelType(
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -527,8 +526,7 @@ framework::OpKernelType BatchNormGradOp::GetExpectedKernelType(
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/concat_op.cc
浏览文件 @
bc902044
...
...
@@ -83,7 +83,7 @@ class ConcatOp : public framework::OperatorWithKernel {
"All Inputs of Concat OP are Empty!"
));
}
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
paddle/fluid/operators/conv_op.cc
浏览文件 @
bc902044
...
...
@@ -155,8 +155,7 @@ framework::OpKernelType ConvOp::GetExpectedKernelType(
}
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
customized_type_value
=
...
...
@@ -565,7 +564,7 @@ framework::OpKernelType ConvOpGrad::GetExpectedKernelType(
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
const
std
::
string
data_format
=
ctx
.
Attr
<
std
::
string
>
(
"data_format"
);
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
paddle/fluid/operators/conv_transpose_op.cc
浏览文件 @
bc902044
...
...
@@ -193,7 +193,7 @@ framework::OpKernelType ConvTransposeOp::GetExpectedKernelType(
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/data_norm_op.cc
浏览文件 @
bc902044
...
...
@@ -184,7 +184,7 @@ class DataNormOp : public framework::OperatorWithKernel {
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -486,7 +486,7 @@ class DataNormGradOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/detection/prior_box_op.cc
浏览文件 @
bc902044
...
...
@@ -98,7 +98,7 @@ class PriorBoxOp : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
auto
input_image_type
=
ctx
.
Input
<
framework
::
Tensor
>
(
"Image"
)
->
type
();
...
...
paddle/fluid/operators/elementwise/elementwise_div_op.h
浏览文件 @
bc902044
...
...
@@ -163,7 +163,7 @@ class ElementwiseDivOpDoubleGrad : public framework::OperatorWithKernel {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"DDX"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
paddle/fluid/operators/elementwise/elementwise_mul_op.h
浏览文件 @
bc902044
...
...
@@ -33,7 +33,7 @@ class ElementwiseMulOp : public ElementwiseOp {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
paddle/fluid/operators/elementwise/elementwise_op.h
浏览文件 @
bc902044
...
...
@@ -108,7 +108,7 @@ class ElementwiseOp : public framework::OperatorWithKernel {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
@@ -265,9 +265,8 @@ class ElementwiseOpGrad : public framework::OperatorWithKernel {
return
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
dims
()
==
ctx
.
Input
<
Tensor
>
(
"Y"
)
->
dims
());
};
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
)
&&
(
ctx
.
Type
()
!=
"elementwise_add_grad"
||
CanMKLDNNElementwiseAddGradBeUsed
()))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
)
&&
(
ctx
.
Type
()
!=
"elementwise_add_grad"
||
CanMKLDNNElementwiseAddGradBeUsed
()))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
@@ -304,7 +303,7 @@ class ElementwiseOpDoubleGrad : public framework::OperatorWithKernel {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"DOut"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
@@ -343,7 +342,7 @@ class ElementwiseOpDoubleGradWithoutDXDY
}
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
paddle/fluid/operators/fused/fusion_gru_op.cc
浏览文件 @
bc902044
...
...
@@ -133,7 +133,7 @@ framework::OpKernelType FusionGRUOp::GetExpectedKernelType(
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/gaussian_random_op.cc
浏览文件 @
bc902044
...
...
@@ -115,7 +115,7 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/gelu_op.cc
浏览文件 @
bc902044
...
...
@@ -49,7 +49,7 @@ class GeluOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
auto
it
=
this
->
Attrs
().
find
(
"use_mkldnn"
);
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
it
!=
this
->
Attrs
().
end
()
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
it
!=
this
->
Attrs
().
end
()
&&
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -89,7 +89,7 @@ class GeluGradOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
auto
it
=
this
->
Attrs
().
find
(
"use_mkldnn"
);
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
it
!=
this
->
Attrs
().
end
()
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
it
!=
this
->
Attrs
().
end
()
&&
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/layer_norm_op.cc
浏览文件 @
bc902044
...
...
@@ -104,7 +104,7 @@ class LayerNormOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/lrn_op.cc
浏览文件 @
bc902044
...
...
@@ -201,7 +201,7 @@ class LRNOp : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -341,7 +341,7 @@ class LRNOpGrad : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/matmul_op.cc
浏览文件 @
bc902044
...
...
@@ -659,7 +659,7 @@ class MatMulOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
using
mkldnn
::
memory
;
if
(
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
if
(
this
->
CanMKLDNNBeUsed
(
ctx
))
{
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
...
...
paddle/fluid/operators/mul_op.cc
浏览文件 @
bc902044
...
...
@@ -106,7 +106,7 @@ class MulOp : public framework::OperatorWithKernel {
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
paddle/fluid/operators/pool_op.cc
浏览文件 @
bc902044
...
...
@@ -157,7 +157,7 @@ framework::OpKernelType PoolOp::GetExpectedKernelType(
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -213,7 +213,7 @@ framework::OpKernelType PoolOpGrad::GetExpectedKernelType(
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/softmax_op.cc
浏览文件 @
bc902044
...
...
@@ -72,7 +72,7 @@ class SoftmaxOp : public framework::OperatorWithKernel {
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -196,7 +196,7 @@ class SoftmaxOpGrad : public framework::OperatorWithKernel {
#endif
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/operators/sum_op.cc
浏览文件 @
bc902044
...
...
@@ -147,7 +147,7 @@ class SumOp : public framework::OperatorWithKernel {
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
)
&&
this
->
CanMKLDNNBeUsed
(
ctx
)
&&
(
static_cast
<
framework
::
proto
::
VarType
::
Type
>
(
dtype
)
==
framework
::
proto
::
VarType
::
FP32
||
static_cast
<
framework
::
proto
::
VarType
::
Type
>
(
dtype
)
==
...
...
paddle/fluid/operators/transpose_op.cc
浏览文件 @
bc902044
...
...
@@ -88,7 +88,7 @@ class TransposeOp : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
StringToDataLayout
(
data_format
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -186,7 +186,7 @@ class TransposeOpGrad : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
StringToDataLayout
(
data_format
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
@@ -233,7 +233,7 @@ class Transpose2Op : public TransposeOp {
framework
::
DataLayout
layout_
=
framework
::
StringToDataLayout
(
data_format
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
using
framework
::
proto
::
VarType
;
...
...
@@ -298,7 +298,7 @@ class Transpose2OpGrad : public framework::OperatorWithKernel {
framework
::
DataLayout
layout_
=
framework
::
StringToDataLayout
(
data_format
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
platform
::
CanMKLDNNBeUsed
(
ctx
))
{
this
->
CanMKLDNNBeUsed
(
ctx
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
}
...
...
paddle/fluid/platform/mkldnn_helper.h
浏览文件 @
bc902044
...
...
@@ -134,11 +134,6 @@ inline mkldnn::memory::desc MKLDNNMemDesc(const std::vector<int64_t>& dims,
return
mkldnn
::
memory
::
desc
({
dims
},
data_type
,
format
);
}
inline
bool
CanMKLDNNBeUsed
(
const
framework
::
ExecutionContext
&
ctx
)
{
bool
use_mkldnn
=
ctx
.
Attr
<
bool
>
(
"use_mkldnn"
);
return
use_mkldnn
&&
platform
::
is_cpu_place
(
ctx
.
GetPlace
());
}
inline
void
ClearMKLDNNCache
(
const
platform
::
Place
&
place
)
{
// Clear mkl-dnn cache,
if
(
platform
::
is_cpu_place
(
place
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录