Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8cd52bd4
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看板
提交
8cd52bd4
编写于
4月 16, 2020
作者:
B
baolei.an
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LITE][BM] support adaptive pool2, test=develop
上级
300d7628
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
23 deletion
+50
-23
lite/kernels/bm/bridges/pool_op.cc
lite/kernels/bm/bridges/pool_op.cc
+50
-23
未找到文件。
lite/kernels/bm/bridges/pool_op.cc
浏览文件 @
8cd52bd4
...
...
@@ -11,7 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <bmcompiler_defs.h>
#include <bmcompiler_if.h>
#include <bmcompiler_if_lite.h>
#include <user_bmcpu_common.h>
#include "lite/kernels/bm/bridges/graph.h"
#include "lite/kernels/bm/bridges/utility.h"
#include "lite/kernels/npu/bridges/registry.h"
...
...
@@ -61,6 +64,7 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
auto
strides
=
op_info
->
GetAttr
<
std
::
vector
<
int
>>
(
"strides"
);
auto
global_pooling
=
op_info
->
GetAttr
<
bool
>
(
"global_pooling"
);
auto
ceil_mode
=
op_info
->
GetAttr
<
bool
>
(
"ceil_mode"
);
auto
adaptive
=
op_info
->
GetAttr
<
bool
>
(
"adaptive"
);
bool
average_exclusive
=
false
;
if
(
pooling_type
==
"avg"
)
{
average_exclusive
=
op_info
->
GetAttr
<
bool
>
(
"exclusive"
);
...
...
@@ -71,29 +75,52 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) {
ksize
[
0
]
=
i_x_shape_data
[
2
];
ksize
[
1
]
=
i_x_shape_data
[
3
];
}
add_pooling_layer
(
graph
->
GetCompilerHandle
(),
const_cast
<
const
int
*>
(
&
i_x_shape_data
[
0
]),
x_dims
.
size
(),
static_cast
<
const
char
*>
(
x_var_name
.
c_str
()),
1
,
shape
,
dim
,
name
,
ksize
[
0
],
ksize
[
1
],
paddings
[
0
],
paddings
[
0
],
paddings
[
1
],
paddings
[
1
],
strides
[
0
],
strides
[
1
],
(
ksize
[
0
]
>
1
&&
ksize
[
1
]
>
1
)
&&
pooling_type
==
"max"
?
0
:
1
,
static_cast
<
int
>
(
average_exclusive
),
static_cast
<
int
>
(
global_pooling
),
static_cast
<
int
>
(
ceil_mode
),
static_cast
<
const
char
*>
(
unique_op_name
.
c_str
()),
nullptr
);
bool
is_max
=
(
ksize
[
0
]
>
1
&&
ksize
[
1
]
>
1
)
&&
pooling_type
==
"max"
;
if
(
adaptive
)
{
user_cpu_param_t
bm_param
;
bm_param
.
op_type
=
USER_PADDLE_ADAPTIVE_POOL
;
bm_param
.
u
.
adaptive_pool_parm
.
is_avg
=
!
is_max
;
int32_t
*
in_shape
[
1
];
int32_t
in_dim
[
1
];
const
char
*
in_name
[
1
];
in_shape
[
0
]
=
&
i_x_shape_data
[
0
];
in_name
[
0
]
=
static_cast
<
const
char
*>
(
x_var_name
.
c_str
());
in_dim
[
0
]
=
x_dims
.
size
();
add_user_cpu_layer
(
graph
->
GetCompilerHandle
(),
1
,
in_shape
,
in_dim
,
in_name
,
1
,
shape
,
dim
,
name
,
&
bm_param
,
static_cast
<
int
>
(
sizeof
(
bm_param
)));
}
else
{
add_pooling_layer
(
graph
->
GetCompilerHandle
(),
const_cast
<
const
int
*>
(
&
i_x_shape_data
[
0
]),
x_dims
.
size
(),
static_cast
<
const
char
*>
(
x_var_name
.
c_str
()),
1
,
shape
,
dim
,
name
,
ksize
[
0
],
ksize
[
1
],
paddings
[
0
],
paddings
[
0
],
paddings
[
1
],
paddings
[
1
],
strides
[
0
],
strides
[
1
],
is_max
?
0
:
1
,
static_cast
<
int
>
(
average_exclusive
),
static_cast
<
int
>
(
global_pooling
),
static_cast
<
int
>
(
ceil_mode
),
static_cast
<
const
char
*>
(
unique_op_name
.
c_str
()),
nullptr
);
}
graph
->
AddNode
(
output_var_name
);
return
SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录