Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
12b9587b
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看板
未验证
提交
12b9587b
编写于
11月 04, 2020
作者:
L
lidanqing
提交者:
GitHub
11月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add conv_bias pass version python test (#28278)
* add conv_bias pass version test * update according to reviews
上级
0d25d55a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
26 deletion
+46
-26
paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.cc
...e/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.cc
+11
-4
python/paddle/fluid/tests/unittests/ir/inference/test_conv_bias_mkldnn_fuse_pass.py
...unittests/ir/inference/test_conv_bias_mkldnn_fuse_pass.py
+35
-22
未找到文件。
paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.cc
浏览文件 @
12b9587b
...
...
@@ -147,12 +147,19 @@ void ConvBiasFusePass::ApplyImpl(ir::Graph* graph) const {
}
// namespace paddle
REGISTER_PASS
(
conv_bias_mkldnn_fuse_pass
,
paddle
::
framework
::
ir
::
ConvBiasFusePass
);
REGISTER_PASS
(
conv_transpose_bias_mkldnn_fuse_pass
,
paddle
::
framework
::
ir
::
Conv2DTransposeBiasFusePass
);
REGISTER_PASS
(
conv3d_bias_mkldnn_fuse_pass
,
paddle
::
framework
::
ir
::
Conv3DBiasFusePass
);
REGISTER_PASS_CAPABILITY
(
conv_bias_mkldnn_fuse_pass
)
.
AddCombination
(
paddle
::
framework
::
compatible
::
OpVersionComparatorCombination
()
.
EQ
(
"conv2d"
,
0
)
.
EQ
(
"elementwise_add"
,
0
));
REGISTER_PASS
(
conv_transpose_bias_mkldnn_fuse_pass
,
paddle
::
framework
::
ir
::
Conv2DTransposeBiasFusePass
);
REGISTER_PASS_CAPABILITY
(
conv_transpose_bias_mkldnn_fuse_pass
)
.
AddCombination
(
paddle
::
framework
::
compatible
::
OpVersionComparatorCombination
()
.
EQ
(
"conv2d_transpose"
,
0
)
.
EQ
(
"elementwise_add"
,
0
));
REGISTER_PASS
(
conv3d_bias_mkldnn_fuse_pass
,
paddle
::
framework
::
ir
::
Conv3DBiasFusePass
);
python/paddle/fluid/tests/unittests/ir/inference/test_conv_bias_mkldnn_fuse_pass.py
浏览文件 @
12b9587b
...
...
@@ -20,11 +20,11 @@ from inference_pass_test import InferencePassTest
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
from
paddle.fluid.core
import
AnalysisConfig
"""Test for fusion of conv and bias."""
from
paddle.fluid.core
import
PassVersionChecker
#padding SAME
class
ConvBiasMkldnnFusePassTest
(
InferencePassTest
):
class
ConvBiasMkldnnFusePass
SamePad
Test
(
InferencePassTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
...
...
@@ -48,10 +48,12 @@ class ConvBiasMkldnnFusePassTest(InferencePassTest):
def
test_check_output
(
self
):
use_gpu
=
False
self
.
check_output_with_option
(
use_gpu
)
self
.
assertTrue
(
PassVersionChecker
.
IsCompatible
(
"conv_bias_mkldnn_fuse_pass"
))
#padding VALID
class
ConvBiasMkldnnFusePass
Test1
(
InferencePass
Test
):
class
ConvBiasMkldnnFusePass
ValidPadTest
(
ConvBiasMkldnnFusePassSamePad
Test
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
...
...
@@ -72,13 +74,9 @@ class ConvBiasMkldnnFusePassTest1(InferencePassTest):
self
.
fetch_list
=
[
conv_out
]
self
.
enable_mkldnn
=
True
def
test_check_output
(
self
):
use_gpu
=
False
self
.
check_output_with_option
(
use_gpu
)
#padding
number
class
ConvBiasMkldnnFusePass
Test2
(
InferencePass
Test
):
#padding
EXPLICT NUMBER
class
ConvBiasMkldnnFusePass
ExplictPadTest
(
ConvBiasMkldnnFusePassSamePad
Test
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
...
...
@@ -99,13 +97,8 @@ class ConvBiasMkldnnFusePassTest2(InferencePassTest):
self
.
fetch_list
=
[
conv_out
]
self
.
enable_mkldnn
=
True
def
test_check_output
(
self
):
use_gpu
=
False
self
.
check_output_with_option
(
use_gpu
)
#dilation not supported yet, just print warning log and does not fuse
class
ConvBiasMkldnnFusePassTest3
(
InferencePassTest
):
class
ConvBiasMkldnnFusePassGroupTest
(
ConvBiasMkldnnFusePassSamePadTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
...
...
@@ -118,7 +111,6 @@ class ConvBiasMkldnnFusePassTest3(InferencePassTest):
num_filters
=
3
,
filter_size
=
3
,
padding
=
"VALID"
,
dilation
=
2
,
groups
=
3
,
bias_attr
=
param_attr
,
use_cudnn
=
False
,
...
...
@@ -131,13 +123,9 @@ class ConvBiasMkldnnFusePassTest3(InferencePassTest):
self
.
fetch_list
=
[
conv_out
]
self
.
enable_mkldnn
=
True
def
test_check_output
(
self
):
use_gpu
=
False
self
.
check_output_with_option
(
use_gpu
)
#all conv params except for dilation
class
ConvBiasMkldnnFusePassTest4
(
InferencePassTest
):
class
ConvBiasMkldnnFusePassDialtionsGroupsTest
(
ConvBiasMkldnnFusePassSamePadTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
...
...
@@ -150,6 +138,7 @@ class ConvBiasMkldnnFusePassTest4(InferencePassTest):
num_filters
=
3
,
filter_size
=
3
,
padding
=
"VALID"
,
dilation
=
2
,
groups
=
3
,
bias_attr
=
param_attr
,
use_cudnn
=
False
,
...
...
@@ -162,9 +151,33 @@ class ConvBiasMkldnnFusePassTest4(InferencePassTest):
self
.
fetch_list
=
[
conv_out
]
self
.
enable_mkldnn
=
True
class
ConvTransposeMkldnnFusePassDialtionsGroupsTest
(
InferencePassTest
):
def
setUp
(
self
):
with
fluid
.
program_guard
(
self
.
main_program
,
self
.
startup_program
):
data
=
fluid
.
data
(
name
=
"data"
,
shape
=
[
-
1
,
3
,
5
,
5
],
dtype
=
"float32"
)
param_attr
=
fluid
.
ParamAttr
(
initializer
=
fluid
.
initializer
.
Xavier
(
uniform
=
False
),
learning_rate
=
0.001
)
conv_out
=
fluid
.
layers
.
conv2d_transpose
(
input
=
data
,
num_filters
=
3
,
filter_size
=
3
,
padding
=
"SAME"
,
dilation
=
1
,
bias_attr
=
param_attr
,
use_cudnn
=
False
)
self
.
feeds
=
{
"data"
:
np
.
random
.
random
((
1
,
3
,
5
,
5
)).
astype
(
"float32"
)}
self
.
fetch_list
=
[
conv_out
]
self
.
enable_mkldnn
=
True
def
test_check_output
(
self
):
use_gpu
=
False
self
.
check_output_with_option
(
use_gpu
)
self
.
assertTrue
(
PassVersionChecker
.
IsCompatible
(
"conv_transpose_bias_mkldnn_fuse_pass"
))
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录