Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
1ba592d6
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1ba592d6
编写于
10月 20, 2022
作者:
H
HongyuJia
提交者:
GitHub
10月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opt mkldnn selection judgement (#47217)
上级
ac666538
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
26 deletion
+18
-26
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+14
-20
paddle/fluid/imperative/prepared_operator.cc
paddle/fluid/imperative/prepared_operator.cc
+4
-6
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
1ba592d6
...
...
@@ -1388,14 +1388,12 @@ bool OperatorWithKernel::SupportsKernelType(
#endif
// NOTE(jiahongyu): If MKLDNN can be used, the function SupportsKernelType needs
// to check whether current op supports MKLDNN kernel. There are three
// statements in if condition: The first statement checks whether library_type_
// are changed by other high priority backends; the second checks whether this
// op has specific implementation; the third checks whether mkldnn kernel can be
// used.
// to check whether current op supports MKLDNN kernel. There are two statements
// in if condition:
// 1. Whether this op has specific implementation;
// 2. Whether mkldnn kernel can be used.
#ifdef PADDLE_WITH_MKLDNN
if
(
kernel_type
.
library_type_
==
framework
::
LibraryType
::
kPlain
&&
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
if
(
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
this
->
CanMKLDNNBeUsed
(
exe_ctx
,
kernel_type
.
data_type_
))
{
auto
tmp_kernel_type
=
kernel_type
;
tmp_kernel_type
.
library_type_
=
framework
::
LibraryType
::
kMKLDNN
;
...
...
@@ -1571,13 +1569,11 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
// NOTE(jiahongyu): The registered MKLDNN kernel have library_type =
// LibraryType::kMKLDNN and data_layout_ = DataLayout::kMKLDNN. But the default
// values are kPlain, so we need to modify the library_type and data_layout_
// here. There are three statements in if condition: The first statement checks
// whether library_type_ are changed by other high priority backends; the second
// checks whether this op has specific implementation; the third checks whether
// mkldnn kernel can be used.
// here. There are two statements in if condition:
// 1. Whether this op has specific implementation;
// 2. Whether mkldnn kernel can be used.
#ifdef PADDLE_WITH_MKLDNN
if
(
kernel_type_
->
library_type_
==
framework
::
LibraryType
::
kPlain
&&
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
if
(
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
this
->
CanMKLDNNBeUsed
(
exe_ctx
,
kernel_type_
->
data_type_
))
{
kernel_type_
->
library_type_
=
framework
::
LibraryType
::
kMKLDNN
;
kernel_type_
->
data_layout_
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
@@ -1814,14 +1810,12 @@ OpKernelType OperatorWithKernel::InnerGetExpectedKernelType(
// NOTE(jiahongyu): PADDLE_WITH_MKLDNN codes are moved outside function
// GetExpectedKernelType, so that if MKLDNN can be used, the library_type_ and
// data_layout_ of expected_kernel_key need to be adjusted. There are three
// statements in if condition: The first statement checks whether library_type_
// are changed by other high priority backends; the second checks whether this
// op has specific implementation; the third checks whether mkldnn kernel can be
// used.
// data_layout_ of expected_kernel_key need to be adjusted. There are two
// statements in if condition:
// 1. Whether this op has specific implementation;
// 2. Whether mkldnn kernel can be used.
#ifdef PADDLE_WITH_MKLDNN
if
(
expected_kernel_key
.
library_type_
==
framework
::
LibraryType
::
kPlain
&&
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
if
(
!
paddle
::
platform
::
in_mkldnn_white_list
(
type_
)
&&
this
->
CanMKLDNNBeUsed
(
ctx
,
expected_kernel_key
.
data_type_
))
{
expected_kernel_key
.
library_type_
=
framework
::
LibraryType
::
kMKLDNN
;
expected_kernel_key
.
data_layout_
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
paddle/fluid/imperative/prepared_operator.cc
浏览文件 @
1ba592d6
...
...
@@ -192,13 +192,11 @@ PreparedOp PrepareImpl(
// NOTE(jiahongyu): The registered MKLDNN kernel have library_type =
// LibraryType::kMKLDNN and data_layout_ = DataLayout::kMKLDNN. But the default
// values are kPlain, so we need to modify the library_type and data_layout_
// here. There are three statements in if condition: The first statement checks
// whether library_type_ are changed by other high priority backends; the second
// checks whether this op has specific implementation; the third checks whether
// mkldnn kernel can be used.
// here. There are two statements in if condition:
// 1. Whether this op has specific implementation;
// 2. Whether mkldnn kernel can be used.
#ifdef PADDLE_WITH_MKLDNN
if
(
expected_kernel_key
.
library_type_
==
framework
::
LibraryType
::
kPlain
&&
!
paddle
::
platform
::
in_mkldnn_white_list
(
op
.
Type
())
&&
if
(
!
paddle
::
platform
::
in_mkldnn_white_list
(
op
.
Type
())
&&
op
.
CanMKLDNNBeUsed
(
dygraph_exe_ctx
,
expected_kernel_key
.
data_type_
))
{
expected_kernel_key
.
library_type_
=
framework
::
LibraryType
::
kMKLDNN
;
expected_kernel_key
.
data_layout_
=
framework
::
DataLayout
::
kMKLDNN
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录