Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
4b5b5403
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看板
未验证
提交
4b5b5403
编写于
9月 25, 2020
作者:
H
huzhiqiang
提交者:
GitHub
9月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry-pick] [ARM] Add int64 implement for `gather` and `greater_than` (#4444)
上级
038c07f3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
15 deletion
+46
-15
lite/kernels/arm/gather_compute.cc
lite/kernels/arm/gather_compute.cc
+4
-4
lite/kernels/arm/gather_compute.h
lite/kernels/arm/gather_compute.h
+1
-1
lite/kernels/host/compare_compute.cc
lite/kernels/host/compare_compute.cc
+31
-0
lite/tests/kernels/gather_compute_test.cc
lite/tests/kernels/gather_compute_test.cc
+10
-10
未找到文件。
lite/kernels/arm/gather_compute.cc
浏览文件 @
4b5b5403
...
...
@@ -73,10 +73,10 @@ void GatherCompute<IndexType>::Run() {
REGISTER_LITE_KERNEL
(
gather
,
kARM
,
k
Any
,
k
Float
,
kNCHW
,
paddle
::
lite
::
kernels
::
arm
::
GatherCompute
<
int32_t
>
,
def
)
int32
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"Index"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
...
...
@@ -85,10 +85,10 @@ REGISTER_LITE_KERNEL(gather,
REGISTER_LITE_KERNEL
(
gather
,
kARM
,
k
Any
,
k
Float
,
kNCHW
,
paddle
::
lite
::
kernels
::
arm
::
GatherCompute
<
int64_t
>
,
def_int64_idx
)
int64
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"Index"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
...
...
lite/kernels/arm/gather_compute.h
浏览文件 @
4b5b5403
...
...
@@ -24,7 +24,7 @@ namespace kernels {
namespace
arm
{
template
<
typename
IndexType
>
class
GatherCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
k
Any
)
>
{
class
GatherCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
k
Float
)
>
{
public:
void
Run
()
override
;
...
...
lite/kernels/host/compare_compute.cc
浏览文件 @
4b5b5403
...
...
@@ -230,6 +230,21 @@ REGISTER_LITE_KERNEL(greater_than, kHost, kFloat, kAny, greater_than_float, def)
TARGET
(
kHost
),
PRECISION
(
kBool
),
DATALAYOUT
(
kAny
),
-
1
)})
.
Finalize
();
using
greater_than_int64
=
paddle
::
lite
::
kernels
::
host
::
CompareCompute
<
PRECISION
(
kInt64
),
paddle
::
lite
::
kernels
::
host
::
_GreaterThanFunctor
<
int64_t
>>
;
REGISTER_LITE_KERNEL
(
greater_than
,
kHost
,
kInt64
,
kAny
,
greater_than_int64
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
),
-
1
)})
.
BindInput
(
"Y"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
),
-
1
)})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kBool
),
DATALAYOUT
(
kAny
),
-
1
)})
.
Finalize
();
using
greater_equal_float
=
paddle
::
lite
::
kernels
::
host
::
CompareCompute
<
PRECISION
(
kFloat
),
paddle
::
lite
::
kernels
::
host
::
_GreaterEqualFunctor
<
float
>>
;
...
...
@@ -245,3 +260,19 @@ REGISTER_LITE_KERNEL(
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kBool
),
DATALAYOUT
(
kAny
),
-
1
)})
.
Finalize
();
using
greater_equal_int64
=
paddle
::
lite
::
kernels
::
host
::
CompareCompute
<
PRECISION
(
kInt64
),
paddle
::
lite
::
kernels
::
host
::
_GreaterEqualFunctor
<
int64_t
>>
;
REGISTER_LITE_KERNEL
(
greater_equal
,
kHost
,
kInt64
,
kAny
,
greater_equal_float
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
),
-
1
)})
.
BindInput
(
"Y"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
),
-
1
)})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kBool
),
DATALAYOUT
(
kAny
),
-
1
)})
.
Finalize
();
lite/tests/kernels/gather_compute_test.cc
浏览文件 @
4b5b5403
...
...
@@ -53,9 +53,9 @@ class GatherComputeTest : public arena::TestCase {
out_dims
[
0
]
=
batch_size
;
out
->
Resize
(
out_dims
);
auto
x_data
=
x
->
data
<
floa
t
>
();
auto
index_data
=
index
->
data
<
int
>
();
auto
out_data
=
out
->
mutable_data
<
floa
t
>
();
auto
x_data
=
x
->
data
<
int64_
t
>
();
auto
index_data
=
index
->
data
<
int
64_t
>
();
auto
out_data
=
out
->
mutable_data
<
int64_
t
>
();
auto
slice_num
=
x_dims
[
0
];
auto
slice_size
=
x_dims
.
Slice
(
1
,
x_dims
.
size
()).
production
();
...
...
@@ -66,7 +66,7 @@ class GatherComputeTest : public arena::TestCase {
CHECK_GE
(
index
,
0
)
<<
"gather ids[i] expected >= 0 but got "
<<
index
;
memcpy
(
out_data
+
i
*
slice_size
,
x_data
+
index
*
slice_size
,
slice_size
*
sizeof
(
floa
t
));
slice_size
*
sizeof
(
int64_
t
));
}
}
...
...
@@ -78,11 +78,11 @@ class GatherComputeTest : public arena::TestCase {
}
void
PrepareData
()
override
{
std
::
vector
<
floa
t
>
x
(
x_dims_
.
production
());
fill_data_rand
(
x
.
data
(),
-
1.
f
,
1.
f
,
x_dims_
.
production
());
std
::
vector
<
int64_
t
>
x
(
x_dims_
.
production
());
fill_data_rand
(
x
.
data
(),
int64_t
(
-
1
),
int64_t
(
1
)
,
x_dims_
.
production
());
std
::
vector
<
int
32
_t
>
index
(
index_dims_
.
production
());
fill_data_rand
<
int
32
_t
>
(
std
::
vector
<
int
64
_t
>
index
(
index_dims_
.
production
());
fill_data_rand
<
int
64
_t
>
(
index
.
data
(),
0
,
x_dims_
[
0
]
-
1
,
index_dims_
.
production
());
SetCommonTensor
(
x_
,
x_dims_
,
x
.
data
());
...
...
@@ -110,8 +110,8 @@ TEST(Gather, precision) {
for
(
auto
x_dims
:
std
::
vector
<
std
::
vector
<
int64_t
>>
{{
5
,
2
,
3
,
4
},
{
8
,
3
,
5
},
{
12
,
3
}})
{
for
(
auto
index_dims
:
std
::
vector
<
std
::
vector
<
int64_t
>>
{{
3
},
{
7
},
{
10
}})
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
GatherComputeTest
(
place
,
"def
"
,
DDim
(
x_dims
),
DDim
(
index_dims
)));
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
GatherComputeTest
(
place
,
"int64
"
,
DDim
(
x_dims
),
DDim
(
index_dims
)));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
abs_error
);
arena
.
TestPrecision
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录