Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
18709770
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
18709770
编写于
4月 28, 2020
作者:
H
HappyAngel
提交者:
GitHub
4月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BUG FIX][Pass]fix depthwise deconv+bn fusion (#3480) (#3519)
*fix depthwise deconv+bn fusion
上级
717c176d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
6 addition
and
3 deletion
+6
-3
lite/core/mir/fusion/conv_bn_fuser.cc
lite/core/mir/fusion/conv_bn_fuser.cc
+6
-3
未找到文件。
lite/core/mir/fusion/conv_bn_fuser.cc
浏览文件 @
18709770
...
@@ -103,9 +103,12 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
...
@@ -103,9 +103,12 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
std
::
string
conv_weight_name
=
matched
.
at
(
"conv_weight"
)
->
arg
()
->
name
;
std
::
string
conv_weight_name
=
matched
.
at
(
"conv_weight"
)
->
arg
()
->
name
;
auto
conv_weight_t
=
auto
conv_weight_t
=
scope
->
FindVar
(
conv_weight_name
)
->
GetMutable
<
lite
::
Tensor
>
();
scope
->
FindVar
(
conv_weight_name
)
->
GetMutable
<
lite
::
Tensor
>
();
auto
groups
=
conv_op_desc
->
GetAttr
<
int
>
(
"groups"
);
bool
depthwise
=
false
;
if
(
conv_type_
==
"conv2d_transpose"
)
{
if
(
conv_type_
==
"conv2d_transpose"
)
{
depthwise
=
(
conv_weight_t
->
dims
()[
0
]
==
conv_weight_t
->
dims
()[
1
]
*
groups
);
CHECK_EQ
(
static_cast
<
size_t
>
(
bn_scale_t
->
data_size
()),
CHECK_EQ
(
static_cast
<
size_t
>
(
bn_scale_t
->
data_size
()),
static_cast
<
size_t
>
(
conv_weight_t
->
dims
()[
1
]))
static_cast
<
size_t
>
(
conv_weight_t
->
dims
()[
1
]
*
groups
))
<<
"The BN bias's size should be equal to the size of the first "
<<
"The BN bias's size should be equal to the size of the first "
<<
"dim size of the conv weights"
;
<<
"dim size of the conv weights"
;
}
else
{
}
else
{
...
@@ -159,7 +162,7 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
...
@@ -159,7 +162,7 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
// compute new conv_weight for int8
// compute new conv_weight for int8
auto
weight_scale
=
auto
weight_scale
=
conv_op_desc
->
GetAttr
<
std
::
vector
<
float
>>
(
"weight_scale"
);
conv_op_desc
->
GetAttr
<
std
::
vector
<
float
>>
(
"weight_scale"
);
if
(
conv_type_
==
"conv2d_transpose"
)
{
if
(
conv_type_
==
"conv2d_transpose"
&&
!
depthwise
)
{
int
c_size
=
conv_weight_t
->
dims
()[
1
]
*
conv_weight_t
->
dims
()[
2
]
*
int
c_size
=
conv_weight_t
->
dims
()[
1
]
*
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
conv_weight_t
->
dims
()[
3
];
int
hw
=
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
int
hw
=
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
...
@@ -199,7 +202,7 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
...
@@ -199,7 +202,7 @@ void ConvBNFuser::InsertNewNode(SSAGraph* graph, const key2nodes_t& matched) {
}
else
{
}
else
{
// compute new conv_weight
// compute new conv_weight
auto
conv_weight_d
=
conv_weight_t
->
mutable_data
<
float
>
();
auto
conv_weight_d
=
conv_weight_t
->
mutable_data
<
float
>
();
if
(
conv_type_
==
"conv2d_transpose"
)
{
if
(
conv_type_
==
"conv2d_transpose"
&&
!
depthwise
)
{
int
c_size
=
conv_weight_t
->
dims
()[
1
]
*
conv_weight_t
->
dims
()[
2
]
*
int
c_size
=
conv_weight_t
->
dims
()[
1
]
*
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
conv_weight_t
->
dims
()[
3
];
int
hw
=
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
int
hw
=
conv_weight_t
->
dims
()[
2
]
*
conv_weight_t
->
dims
()[
3
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录