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.
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
(
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
(
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
)
...
...
lite/kernels/arm/beam_search_decode_compute.cc
浏览文件 @
3a04e11d
...
...
@@ -114,14 +114,14 @@ struct BeamSearchDecoder {
lod
.
push_back
(
source_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
())});
auto
id_ptr
=
id_tensor
->
mutable_data
<
int64_t
>
();
TargetCopy
(
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
())});
auto
score_ptr
=
score_tensor
->
mutable_data
<
T
>
();
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
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
(
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 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "lite/kernels/arm/read_from_array_compute.h"
#include "lite/backends/arm/math/funcs.h"
#include "lite/kernels/host/read_from_array_compute.h"
namespace
paddle
{
namespace
lite
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
void
ReadFromArrayCompute
::
Run
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
param
=
this
->
Param
<
param_t
>
();
auto
&
param
=
this
->
Param
<
operators
::
ReadFromArrayParam
>
();
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"I should have only one element"
;
int
id
=
param
.
I
->
data
<
int64_t
>
()[
0
];
...
...
@@ -33,18 +31,27 @@ void ReadFromArrayCompute::Run() {
param
.
Out
->
CopyDataFrom
((
*
param
.
X
)[
id
]);
}
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace lite
}
// namespace paddle
REGISTER_LITE_KERNEL
(
read_from_array
,
k
ARM
,
k
Host
,
kAny
,
k
NCHW
,
paddle
::
lite
::
kernels
::
arm
::
ReadFromArrayCompute
,
k
Any
,
paddle
::
lite
::
kernels
::
host
::
ReadFromArrayCompute
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kHost
),
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
();
lite/kernels/
arm
/read_from_array_compute.h
→
lite/kernels/
host
/read_from_array_compute.h
浏览文件 @
3a04e11d
...
...
@@ -13,20 +13,17 @@
// limitations under the License.
#pragma once
#include <stdint.h>
#include "lite/backends/arm/math/type_trans.h"
#include "lite/core/kernel.h"
#include "lite/core/op_registry.h"
namespace
paddle
{
namespace
lite
{
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:
using
param_t
=
operators
::
ReadFromArrayParam
;
void
Run
()
override
;
~
ReadFromArrayCompute
()
{}
...
...
@@ -34,7 +31,7 @@ class ReadFromArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
private:
};
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace lite
}
// namespace paddle
lite/kernels/
arm
/write_to_array_compute.cc
→
lite/kernels/
host
/write_to_array_compute.cc
浏览文件 @
3a04e11d
...
...
@@ -12,16 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "lite/kernels/arm/write_to_array_compute.h"
#include "lite/backends/arm/math/funcs.h"
#include "lite/kernels/host/write_to_array_compute.h"
namespace
paddle
{
namespace
lite
{
namespace
kernels
{
namespace
arm
{
namespace
host
{
void
WriteToArrayCompute
::
Run
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
param
=
this
->
template
Param
<
operators
::
WriteToArrayParam
>();
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"input2 should have only one element"
;
...
...
@@ -32,19 +30,27 @@ void WriteToArrayCompute::Run() {
param
.
Out
->
at
(
id
).
CopyDataFrom
(
*
param
.
X
);
}
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace lite
}
// namespace paddle
REGISTER_LITE_KERNEL
(
write_to_array
,
k
ARM
,
k
Host
,
kAny
,
k
NCHW
,
paddle
::
lite
::
kernels
::
arm
::
WriteToArrayCompute
,
k
Any
,
paddle
::
lite
::
kernels
::
host
::
WriteToArrayCompute
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kHost
),
PRECISION
(
kInt64
),
DATALAYOUT
(
kAny
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
),
PRECISION
(
kAny
))})
{
LiteType
::
GetTensorListTy
(
TARGET
(
kHost
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
))})
.
Finalize
();
lite/kernels/
arm
/write_to_array_compute.h
→
lite/kernels/
host
/write_to_array_compute.h
浏览文件 @
3a04e11d
...
...
@@ -13,17 +13,16 @@
// limitations under the License.
#pragma once
#include <stdint.h>
#include "lite/backends/arm/math/type_trans.h"
#include "lite/core/kernel.h"
#include "lite/core/op_registry.h"
namespace
paddle
{
namespace
lite
{
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:
void
Run
()
override
;
...
...
@@ -32,7 +31,7 @@ class WriteToArrayCompute : public KernelLite<TARGET(kARM), PRECISION(kAny)> {
private:
};
}
// namespace
arm
}
// namespace
host
}
// namespace kernels
}
// namespace lite
}
// namespace paddle
lite/operators/read_from_array_op.cc
浏览文件 @
3a04e11d
...
...
@@ -26,12 +26,7 @@ bool ReadFromArrayOp::CheckShape() const {
return
true
;
}
bool
ReadFromArrayOp
::
InferShapeImpl
()
const
{
int
id
=
param_
.
I
->
data
<
int64_t
>
()[
0
];
auto
out_dims
=
(
*
param_
.
X
)[
id
].
dims
();
param_
.
Out
->
Resize
(
out_dims
);
return
true
;
}
bool
ReadFromArrayOp
::
InferShapeImpl
()
const
{
return
true
;
}
bool
ReadFromArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
lite
::
Scope
*
scope
)
{
...
...
lite/operators/write_to_array_op.cc
浏览文件 @
3a04e11d
...
...
@@ -26,13 +26,7 @@ bool WriteToArrayOp::CheckShape() const {
return
true
;
}
bool
WriteToArrayOp
::
InferShapeImpl
()
const
{
int
id
=
param_
.
I
->
data
<
int64_t
>
()[
0
];
if
(
param_
.
Out
->
size
()
<
id
+
1
)
{
param_
.
Out
->
resize
(
id
+
1
);
}
return
true
;
}
bool
WriteToArrayOp
::
InferShapeImpl
()
const
{
return
true
;
}
bool
WriteToArrayOp
::
AttachImpl
(
const
cpp
::
OpDesc
&
opdesc
,
lite
::
Scope
*
scope
)
{
auto
inputs
=
opdesc
.
Input
(
"X"
).
front
();
...
...
lite/tests/kernels/read_from_array_compute_test.cc
浏览文件 @
3a04e11d
...
...
@@ -88,7 +88,7 @@ TEST(ReadFromArray, precision) {
Place
place
;
float
abs_error
=
1e-5
;
#ifdef LITE_WITH_ARM
place
=
TARGET
(
k
ARM
);
place
=
TARGET
(
k
Host
);
#else
return
;
#endif
...
...
lite/tests/kernels/write_to_array_compute_test.cc
浏览文件 @
3a04e11d
...
...
@@ -85,7 +85,7 @@ TEST(WriteToArray, precision) {
Place
place
;
float
abs_error
=
1e-5
;
#ifdef LITE_WITH_ARM
place
=
TARGET
(
k
ARM
);
place
=
TARGET
(
k
Host
);
#else
return
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录