Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
78ab656c
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看板
未验证
提交
78ab656c
编写于
7月 09, 2021
作者:
F
feng_shuai
提交者:
GitHub
7月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
depthwise_conv_mkl_pass (#33936)
上级
033d736d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
1 deletion
+53
-1
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.cc
...e/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.cc
+45
-0
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.h
...le/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.h
+1
-0
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc
.../framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc
+7
-1
未找到文件。
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.cc
浏览文件 @
78ab656c
...
@@ -31,6 +31,47 @@ class Graph;
...
@@ -31,6 +31,47 @@ class Graph;
PADDLE_ENFORCE_NOT_NULL( \
PADDLE_ENFORCE_NOT_NULL( \
id, platform::errors::InvalidArgument("Subgraph has no node %s.", #id));
id, platform::errors::InvalidArgument("Subgraph has no node %s.", #id));
DepthwiseConvMKLDNNPass
::
DepthwiseConvMKLDNNPass
()
{
AddOpCompat
(
OpCompat
(
"depthwise_conv2d"
))
.
AddInput
(
"Input"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Filter"
)
.
IsTensor
()
.
End
()
.
AddInput
(
"Bias"
)
.
IsOptional
()
.
IsTensor
()
.
End
()
.
AddInput
(
"ResidualData"
)
.
IsOptional
()
.
IsTensor
()
.
End
()
.
AddOutput
(
"Output"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"strides"
)
.
IsType
<
std
::
vector
<
int
>>
()
.
End
()
.
AddAttr
(
"paddings"
)
.
IsType
<
std
::
vector
<
int
>>
()
.
End
()
.
AddAttr
(
"padding_algorithm"
)
// mobilenet-ssd has no "padding_algorithm"
.
IsOptional
()
.
IsStringIn
({
"EXPLICIT"
,
"SAME"
,
"VALID"
})
.
End
()
.
AddAttr
(
"groups"
)
.
IsNumGE
(
1
)
.
End
()
.
AddAttr
(
"dilations"
)
.
IsType
<
std
::
vector
<
int
>>
()
.
End
()
.
AddAttr
(
"data_format"
)
.
IsStringIn
({
"NHWC"
,
"NCHW"
,
"AnyLayout"
})
.
End
();
}
void
DepthwiseConvMKLDNNPass
::
ApplyImpl
(
ir
::
Graph
*
graph
)
const
{
void
DepthwiseConvMKLDNNPass
::
ApplyImpl
(
ir
::
Graph
*
graph
)
const
{
PADDLE_ENFORCE_NOT_NULL
(
PADDLE_ENFORCE_NOT_NULL
(
graph
,
platform
::
errors
::
InvalidArgument
(
"Graph cannot be nullptr."
));
graph
,
platform
::
errors
::
InvalidArgument
(
"Graph cannot be nullptr."
));
...
@@ -45,6 +86,10 @@ void DepthwiseConvMKLDNNPass::ApplyImpl(ir::Graph* graph) const {
...
@@ -45,6 +86,10 @@ void DepthwiseConvMKLDNNPass::ApplyImpl(ir::Graph* graph) const {
int
found_depthwise_conv_mkldnn_count
=
0
;
int
found_depthwise_conv_mkldnn_count
=
0
;
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
auto
handler
=
[
&
](
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
g
)
{
Graph
*
g
)
{
if
(
!
IsCompat
(
subgraph
,
g
))
{
LOG
(
WARNING
)
<<
"Pass op compat failed."
;
return
;
}
VLOG
(
3
)
<<
"handle DepthwiseConvMKLDNN fuse"
;
VLOG
(
3
)
<<
"handle DepthwiseConvMKLDNN fuse"
;
GET_NODE
(
depthwise_conv
,
(
*
pattern
));
GET_NODE
(
depthwise_conv
,
(
*
pattern
));
depthwise_conv
->
Op
()
->
SetType
(
"conv2d"
);
depthwise_conv
->
Op
()
->
SetType
(
"conv2d"
);
...
...
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.h
浏览文件 @
78ab656c
...
@@ -24,6 +24,7 @@ class Graph;
...
@@ -24,6 +24,7 @@ class Graph;
class
DepthwiseConvMKLDNNPass
:
public
FusePassBase
{
class
DepthwiseConvMKLDNNPass
:
public
FusePassBase
{
public:
public:
DepthwiseConvMKLDNNPass
();
virtual
~
DepthwiseConvMKLDNNPass
()
{}
virtual
~
DepthwiseConvMKLDNNPass
()
{}
protected:
protected:
...
...
paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc
浏览文件 @
78ab656c
...
@@ -29,10 +29,16 @@ void SetOp(ProgramDesc* prog, const std::string& type, const std::string& name,
...
@@ -29,10 +29,16 @@ void SetOp(ProgramDesc* prog, const std::string& type, const std::string& name,
op
->
SetType
(
type
);
op
->
SetType
(
type
);
op
->
SetAttr
(
"use_mkldnn"
,
use_mkldnn
);
op
->
SetAttr
(
"use_mkldnn"
,
use_mkldnn
);
op
->
SetAttr
(
"name"
,
name
);
op
->
SetAttr
(
"name"
,
name
);
op
->
SetAttr
(
"groups"
,
1
);
op
->
SetAttr
(
"padding_algorithm"
,
std
::
string
(
"EXPLICIT"
));
op
->
SetAttr
(
"data_format"
,
std
::
string
(
"NCHW"
));
op
->
SetAttr
(
"strides"
,
std
::
vector
<
int
>
({
1
,
1
}));
op
->
SetAttr
(
"dilations"
,
std
::
vector
<
int
>
({
1
,
1
}));
op
->
SetAttr
(
"paddings"
,
std
::
vector
<
int
>
({
0
,
0
}));
op
->
SetInput
(
"Input"
,
{
inputs
[
0
]});
op
->
SetInput
(
"Input"
,
{
inputs
[
0
]});
op
->
SetInput
(
"Filter"
,
{
inputs
[
1
]});
op
->
SetInput
(
"Filter"
,
{
inputs
[
1
]});
op
->
SetInput
(
"Bias"
,
{
inputs
[
2
]});
op
->
SetInput
(
"Bias"
,
{
inputs
[
2
]});
op
->
SetOutput
(
"Out"
,
outputs
);
op
->
SetOutput
(
"Out
put
"
,
outputs
);
}
}
// (a, weights, bias)->depthwise conv mkldnn->b
// (a, weights, bias)->depthwise conv mkldnn->b
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录