Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0b2dad2b
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
0b2dad2b
编写于
4月 13, 2020
作者:
D
dingminghui
提交者:
jackzhang235
4月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(pool): fix pool op wrong calculation in yolov3 and enable more
testcase
上级
789112e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
76 deletion
+59
-76
lite/kernels/mlu/bridges/pool_op.cc
lite/kernels/mlu/bridges/pool_op.cc
+15
-22
lite/kernels/mlu/bridges/pool_op_test.cc
lite/kernels/mlu/bridges/pool_op_test.cc
+44
-54
未找到文件。
lite/kernels/mlu/bridges/pool_op.cc
浏览文件 @
0b2dad2b
...
...
@@ -62,8 +62,6 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
paddings
.
insert
(
paddings
.
begin
()
+
2
*
i
+
1
,
copy_pad
);
}
}
int
pad_height
=
paddings
[
0
];
int
pad_width
=
paddings
[
2
];
std
::
string
padding_algorithm
(
""
);
if
(
op_info
->
HasAttr
(
"padding_algorithm"
))
{
padding_algorithm
=
op_info
->
GetAttr
<
std
::
string
>
(
"padding_algorithm"
);
...
...
@@ -73,12 +71,7 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
adaptive
=
op_info
->
GetAttr
<
bool
>
(
"adaptive"
);
}
auto
input_dims
=
x
->
dims
();
if
(
global_pooling
)
{
ksize
.
resize
(
static_cast
<
size_t
>
(
input_dims
.
size
())
-
2
);
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
ksize
[
i
]
=
static_cast
<
int
>
(
input_dims
[
i
+
2
]);
}
}
lite
::
operators
::
UpdatePadding
(
&
paddings
,
global_pooling
,
adaptive
,
...
...
@@ -87,31 +80,31 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
strides
,
ksize
);
// std::vector<int64_t> output_shape({input_dims[0], input_dims[1]});
// for (size_t i = 0; i < 2; i++) {
// output_shape.push_back(
// (input_dims[i + 2] + paddings[2 * i] + paddings[2 * i + 1] -
// ksize[0]) /
// strides[i] +
// 1);
// }
if
(
global_pooling
)
{
ksize
.
resize
(
static_cast
<
size_t
>
(
input_dims
.
size
())
-
2
);
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
ksize
[
i
]
=
static_cast
<
int
>
(
input_dims
[
i
+
2
]);
}
}
auto
output_tensor
=
graph
->
AddNode
(
output_var_name
,
output_shape
,
CNML_TENSOR
,
CNML_NCHW
,
graph
->
FPType
());
cnmlPoolOpParam_t
pool_param
;
CNML_CALL
(
cnmlCreatePoolOpParam_V
2
(
&
pool_param
,
cnmlCreatePoolOpParam_V
3
(
&
pool_param
,
ksize
[
0
],
ksize
[
1
],
strides
[
0
],
strides
[
1
],
pad_height
,
pad_width
,
1
,
// dilation
1
,
paddings
[
0
],
paddings
[
1
],
paddings
[
2
],
paddings
[
3
],
1
,
// dilation h
1
,
// dilation w
ToCnmlPoolMode
(
pooling_type
),
ceil_mode
?
CNML_POOL_K
VALID
:
CNML_POOL_KFULL
,
ceil_mode
?
CNML_POOL_K
FULL
:
CNML_POOL_KVALID
,
true
,
/* real */
1
/* blend factor */
));
cnmlBaseOp_t
pool_op
;
...
...
lite/kernels/mlu/bridges/pool_op_test.cc
浏览文件 @
0b2dad2b
...
...
@@ -43,6 +43,12 @@ void pool_ref(const std::shared_ptr<operators::PoolOpLite> op) {
std
::
string
pooling_type
=
op_info
->
GetAttr
<
std
::
string
>
(
"pooling_type"
);
bool
global_pooling
=
op_info
->
GetAttr
<
bool
>
(
"global_pooling"
);
if
(
pooling_type
==
"max"
)
{
for
(
int
i
=
0
;
i
<
out_dims
.
production
();
++
i
)
{
dst_ptr
[
i
]
=
-
65504.
f
;
}
}
int
in_n
=
in_dims
[
0
];
int
in_c
=
in_dims
[
1
];
int
in_h
=
in_dims
[
2
];
...
...
@@ -203,62 +209,46 @@ void test_pool(int bs,
}
TEST
(
MLUBridges
,
pool
)
{
// for (auto pooling_type : {"max", "avg"}) {
// for (auto ceil_mode : {true, false}) {
// for (auto global_pooling : {/*true, */ false}) {
// for (auto exclusive : {true /*, false*/}) {
// for (auto ksize : {2, 3}) {
// for (auto stride : {1, 2}) {
// for (auto padding : {0, 1}) {
// for (auto bs : {1, 3}) {
// for (auto ic : {1, 3}) {
// for (auto ih : {3, 7}) {
// for (auto iw : {3, 7}) {
// test_pool(bs,
// ic,
// ih,
// iw,
// pooling_type,
// ceil_mode,
// global_pooling,
// exclusive,
// ksize,
// stride,
// padding);
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
// }
for
(
auto
pooling_type
:
{
"max"
,
"avg"
})
{
for
(
auto
ceil_mode
:
{
true
,
false
})
{
bool
global_pooling
=
false
;
bool
exclusive
=
true
;
int
ksize
=
2
;
int
stride
=
1
;
int
padding
=
0
;
int
bs
=
6
;
int
ic
=
6
;
int
ih
=
6
;
int
iw
=
6
;
test_pool
(
bs
,
ic
,
ih
,
iw
,
pooling_type
,
ceil_mode
,
global_pooling
,
exclusive
,
ksize
,
stride
,
padding
);
for
(
auto
global_pooling
:
{
true
,
false
})
{
for
(
auto
exclusive
:
{
true
/*, false*/
})
{
for
(
auto
ksize
:
{
2
,
3
})
{
for
(
auto
stride
:
{
1
,
2
})
{
for
(
auto
padding
:
{
0
,
1
})
{
for
(
auto
bs
:
{
1
,
3
})
{
for
(
auto
ic
:
{
1
,
3
})
{
for
(
auto
ih
:
{
3
,
7
})
{
for
(
auto
iw
:
{
3
,
7
})
{
LOG
(
INFO
)
<<
"shape: "
<<
bs
<<
','
<<
ic
<<
','
<<
ih
<<
','
<<
iw
<<
'\t'
<<
"pooling type: "
<<
pooling_type
<<
'\t'
<<
"ceil model: "
<<
ceil_mode
<<
'\t'
<<
"global_pooling: "
<<
global_pooling
<<
'\t'
<<
"exclusive: "
<<
exclusive
<<
'\t'
<<
"ksize: "
<<
ksize
<<
'\t'
<<
"stride: "
<<
stride
<<
'\t'
<<
"padding: "
<<
padding
;
test_pool
(
bs
,
ic
,
ih
,
iw
,
pooling_type
,
ceil_mode
,
global_pooling
,
exclusive
,
ksize
,
stride
,
padding
);
}
}
}
}
}
}
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录