Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b2b9a1bb
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
b2b9a1bb
编写于
9月 17, 2022
作者:
J
jiahongyu
提交者:
HongyuJia
9月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine mkldnn code
上级
db97773b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
67 addition
and
84 deletion
+67
-84
paddle/fluid/operators/dequantize_op.cc
paddle/fluid/operators/dequantize_op.cc
+7
-8
paddle/fluid/operators/fc_op.cc
paddle/fluid/operators/fc_op.cc
+10
-15
paddle/fluid/operators/gaussian_random_op.cc
paddle/fluid/operators/gaussian_random_op.cc
+6
-8
paddle/fluid/operators/gaussian_random_op_npu.cc
paddle/fluid/operators/gaussian_random_op_npu.cc
+0
-3
paddle/fluid/operators/gelu_op.cc
paddle/fluid/operators/gelu_op.cc
+12
-14
paddle/fluid/operators/interpolate_op.cc
paddle/fluid/operators/interpolate_op.cc
+5
-5
paddle/fluid/operators/interpolate_v2_op.cc
paddle/fluid/operators/interpolate_v2_op.cc
+5
-5
paddle/fluid/operators/layer_norm_op.cc
paddle/fluid/operators/layer_norm_op.cc
+6
-8
paddle/fluid/operators/lrn_op.cc
paddle/fluid/operators/lrn_op.cc
+16
-18
未找到文件。
paddle/fluid/operators/dequantize_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -24,14 +24,13 @@ namespace operators {
framework
::
OpKernelType
DeQuantOp
::
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
framework
::
LibraryType
library_
=
framework
::
LibraryType
::
kMKLDNN
;
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
return
framework
::
OpKernelType
(
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
),
ctx
.
GetPlace
(),
layout_
,
library_
);
auto
input_data_type
=
framework
::
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
void
DeQuantOpMaker
::
Make
()
{
...
...
paddle/fluid/operators/fc_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -126,26 +126,21 @@ class FCOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
int
customized_type_value
=
framework
::
OpKernelType
::
kDefaultCustomizedTypeValue
;
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
if
(
ctx
.
Attr
<
bool
>
(
"use_mkldnn"
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
using
framework
::
proto
::
VarType
;
customized_type_value
=
(
input_data_type
==
VarType
::
INT8
||
input_data_type
==
VarType
::
UINT8
)
?
kFCMKLDNNINT8
:
kFCMKLDNNFP32
;
int
customized_type_value
=
(
input_data_type
==
VarType
::
INT8
||
input_data_type
==
VarType
::
UINT8
)
?
kFCMKLDNNINT8
:
kFCMKLDNNFP32
;
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
,
customized_type_value
);
}
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
layout
,
library
,
customized_type_value
);
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
());
}
};
...
...
paddle/fluid/operators/gaussian_random_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -58,21 +58,19 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library
{
framework
::
LibraryType
::
kPlain
};
framework
::
DataLayout
layout
{
framework
::
DataLayout
::
kAnyLayout
};
auto
data_type
=
static_cast
<
framework
::
proto
::
VarType
::
Type
>
(
ctx
.
Attr
<
int
>
(
"dtype"
));
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
return
framework
::
OpKernelType
(
data_type
,
ctx
.
device_context
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
device_context
(),
layout
,
library
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
device_context
());
}
framework
::
OpKernelType
GetKernelTypeForVar
(
...
...
paddle/fluid/operators/gaussian_random_op_npu.cc
浏览文件 @
b2b9a1bb
...
...
@@ -18,9 +18,6 @@ limitations under the License. */
#include "paddle/fluid/framework/generator.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_version_registry.h"
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
namespace
paddle
{
namespace
operators
{
...
...
paddle/fluid/operators/gelu_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -35,17 +35,16 @@ class GeluOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library
{
framework
::
LibraryType
::
kPlain
};
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
()
,
layout
,
library
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
};
...
...
@@ -76,18 +75,17 @@ class GeluGradOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library
{
framework
::
LibraryType
::
kPlain
};
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
auto
it
=
this
->
Attrs
().
find
(
"use_mkldnn"
);
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
it
!=
this
->
Attrs
().
end
()
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
if
(
it
!=
this
->
Attrs
().
end
()
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
()
,
layout
,
library
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
};
...
...
paddle/fluid/operators/interpolate_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -340,8 +340,6 @@ class InterpolateOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
...
...
@@ -349,12 +347,14 @@ class InterpolateOp : public framework::OperatorWithKernel {
// TODO(danqing): support other interp_method
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
)
&&
(
interp_method
==
"nearest"
||
interp_method
==
"bilinear"
))
{
layout
=
framework
::
DataLayout
::
kMKLDNN
;
library
=
framework
::
LibraryType
::
kMKLDNN
;
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
()
,
layout
,
library
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
framework
::
OpKernelType
GetKernelTypeForVar
(
...
...
paddle/fluid/operators/interpolate_v2_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -444,8 +444,6 @@ class InterpolateV2Op : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
#ifdef PADDLE_WITH_MKLDNN
...
...
@@ -453,12 +451,14 @@ class InterpolateV2Op : public framework::OperatorWithKernel {
// TODO(danqing): support other interp_method
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
)
&&
(
interp_method
==
"nearest"
||
interp_method
==
"bilinear"
))
{
layout
=
framework
::
DataLayout
::
kMKLDNN
;
library
=
framework
::
LibraryType
::
kMKLDNN
;
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
()
,
layout
,
library
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
framework
::
OpKernelType
GetKernelTypeForVar
(
...
...
paddle/fluid/operators/layer_norm_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -110,21 +110,19 @@ class LayerNormOp : public framework::OperatorWithKernel {
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
input_data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
framework
::
LibraryType
library
=
framework
::
LibraryType
::
kPlain
;
framework
::
DataLayout
layout
=
framework
::
DataLayout
::
kAnyLayout
;
#ifdef PADDLE_WITH_MKLDNN
int
begin_norm_axis
=
ctx
.
Attr
<
int
>
(
"begin_norm_axis"
);
if
(
library
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
input_data_type
)
&&
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
input_data_type
)
&&
begin_norm_axis
==
ctx
.
Input
<
Tensor
>
(
"X"
)
->
dims
().
size
()
-
1
)
{
library
=
framework
::
LibraryType
::
kMKLDNN
;
layout
=
framework
::
DataLayout
::
kMKLDNN
;
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
(),
layout
,
library
);
return
framework
::
OpKernelType
(
input_data_type
,
ctx
.
GetPlace
());
}
};
...
...
paddle/fluid/operators/lrn_op.cc
浏览文件 @
b2b9a1bb
...
...
@@ -225,19 +225,18 @@ class LRNOp : public framework::OperatorWithKernel {
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library_
{
framework
::
LibraryType
::
kPlain
};
// TODO(pzelazko-intel): enable MKLDNN layout when it's ready
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kAnyLayout
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
// TODO(pzelazko-intel): enable MKLDNN layout when it's ready
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
layout_
,
library_
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
framework
::
OpKernelType
GetKernelTypeForVar
(
...
...
@@ -360,19 +359,18 @@ class LRNOpGrad : public framework::OperatorWithKernel {
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
framework
::
LibraryType
library_
{
framework
::
LibraryType
::
kPlain
};
// TODO(pzelazko-intel): enable MKLDNN layout when it's ready
framework
::
DataLayout
layout_
=
framework
::
DataLayout
::
kAnyLayout
;
auto
data_type
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
// TODO(pzelazko-intel): enable MKLDNN layout when it's ready
#ifdef PADDLE_WITH_MKLDNN
if
(
library_
==
framework
::
LibraryType
::
kPlain
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
library_
=
framework
::
LibraryType
::
kMKLDNN
;
layout_
=
framework
::
DataLayout
::
kMKLDNN
;
if
(
this
->
CanMKLDNNBeUsed
(
ctx
,
data_type
))
{
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
framework
::
DataLayout
::
kMKLDNN
,
framework
::
LibraryType
::
kMKLDNN
);
}
#endif
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
(),
layout_
,
library_
);
return
framework
::
OpKernelType
(
data_type
,
ctx
.
GetPlace
());
}
framework
::
OpKernelType
GetKernelTypeForVar
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录