Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
3a04e11d
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看板
未验证
提交
3a04e11d
编写于
4月 17, 2020
作者:
Z
zhupengyang
提交者:
GitHub
4月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move read_from_array and write_to_array to host (#3428)
上级
b445941f
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
52 addition
and
54 deletion
+52
-54
lite/kernels/arm/CMakeLists.txt
lite/kernels/arm/CMakeLists.txt
+0
-2
lite/kernels/arm/beam_search_decode_compute.cc
lite/kernels/arm/beam_search_decode_compute.cc
+2
-2
lite/kernels/host/CMakeLists.txt
lite/kernels/host/CMakeLists.txt
+2
-0
lite/kernels/host/read_from_array_compute.cc
lite/kernels/host/read_from_array_compute.cc
+19
-12
lite/kernels/host/read_from_array_compute.h
lite/kernels/host/read_from_array_compute.h
+4
-7
lite/kernels/host/write_to_array_compute.cc
lite/kernels/host/write_to_array_compute.cc
+17
-11
lite/kernels/host/write_to_array_compute.h
lite/kernels/host/write_to_array_compute.h
+4
-5
lite/operators/read_from_array_op.cc
lite/operators/read_from_array_op.cc
+1
-6
lite/operators/write_to_array_op.cc
lite/operators/write_to_array_op.cc
+1
-7
lite/tests/kernels/read_from_array_compute_test.cc
lite/tests/kernels/read_from_array_compute_test.cc
+1
-1
lite/tests/kernels/write_to_array_compute_test.cc
lite/tests/kernels/write_to_array_compute_test.cc
+1
-1
未找到文件。
lite/kernels/arm/CMakeLists.txt
浏览文件 @
3a04e11d
...
@@ -92,8 +92,6 @@ add_kernel(sequence_softmax_compute_arm ARM extra SRCS sequence_softmax_compute.
...
@@ -92,8 +92,6 @@ add_kernel(sequence_softmax_compute_arm ARM extra SRCS sequence_softmax_compute.
add_kernel
(
while_compute_arm ARM extra SRCS while_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
while_compute_arm ARM extra SRCS while_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
topk_compute_arm ARM extra SRCS topk_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
topk_compute_arm ARM extra SRCS topk_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
increment_compute_arm ARM extra SRCS increment_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
increment_compute_arm ARM extra SRCS increment_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
write_to_array_compute_arm ARM extra SRCS write_to_array_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
read_from_array_compute_arm ARM extra SRCS read_from_array_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
beam_search_compute_arm ARM extra SRCS beam_search_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
beam_search_compute_arm ARM extra SRCS beam_search_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
fill_constant_compute_arm ARM basic SRCS fill_constant_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
fill_constant_compute_arm ARM basic SRCS fill_constant_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
fill_constant_batch_size_like_compute_arm ARM basic SRCS fill_constant_batch_size_like_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
add_kernel
(
fill_constant_batch_size_like_compute_arm ARM basic SRCS fill_constant_batch_size_like_compute.cc DEPS
${
lite_kernel_deps
}
math_arm
)
...
...
lite/kernels/arm/beam_search_decode_compute.cc
浏览文件 @
3a04e11d
...
@@ -114,14 +114,14 @@ struct BeamSearchDecoder {
...
@@ -114,14 +114,14 @@ struct BeamSearchDecoder {
lod
.
push_back
(
source_level_lod
);
lod
.
push_back
(
source_level_lod
);
lod
.
push_back
(
sentence_level_lod
);
lod
.
push_back
(
sentence_level_lod
);
*
(
id_tensor
->
mutable_lod
())
=
lod
;
id_tensor
->
set_lod
(
lod
)
;
id_tensor
->
Resize
({
static_cast
<
int64_t
>
(
id_data
.
size
())});
id_tensor
->
Resize
({
static_cast
<
int64_t
>
(
id_data
.
size
())});
auto
id_ptr
=
id_tensor
->
mutable_data
<
int64_t
>
();
auto
id_ptr
=
id_tensor
->
mutable_data
<
int64_t
>
();
TargetCopy
(
TargetCopy
(
TARGET
(
kARM
),
id_ptr
,
id_data
.
data
(),
id_data
.
size
()
*
sizeof
(
int64_t
));
TARGET
(
kARM
),
id_ptr
,
id_data
.
data
(),
id_data
.
size
()
*
sizeof
(
int64_t
));
*
(
score_tensor
->
mutable_lod
())
=
lod
;
score_tensor
->
set_lod
(
lod
)
;
score_tensor
->
Resize
({
static_cast
<
int64_t
>
(
score_data
.
size
())});
score_tensor
->
Resize
({
static_cast
<
int64_t
>
(
score_data
.
size
())});
auto
score_ptr
=
score_tensor
->
mutable_data
<
T
>
();
auto
score_ptr
=
score_tensor
->
mutable_data
<
T
>
();
TargetCopy
(
TARGET
(
kARM
),
TargetCopy
(
TARGET
(
kARM
),
...
...
lite/kernels/host/CMakeLists.txt
浏览文件 @
3a04e11d
...
@@ -10,3 +10,5 @@ add_kernel(crf_decoding_compute_host Host extra SRCS crf_decoding_compute.cc DEP
...
@@ -10,3 +10,5 @@ add_kernel(crf_decoding_compute_host Host extra SRCS crf_decoding_compute.cc DEP
add_kernel
(
compare_compute_host Host extra SRCS compare_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
compare_compute_host Host extra SRCS compare_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
logical_compute_host Host extra SRCS logical_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
logical_compute_host Host extra SRCS logical_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
ctc_align_compute_host Host extra SRCS ctc_align_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
ctc_align_compute_host Host extra SRCS ctc_align_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
write_to_array_compute_host Host extra SRCS write_to_array_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
read_from_array_compute_host Host extra SRCS read_from_array_compute.cc DEPS
${
lite_kernel_deps
}
)
lite/kernels/
arm
/read_from_array_compute.cc
→
lite/kernels/
host
/read_from_array_compute.cc
浏览文件 @
3a04e11d
...
@@ -12,17 +12,15 @@
...
@@ -12,17 +12,15 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "lite/kernels/arm/read_from_array_compute.h"
#include "lite/kernels/host/read_from_array_compute.h"
#include "lite/backends/arm/math/funcs.h"
namespace
paddle
{
namespace
paddle
{
namespace
lite
{
namespace
lite
{
namespace
kernels
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
void
ReadFromArrayCompute
::
Run
()
{
void
ReadFromArrayCompute
::
Run
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
param
=
this
->
Param
<
operators
::
ReadFromArrayParam
>
();
auto
&
param
=
this
->
Param
<
param_t
>
();
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"I should have only one element"
;
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"I should have only one element"
;
int
id
=
param
.
I
->
data
<
int64_t
>
()[
0
];
int
id
=
param
.
I
->
data
<
int64_t
>
()[
0
];
...
@@ -33,18 +31,27 @@ void ReadFromArrayCompute::Run() {
...
@@ -33,18 +31,27 @@ void ReadFromArrayCompute::Run() {
param
.
Out
->
CopyDataFrom
((
*
param
.
X
)[
id
]);
param
.
Out
->
CopyDataFrom
((
*
param
.
X
)[
id
]);
}
}
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace kernels
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
REGISTER_LITE_KERNEL
(
read_from_array
,
REGISTER_LITE_KERNEL
(
read_from_array
,
k
ARM
,
k
Host
,
kAny
,
kAny
,
k
NCHW
,
k
Any
,
paddle
::
lite
::
kernels
::
arm
::
ReadFromArrayCompute
,
paddle
::
lite
::
kernels
::
host
::
ReadFromArrayCompute
,
def
)
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"X"
,
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
{
LiteType
::
GetTensorListTy
(
TARGET
(
kHost
),
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
Finalize
();
.
Finalize
();
lite/kernels/
arm
/read_from_array_compute.h
→
lite/kernels/
host
/read_from_array_compute.h
浏览文件 @
3a04e11d
...
@@ -13,20 +13,17 @@
...
@@ -13,20 +13,17 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <stdint.h>
#include "lite/backends/arm/math/type_trans.h"
#include "lite/core/kernel.h"
#include "lite/core/kernel.h"
#include "lite/core/op_registry.h"
#include "lite/core/op_registry.h"
namespace
paddle
{
namespace
paddle
{
namespace
lite
{
namespace
lite
{
namespace
kernels
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
class
ReadFromArrayCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
kAny
)
>
{
class
ReadFromArrayCompute
:
public
KernelLite
<
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
)
>
{
public:
public:
using
param_t
=
operators
::
ReadFromArrayParam
;
void
Run
()
override
;
void
Run
()
override
;
~
ReadFromArrayCompute
()
{}
~
ReadFromArrayCompute
()
{}
...
@@ -34,7 +31,7 @@ class ReadFromArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
...
@@ -34,7 +31,7 @@ class ReadFromArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
private:
private:
};
};
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace kernels
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
lite/kernels/
arm
/write_to_array_compute.cc
→
lite/kernels/
host
/write_to_array_compute.cc
浏览文件 @
3a04e11d
...
@@ -12,16 +12,14 @@
...
@@ -12,16 +12,14 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "lite/kernels/arm/write_to_array_compute.h"
#include "lite/kernels/host/write_to_array_compute.h"
#include "lite/backends/arm/math/funcs.h"
namespace
paddle
{
namespace
paddle
{
namespace
lite
{
namespace
lite
{
namespace
kernels
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
void
WriteToArrayCompute
::
Run
()
{
void
WriteToArrayCompute
::
Run
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
param
=
this
->
template
Param
<
operators
::
WriteToArrayParam
>();
auto
&
param
=
this
->
template
Param
<
operators
::
WriteToArrayParam
>();
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"input2 should have only one element"
;
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"input2 should have only one element"
;
...
@@ -32,19 +30,27 @@ void WriteToArrayCompute::Run() {
...
@@ -32,19 +30,27 @@ void WriteToArrayCompute::Run() {
param
.
Out
->
at
(
id
).
CopyDataFrom
(
*
param
.
X
);
param
.
Out
->
at
(
id
).
CopyDataFrom
(
*
param
.
X
);
}
}
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace kernels
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
REGISTER_LITE_KERNEL
(
write_to_array
,
REGISTER_LITE_KERNEL
(
write_to_array
,
k
ARM
,
k
Host
,
kAny
,
kAny
,
k
NCHW
,
k
Any
,
paddle
::
lite
::
kernels
::
arm
::
WriteToArrayCompute
,
paddle
::
lite
::
kernels
::
host
::
WriteToArrayCompute
,
def
)
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"X"
,
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
))})
.
BindOutput
(
"Out"
,
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
{
LiteType
::
GetTensorListTy
(
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
Finalize
();
.
Finalize
();
lite/kernels/
arm
/write_to_array_compute.h
→
lite/kernels/
host
/write_to_array_compute.h
浏览文件 @
3a04e11d
...
@@ -13,17 +13,16 @@
...
@@ -13,17 +13,16 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <stdint.h>
#include "lite/backends/arm/math/type_trans.h"
#include "lite/core/kernel.h"
#include "lite/core/kernel.h"
#include "lite/core/op_registry.h"
#include "lite/core/op_registry.h"
namespace
paddle
{
namespace
paddle
{
namespace
lite
{
namespace
lite
{
namespace
kernels
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
class
WriteToArrayCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
kAny
)
>
{
class
WriteToArrayCompute
:
public
KernelLite
<
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
)
>
{
public:
public:
void
Run
()
override
;
void
Run
()
override
;
...
@@ -32,7 +31,7 @@ class WriteToArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
...
@@ -32,7 +31,7 @@ class WriteToArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
private:
private:
};
};
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace kernels
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
lite/operators/read_from_array_op.cc
浏览文件 @
3a04e11d
...
@@ -26,12 +26,7 @@ bool ReadFromArrayOp::CheckShape() const {
...
@@ -26,12 +26,7 @@ bool ReadFromArrayOp::CheckShape() const {
return
true
;
return
true
;
}
}
bool
ReadFromArrayOp
::
InferShapeImpl
()
const
{
bool
ReadFromArrayOp
::
InferShapeImpl
()
const
{
return
true
;
}
int
id
=
param_
.
I
->
data
<
int64_t
>
()[
0
];
auto
out_dims
=
(
*
param_
.
X
)[
id
].
dims
();
param_
.
Out
->
Resize
(
out_dims
);
return
true
;
}
bool
ReadFromArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
bool
ReadFromArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
lite
::
Scope
*
scope
)
{
lite
::
Scope
*
scope
)
{
...
...
lite/operators/write_to_array_op.cc
浏览文件 @
3a04e11d
...
@@ -26,13 +26,7 @@ bool WriteToArrayOp::CheckShape() const {
...
@@ -26,13 +26,7 @@ bool WriteToArrayOp::CheckShape() const {
return
true
;
return
true
;
}
}
bool
WriteToArrayOp
::
InferShapeImpl
()
const
{
bool
WriteToArrayOp
::
InferShapeImpl
()
const
{
return
true
;
}
int
id
=
param_
.
I
->
data
<
int64_t
>
()[
0
];
if
(
param_
.
Out
->
size
()
<
id
+
1
)
{
param_
.
Out
->
resize
(
id
+
1
);
}
return
true
;
}
bool
WriteToArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
lite
::
Scope
*
scope
)
{
bool
WriteToArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
lite
::
Scope
*
scope
)
{
auto
inputs
=
opdesc
.
Input
(
"X"
).
front
();
auto
inputs
=
opdesc
.
Input
(
"X"
).
front
();
...
...
lite/tests/kernels/read_from_array_compute_test.cc
浏览文件 @
3a04e11d
...
@@ -88,7 +88,7 @@ TEST(ReadFromArray, precision) {
...
@@ -88,7 +88,7 @@ TEST(ReadFromArray, precision) {
Place
place
;
Place
place
;
float
abs_error
=
1e-5
;
float
abs_error
=
1e-5
;
#ifdef LITE_WITH_ARM
#ifdef LITE_WITH_ARM
place
=
TARGET
(
k
ARM
);
place
=
TARGET
(
k
Host
);
#else
#else
return
;
return
;
#endif
#endif
...
...
lite/tests/kernels/write_to_array_compute_test.cc
浏览文件 @
3a04e11d
...
@@ -85,7 +85,7 @@ TEST(WriteToArray, precision) {
...
@@ -85,7 +85,7 @@ TEST(WriteToArray, precision) {
Place
place
;
Place
place
;
float
abs_error
=
1e-5
;
float
abs_error
=
1e-5
;
#ifdef LITE_WITH_ARM
#ifdef LITE_WITH_ARM
place
=
TARGET
(
k
ARM
);
place
=
TARGET
(
k
Host
);
#else
#else
return
;
return
;
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录