Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
07104881
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
330
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
07104881
编写于
8月 06, 2020
作者:
Z
zhupengyang
提交者:
GitHub
8月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support int64 of slice, split; support cast: int64->int64, int32->int64 (#4048)
上级
8e76e305
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
92 addition
and
31 deletion
+92
-31
lite/backends/arm/math/slice.cc
lite/backends/arm/math/slice.cc
+9
-2
lite/backends/arm/math/split.cc
lite/backends/arm/math/split.cc
+17
-8
lite/kernels/arm/cast_compute.cc
lite/kernels/arm/cast_compute.cc
+6
-1
lite/kernels/arm/slice_compute.cc
lite/kernels/arm/slice_compute.cc
+36
-10
lite/kernels/arm/split_compute.cc
lite/kernels/arm/split_compute.cc
+20
-7
lite/kernels/arm/split_compute.h
lite/kernels/arm/split_compute.h
+2
-1
lite/kernels/arm/split_compute_test.cc
lite/kernels/arm/split_compute_test.cc
+2
-2
未找到文件。
lite/backends/arm/math/slice.cc
浏览文件 @
07104881
...
...
@@ -79,6 +79,13 @@ void slice(const Dtype* input,
}
}
template
void
slice
(
const
float
*
input
,
std
::
vector
<
int64_t
>
dims
,
std
::
vector
<
int
>
axes
,
std
::
vector
<
int
>
starts
,
std
::
vector
<
int
>
ends
,
float
*
out
,
Context
<
TARGET
(
kARM
)
>*
ctx
);
template
void
slice
(
const
int
*
input
,
std
::
vector
<
int64_t
>
dims
,
std
::
vector
<
int
>
axes
,
...
...
@@ -86,12 +93,12 @@ template void slice(const int* input,
std
::
vector
<
int
>
ends
,
int
*
out
,
Context
<
TARGET
(
kARM
)
>*
ctx
);
template
void
slice
(
const
floa
t
*
input
,
template
void
slice
(
const
int64_
t
*
input
,
std
::
vector
<
int64_t
>
dims
,
std
::
vector
<
int
>
axes
,
std
::
vector
<
int
>
starts
,
std
::
vector
<
int
>
ends
,
floa
t
*
out
,
int64_
t
*
out
,
Context
<
TARGET
(
kARM
)
>*
ctx
);
}
// namespace math
...
...
lite/backends/arm/math/split.cc
浏览文件 @
07104881
...
...
@@ -51,11 +51,11 @@ void split_cpy<float>(const float* din, float* dout, int num) {
}
}
template
<
>
void
split
<
float
>
(
const
float
*
din
,
const
std
::
vector
<
lite
::
Tensor
*>&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
)
{
template
<
typename
T
>
void
split
(
const
T
*
din
,
const
std
::
vector
<
lite
::
Tensor
*>&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
)
{
int
input_offset
=
0
;
for
(
auto
out
:
dout
)
{
auto
out_dim
=
out
->
dims
();
...
...
@@ -65,15 +65,15 @@ void split<float>(const float* din,
out_strides
[
i
]
=
out_strides
[
i
+
1
]
*
out_dim
[
i
];
}
float
*
out_data
=
out
->
mutable_data
<
float
>
();
T
*
out_data
=
out
->
mutable_data
<
T
>
();
int
before
=
out_strides
[
0
]
/
out_strides
[
axis
];
int
in_after
=
in_strides
[
axis
];
int
out_after
=
out_strides
[
axis
];
const
float
*
din_ptr
=
din
+
input_offset
;
const
T
*
din_ptr
=
din
+
input_offset
;
for
(
int
i
=
0
;
i
<
before
;
++
i
)
{
std
::
memcpy
(
out_data
,
din_ptr
,
sizeof
(
float
)
*
out_after
);
std
::
memcpy
(
out_data
,
din_ptr
,
sizeof
(
T
)
*
out_after
);
din_ptr
+=
in_after
;
out_data
+=
out_after
;
}
...
...
@@ -81,6 +81,15 @@ void split<float>(const float* din,
}
}
template
void
split
(
const
float
*
din
,
const
std
::
vector
<
lite
::
Tensor
*
>
&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
);
template
void
split
(
const
int64_t
*
din
,
const
std
::
vector
<
lite
::
Tensor
*
>
&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
);
}
// namespace math
}
// namespace arm
}
// namespace lite
...
...
lite/kernels/arm/cast_compute.cc
浏览文件 @
07104881
...
...
@@ -40,6 +40,11 @@ void CastCompute::Run() {
const
auto
*
x_data
=
param
.
X
->
data
<
float
>
();
auto
*
o_data
=
param
.
Out
->
mutable_data
<
float
>
();
memcpy
(
o_data
,
x_data
,
sizeof
(
float
)
*
param
.
X
->
numel
());
}
else
if
(
param
.
in_dtype
==
param
.
out_dtype
&&
param
.
in_dtype
==
3
)
{
// int64->int64
const
auto
*
x_data
=
param
.
X
->
data
<
int64_t
>
();
auto
*
o_data
=
param
.
Out
->
mutable_data
<
int64_t
>
();
memcpy
(
o_data
,
x_data
,
sizeof
(
int64_t
)
*
param
.
X
->
numel
());
}
else
if
(
param
.
in_dtype
==
21
&&
param
.
out_dtype
==
5
)
{
// int8->float32
const
char
*
x_data_begin
=
param
.
X
->
data
<
char
>
();
const
char
*
x_data_end
=
x_data_begin
+
param
.
X
->
numel
();
...
...
@@ -56,7 +61,7 @@ void CastCompute::Run() {
float
*
out_data
=
param
.
Out
->
mutable_data
<
float
>
();
std
::
transform
(
x_data_begin
,
x_data_end
,
out_data
,
TransOp
<
unsigned
char
,
float
>
);
}
else
if
(
param
.
in_dtype
==
3
&&
param
.
out_dtype
==
2
)
{
}
else
if
(
param
.
in_dtype
==
3
&&
param
.
out_dtype
==
2
)
{
// int64->int32
const
int64_t
*
x_data_begin
=
param
.
X
->
data
<
int64_t
>
();
const
int64_t
*
x_data_end
=
x_data_begin
+
param
.
X
->
numel
();
int32_t
*
out_data
=
param
.
Out
->
mutable_data
<
int32_t
>
();
...
...
lite/kernels/arm/slice_compute.cc
浏览文件 @
07104881
...
...
@@ -169,21 +169,47 @@ void SliceCompute<T, PType>::Run() {
using
slice_float
=
paddle
::
lite
::
kernels
::
arm
::
SliceCompute
<
float
,
PRECISION
(
kFloat
)
>
;
REGISTER_LITE_KERNEL
(
slice
,
kARM
,
kFloat
,
kNCHW
,
slice_float
,
def
)
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"StartsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"EndsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"StartsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"EndsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kFloat
))})
.
BindInput
(
"StartsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"StartsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kFloat
))})
.
Finalize
();
using
slice_int32
=
paddle
::
lite
::
kernels
::
arm
::
SliceCompute
<
int
,
PRECISION
(
kInt32
)
>
;
REGISTER_LITE_KERNEL
(
slice
,
kARM
,
kInt32
,
kNCHW
,
slice_int32
,
def
)
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"StartsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"EndsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"StartsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"EndsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"StartsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"StartsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
Finalize
();
using
slice_int64
=
paddle
::
lite
::
kernels
::
arm
::
SliceCompute
<
int64_t
,
PRECISION
(
kInt64
)
>
;
REGISTER_LITE_KERNEL
(
slice
,
kARM
,
kInt64
,
kNCHW
,
slice_int64
,
def
)
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindInput
(
"StartsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"StartsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"EndsTensorList"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
Finalize
();
lite/kernels/arm/split_compute.cc
浏览文件 @
07104881
...
...
@@ -21,9 +21,10 @@ namespace lite {
namespace
kernels
{
namespace
arm
{
void
SplitCompute
::
Run
()
{
auto
&
param
=
Param
<
operators
::
SplitParam
>
();
const
float
*
din
=
param
.
x
->
data
<
float
>
();
template
<
typename
T
,
PrecisionType
PType
>
void
SplitCompute
<
T
,
PType
>::
Run
()
{
auto
&
param
=
this
->
template
Param
<
operators
::
SplitParam
>();
const
T
*
din
=
param
.
x
->
template
data
<
T
>();
auto
&
dout
=
param
.
output
;
auto
in_dim
=
param
.
x
->
dims
();
std
::
vector
<
int
>
in_strides
(
in_dim
.
size
());
...
...
@@ -42,12 +43,24 @@ void SplitCompute::Run() {
}
// namespace lite
}
// namespace paddle
REGISTER_LITE_KERNEL
(
split
,
kARM
,
kFloat
,
kNCHW
,
paddle
::
lite
::
kernels
::
arm
::
SplitCompute
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
using
split_float
=
paddle
::
lite
::
kernels
::
arm
::
SplitCompute
<
float
,
PRECISION
(
kFloat
)
>
;
REGISTER_LITE_KERNEL
(
split
,
kARM
,
kFloat
,
kNCHW
,
split_float
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kFloat
))})
.
BindInput
(
"AxisTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"SectionsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kFloat
))})
.
Finalize
();
using
split_int64
=
paddle
::
lite
::
kernels
::
arm
::
SplitCompute
<
int64_t
,
PRECISION
(
kInt64
)
>
;
REGISTER_LITE_KERNEL
(
split
,
kARM
,
kInt64
,
kNCHW
,
split_int64
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindInput
(
"AxisTensor"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindInput
(
"SectionsTensorList"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
Finalize
();
lite/kernels/arm/split_compute.h
浏览文件 @
07104881
...
...
@@ -22,7 +22,8 @@ namespace lite {
namespace
kernels
{
namespace
arm
{
class
SplitCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
kFloat
)
>
{
template
<
typename
T
,
PrecisionType
PType
>
class
SplitCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PType
>
{
public:
void
Run
()
override
;
...
...
lite/kernels/arm/split_compute_test.cc
浏览文件 @
07104881
...
...
@@ -93,13 +93,13 @@ void split_compute_ref(const operators::SplitParam& param) {
}
TEST
(
split_arm
,
init
)
{
SplitCompute
split
;
SplitCompute
<
float
,
PRECISION
(
kFloat
)
>
split
;
ASSERT_EQ
(
split
.
precision
(),
PRECISION
(
kFloat
));
ASSERT_EQ
(
split
.
target
(),
TARGET
(
kARM
));
}
TEST
(
split_arm
,
compute
)
{
SplitCompute
split
;
SplitCompute
<
float
,
PRECISION
(
kFloat
)
>
split
;
operators
::
SplitParam
param
;
lite
::
Tensor
x
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录