Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
231da325
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看板
提交
231da325
编写于
8月 26, 2019
作者:
S
sangoly
提交者:
Yan Chunwei
8月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Navie buffer] make load/save be compatible with 32 and 64 arch test=develop (#1858)
上级
0d56d6fe
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
15 addition
and
15 deletion
+15
-15
lite/model_parser/naive_buffer/naive_buffer.cc
lite/model_parser/naive_buffer/naive_buffer.cc
+7
-7
lite/model_parser/naive_buffer/naive_buffer.h
lite/model_parser/naive_buffer/naive_buffer.h
+8
-8
未找到文件。
lite/model_parser/naive_buffer/naive_buffer.cc
浏览文件 @
231da325
...
@@ -68,13 +68,13 @@ void BinaryTable::LoadFromFile(const std::string &filename) {
...
@@ -68,13 +68,13 @@ void BinaryTable::LoadFromFile(const std::string &filename) {
void
StringBuilder
::
Save
()
{
void
StringBuilder
::
Save
()
{
// memory format: [size][string data]
// memory format: [size][string data]
size_t
mem_size
=
sizeof
(
size
_t
)
+
data_
.
size
();
uint64_t
mem_size
=
sizeof
(
uint64
_t
)
+
data_
.
size
();
table
()
->
Require
(
mem_size
);
table
()
->
Require
(
mem_size
);
size
_t
str_len
=
data_
.
size
();
uint64
_t
str_len
=
data_
.
size
();
// write meta data of size.
// write meta data of size.
memcpy
(
table
()
->
cursor
(),
&
str_len
,
sizeof
(
size
_t
));
memcpy
(
table
()
->
cursor
(),
&
str_len
,
sizeof
(
uint64
_t
));
table
()
->
Consume
(
sizeof
(
size
_t
));
table
()
->
Consume
(
sizeof
(
uint64
_t
));
// write the string data.
// write the string data.
memcpy
(
table
()
->
cursor
(),
memcpy
(
table
()
->
cursor
(),
...
@@ -85,9 +85,9 @@ void StringBuilder::Save() {
...
@@ -85,9 +85,9 @@ void StringBuilder::Save() {
void
StringBuilder
::
Load
()
{
void
StringBuilder
::
Load
()
{
// load meta data of size
// load meta data of size
size
_t
str_len
{};
uint64
_t
str_len
{};
memcpy
(
&
str_len
,
table
()
->
cursor
(),
sizeof
(
size
_t
));
memcpy
(
&
str_len
,
table
()
->
cursor
(),
sizeof
(
uint64
_t
));
table
()
->
Consume
(
sizeof
(
size
_t
));
table
()
->
Consume
(
sizeof
(
uint64
_t
));
// load string data.
// load string data.
data_
.
resize
(
str_len
);
data_
.
resize
(
str_len
);
...
...
lite/model_parser/naive_buffer/naive_buffer.h
浏览文件 @
231da325
...
@@ -303,10 +303,10 @@ class ListBuilder : public FieldBuilder {
...
@@ -303,10 +303,10 @@ class ListBuilder : public FieldBuilder {
template
<
typename
Builder
>
template
<
typename
Builder
>
void
ListBuilder
<
Builder
>::
Save
()
{
void
ListBuilder
<
Builder
>::
Save
()
{
// store number of elements in the head.
// store number of elements in the head.
size
_t
num_elems
=
size
();
uint64
_t
num_elems
=
size
();
table
()
->
Require
(
sizeof
(
size
_t
));
table
()
->
Require
(
sizeof
(
uint64
_t
));
memcpy
(
table
()
->
cursor
(),
&
num_elems
,
sizeof
(
size
_t
));
memcpy
(
table
()
->
cursor
(),
&
num_elems
,
sizeof
(
uint64
_t
));
table
()
->
Consume
(
sizeof
(
size
_t
));
table
()
->
Consume
(
sizeof
(
uint64
_t
));
// Save all the elements.
// Save all the elements.
for
(
auto
&
elem
:
builders_
)
{
for
(
auto
&
elem
:
builders_
)
{
...
@@ -318,12 +318,12 @@ template <typename Builder>
...
@@ -318,12 +318,12 @@ template <typename Builder>
void
ListBuilder
<
Builder
>::
Load
()
{
void
ListBuilder
<
Builder
>::
Load
()
{
CHECK
(
builders_
.
empty
())
<<
"Duplicate load"
;
CHECK
(
builders_
.
empty
())
<<
"Duplicate load"
;
// Load number of elements first.
// Load number of elements first.
size
_t
num_elems
{};
uint64
_t
num_elems
{};
memcpy
(
&
num_elems
,
table
()
->
cursor
(),
sizeof
(
num_elems
));
memcpy
(
&
num_elems
,
table
()
->
cursor
(),
sizeof
(
uint64_t
));
table
()
->
Consume
(
sizeof
(
size
_t
));
table
()
->
Consume
(
sizeof
(
uint64
_t
));
// Load all the elements.
// Load all the elements.
for
(
size
_t
i
=
0
;
i
<
num_elems
;
i
++
)
{
for
(
uint64
_t
i
=
0
;
i
<
num_elems
;
i
++
)
{
builders_
.
emplace_back
(
table
());
builders_
.
emplace_back
(
table
());
builders_
.
back
().
Load
();
builders_
.
back
().
Load
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录