Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
9611e046
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9611e046
编写于
1月 16, 2020
作者:
H
huzhiqiang
提交者:
GitHub
1月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【BUG FIX】fix the bug that ocr model can not be loaded properly (#2757)
上级
d2fb7f8f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
23 deletion
+30
-23
lite/kernels/arm/write_to_array_compute.cc
lite/kernels/arm/write_to_array_compute.cc
+29
-20
lite/kernels/arm/write_to_array_compute.h
lite/kernels/arm/write_to_array_compute.h
+1
-3
未找到文件。
lite/kernels/arm/write_to_array_compute.cc
浏览文件 @
9611e046
...
...
@@ -20,28 +20,37 @@ namespace lite {
namespace
kernels
{
namespace
arm
{
void
WriteToArrayCompute
::
PrepareForRun
()
{}
void
WriteToArrayCompute
::
Run
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
param
=
this
->
Param
<
operators
::
WriteToArrayParam
>
();
auto
&
param
=
this
->
template
Param
<
operators
::
WriteToArrayParam
>();
CHECK_EQ
(
param
.
I
->
numel
(),
1
)
<<
"input2 should have only one element"
;
const
auto
*
x_data
=
param
.
X
->
data
<
float
>
();
int
id
=
param
.
I
->
data
<
float
>
()[
0
];
int
id_test
=
param
.
I
->
data
<
int64_t
>
()[
0
];
if
(
id
>=
param
.
Out
->
size
())
{
for
(
int
i
=
param
.
Out
->
size
();
i
<
id
+
1
;
i
++
)
{
lite
::
Tensor
tmp
;
param
.
Out
->
push_back
(
tmp
);
}
auto
precision_type
=
param
.
X
->
precision
();
#define SOLVE_TYPE(type__, T) \
case type__: { \
const auto* x_data = param.X->data<T>(); \
int id = param.I->data<int64_t>()[0]; \
if (id >= param.Out->size()) { \
for (int i = param.Out->size(); i < id + 1; i++) { \
lite::Tensor tmp; \
param.Out->push_back(tmp); \
} \
} \
(*param.Out)[id].Resize(param.X->dims()); \
auto out_lod = (*param.Out)[id].mutable_lod(); \
*out_lod = param.X->lod(); \
auto* o_data = (*param.Out)[id].mutable_data<T>(TARGET(kHost)); \
int input_size = param.X->numel(); \
memcpy(o_data, x_data, sizeof(T) * input_size); \
} break;
switch
(
precision_type
)
{
SOLVE_TYPE
(
PRECISION
(
kFloat
),
float
);
SOLVE_TYPE
(
PRECISION
(
kInt64
),
int64_t
);
default:
LOG
(
FATAL
)
<<
"Unsupported precision type."
;
}
(
*
param
.
Out
)[
id
].
Resize
(
param
.
X
->
dims
());
auto
out_lod
=
(
*
param
.
Out
)[
id
].
mutable_lod
();
*
out_lod
=
param
.
X
->
lod
();
auto
*
o_data
=
(
*
param
.
Out
)[
id
].
mutable_data
<
float
>
(
TARGET
(
kHost
));
int
input_size
=
param
.
X
->
numel
();
memcpy
(
o_data
,
x_data
,
sizeof
(
float
)
*
input_size
);
#undef SOLVE_TYPE
}
}
// namespace arm
...
...
@@ -51,11 +60,11 @@ void WriteToArrayCompute::Run() {
REGISTER_LITE_KERNEL
(
write_to_array
,
kARM
,
k
Float
,
k
Any
,
kNCHW
,
paddle
::
lite
::
kernels
::
arm
::
WriteToArrayCompute
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
)
,
PRECISION
(
kAny
)
)})
.
BindInput
(
"I"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorListTy
(
TARGET
(
kARM
))})
.
Finalize
();
lite/kernels/arm/write_to_array_compute.h
浏览文件 @
9611e046
...
...
@@ -23,12 +23,10 @@ namespace lite {
namespace
kernels
{
namespace
arm
{
class
WriteToArrayCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
k
Float
)
>
{
class
WriteToArrayCompute
:
public
KernelLite
<
TARGET
(
kARM
),
PRECISION
(
k
Any
)
>
{
public:
using
param_t
=
operators
::
WriteToArrayParam
;
void
PrepareForRun
()
override
;
void
Run
()
override
;
~
WriteToArrayCompute
()
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录