Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
b22b8c47
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看板
提交
b22b8c47
编写于
7月 19, 2019
作者:
Z
zp7
提交者:
Yanzhan Yang
7月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add slice cpu op (#1759)
* add slice cpu op * print error var name && print op position
上级
33521991
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
7 deletion
+59
-7
src/framework/executor.cpp
src/framework/executor.cpp
+4
-2
src/framework/program/program_desc.cpp
src/framework/program/program_desc.cpp
+1
-1
src/operators/kernel/arm/slice_kernel.cpp
src/operators/kernel/arm/slice_kernel.cpp
+43
-1
src/operators/slice_op.cpp
src/operators/slice_op.cpp
+8
-1
tools/python/fluidtools/run.py
tools/python/fluidtools/run.py
+3
-2
未找到文件。
src/framework/executor.cpp
浏览文件 @
b22b8c47
...
...
@@ -474,12 +474,14 @@ PMStatus Executor<Device, T>::Predict() {
struct
timespec
ts
;
int
op_index
=
0
;
#endif
for
(
auto
&
op_handler
:
ops_of_block0_
)
{
for
(
int
i
=
0
;
i
<
ops_of_block0_
.
size
();
++
i
)
{
auto
&
op_handler
=
ops_of_block0_
[
i
];
#ifdef PADDLE_MOBILE_PROFILE
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
profile
[
op_index
].
runBegin
=
(
uint64_t
)
ts
.
tv_sec
*
1e9
+
ts
.
tv_nsec
;
#endif
DLOG
<<
"run op: "
<<
op_handler
->
Type
();
DLOG
<<
i
<<
"th, "
<<
"run op: "
<<
op_handler
->
Type
();
if
(
lod_mode_
&&
input_dim_has_changed_
)
{
op_handler
->
InferShape
();
}
...
...
src/framework/program/program_desc.cpp
浏览文件 @
b22b8c47
...
...
@@ -58,7 +58,7 @@ void ProgramDesc::Description(std::string header) const {
LOG
(
kLOG_INFO
)
<<
"block ops size: "
<<
block
->
Ops
().
size
();
for
(
int
j
=
0
;
j
<
block
->
Ops
().
size
();
++
j
)
{
auto
op
=
block
->
Ops
()[
j
];
LOG
(
kLOG_DEBUG1
)
<<
"
op: "
<<
op
->
Type
();
LOG
(
kLOG_DEBUG1
)
<<
j
<<
"th,
op: "
<<
op
->
Type
();
for
(
auto
&
input
:
op
->
GetInputs
())
{
LOG
(
kLOG_DEBUG2
)
<<
"input parameter: "
<<
input
.
first
;
for
(
auto
&
n
:
input
.
second
)
{
...
...
src/operators/kernel/arm/slice_kernel.cpp
浏览文件 @
b22b8c47
...
...
@@ -19,12 +19,54 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
void
SliceCompute
(
const
SliceParam
<
CPU
>&
param
)
{
auto
input
=
param
.
input_
;
auto
output
=
param
.
output_
;
auto
*
input_ptr
=
input
->
data
<
float
>
();
auto
*
output_ptr
=
output
->
mutable_data
<
float
>
();
auto
out_dims
=
output
->
dims
();
auto
in_dims
=
input
->
dims
();
auto
starts
=
param
.
starts_
;
auto
ends
=
param
.
ends_
;
int
axes
=
param
.
axes_
[
0
];
int
HW
=
input
->
dims
()[
axes
+
1
]
*
input
->
dims
()[
axes
+
2
];
int
batch_size
=
out_dims
[
axes
-
1
];
int
input_channel
=
in_dims
[
axes
];
int
output_channel
=
out_dims
[
axes
];
for
(
int
c1
=
0
;
c1
<
batch_size
;
++
c1
)
{
for
(
int
c2
=
starts
[
0
],
c3
=
0
;
c2
<
ends
[
0
];
++
c2
,
++
c3
)
{
size_t
out_offset
=
c1
*
output_channel
*
HW
+
c3
*
HW
;
size_t
in_offset
=
c1
*
input_channel
*
HW
+
c2
*
HW
;
memcpy
(
output_ptr
+
out_offset
,
input_ptr
+
in_offset
,
HW
*
sizeof
(
float
));
}
}
}
template
<
>
bool
SliceKernel
<
CPU
,
float
>::
Init
(
SliceParam
<
CPU
>*
param
)
{
return
true
;
}
template
<
>
void
SliceKernel
<
CPU
,
float
>::
Compute
(
const
SliceParam
<
CPU
>&
param
)
{}
void
SliceKernel
<
CPU
,
float
>::
Compute
(
const
SliceParam
<
CPU
>&
param
)
{
int
rank
=
param
.
input_
->
dims
().
size
();
switch
(
rank
)
{
case
4
:
SliceCompute
(
param
);
break
;
case
5
:
if
(
param
.
input_
->
dims
()[
0
]
==
1
)
{
SliceCompute
(
param
);
}
break
;
default:
PADDLE_MOBILE_ENFORCE
(
0
,
"input dims not support now"
);
break
;
}
}
}
// namespace operators
}
// namespace paddle_mobile
#endif
src/operators/slice_op.cpp
浏览文件 @
b22b8c47
...
...
@@ -21,7 +21,14 @@ namespace operators {
template
<
typename
Dtype
,
typename
T
>
void
SliceOp
<
Dtype
,
T
>::
InferShape
()
const
{
/// todo: add InputShape() detection.
auto
axes
=
this
->
param_
.
axes_
;
auto
input
=
this
->
param_
.
input_
;
auto
output
=
this
->
param_
.
output_
;
PADDLE_MOBILE_ENFORCE
(
axes
.
size
()
==
1
,
"axes size should equals 1"
);
PADDLE_MOBILE_ENFORCE
(
input
->
dims
().
size
()
==
output
->
dims
().
size
(),
"input dim size should equals output dim size"
);
PADDLE_MOBILE_ENFORCE
(
input
->
dims
().
size
()
-
axes
[
0
]
==
3
,
"op only support slice channel now"
);
}
}
// namespace operators
...
...
tools/python/fluidtools/run.py
浏览文件 @
b22b8c47
...
...
@@ -368,10 +368,11 @@ def check_mobile_results(args, fuse, mem_opt):
error_values1
=
np
.
array
(
error_values1
)
error_values2
=
np
.
array
(
error_values2
)
# pp_red("mobile op is not correct, error occurs at {}th op, op's type is {}")
pp_red
(
"corresponding fluid op is {}th op, op's type is {}"
.
format
(
error_index
,
op_cache
[
error_index
][
1
].
type
),
1
)
pp_red
(
"corresponding fluid op is {}th op, op's type is {}, wrong var name is {}"
.
format
(
error_index
,
op_cache
[
error_index
][
1
].
type
,
op_output_var_name
),
1
)
pp_red
(
"fluid results are : "
,
1
)
pp_red
(
str
(
error_values1
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
pp_
red
(
"paddle mobile results are : "
,
1
)
pp_
yellow
(
"paddle mobile results are : "
,
1
)
pp_red
(
str
(
error_values2
).
replace
(
"
\n
"
,
"
\n
"
+
"
\t
"
*
1
),
1
)
# print(output_var_cache)
# print(mobile_var_cache)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录