Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d8cea7f7
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看板
提交
d8cea7f7
编写于
10月 11, 2018
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revert batch size and protobuf-c
上级
69a0ecad
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
107 addition
and
1388 deletion
+107
-1388
src/io/executor.cpp
src/io/executor.cpp
+6
-3
src/io/executor.h
src/io/executor.h
+2
-1
src/io/paddle_mobile.cpp
src/io/paddle_mobile.cpp
+9
-5
src/io/paddle_mobile.h
src/io/paddle_mobile.h
+3
-2
src/protobuf-c/protobuf-c.c
src/protobuf-c/protobuf-c.c
+81
-1227
src/protobuf-c/protobuf-c.h
src/protobuf-c/protobuf-c.h
+3
-148
test/net/test_nlp.cpp
test/net/test_nlp.cpp
+1
-1
tools/pre-commit.hooks/cpplint.hook
tools/pre-commit.hooks/cpplint.hook
+2
-1
未找到文件。
src/io/executor.cpp
浏览文件 @
d8cea7f7
...
...
@@ -33,11 +33,14 @@ namespace paddle_mobile {
using
framework
::
Variable
;
template
<
typename
Dtype
,
Precision
P
>
Executor
<
Dtype
,
P
>::
Executor
(
const
framework
::
Program
<
Dtype
>
p
,
Executor
<
Dtype
,
P
>::
Executor
(
const
framework
::
Program
<
Dtype
>
p
,
int
batch_size
,
const
bool
use_optimize
,
const
bool
loddable
)
:
program_
(
p
),
use_optimize_
(
use_optimize
),
loddable_
(
loddable
)
{
:
program_
(
p
),
batch_size_
(
batch_size
),
use_optimize_
(
use_optimize
),
loddable_
(
loddable
)
{
Variable
*
variable_ptr
=
program_
.
scope
->
Var
(
"batch_size"
);
variable_ptr
->
SetValue
<
int
>
(
1
);
variable_ptr
->
SetValue
<
int
>
(
batch_size
);
to_predict_program_
=
use_optimize_
?
program_
.
optimizeProgram
:
program_
.
originProgram
;
PADDLE_MOBILE_ENFORCE
(
to_predict_program_
!=
nullptr
,
...
...
src/io/executor.h
浏览文件 @
d8cea7f7
...
...
@@ -35,7 +35,7 @@ class Executor {
// @param program program converted from proto program in PaddlePaddle
// @param use_optimize bool whether use operator fusion to speed up or not
// @param loddable bool
Executor
(
const
framework
::
Program
<
Dtype
>
program
,
Executor
(
const
framework
::
Program
<
Dtype
>
program
,
int
batch_size
=
1
,
const
bool
use_optimize
=
true
,
const
bool
loddable
=
false
);
// predict with tensor input
...
...
@@ -81,6 +81,7 @@ class Executor {
framework
::
LoDTensor
*
tensor
);
framework
::
Program
<
Dtype
>
program_
;
int
batch_size_
=
1
;
std
::
shared_ptr
<
framework
::
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
OperatorBase
<
Dtype
>>>>
...
...
src/io/paddle_mobile.cpp
浏览文件 @
d8cea7f7
...
...
@@ -25,7 +25,8 @@ void PaddleMobile<Dtype, P>::SetThreadNum(int num) {
template
<
typename
Dtype
,
Precision
P
>
bool
PaddleMobile
<
Dtype
,
P
>::
Load
(
const
std
::
string
&
dirname
,
bool
optimize
,
bool
quantification
,
bool
loddable
)
{
bool
quantification
,
int
batch_size
,
bool
loddable
)
{
if
(
loader_
.
get
()
==
nullptr
)
{
loader_
=
std
::
make_shared
<
Loader
<
Dtype
,
P
>>
();
}
else
{
...
...
@@ -34,7 +35,8 @@ bool PaddleMobile<Dtype, P>::Load(const std::string &dirname, bool optimize,
if
(
executor_
.
get
()
==
nullptr
)
{
executor_
=
std
::
make_shared
<
Executor
<
Dtype
,
P
>>
(
loader_
->
Load
(
dirname
,
optimize
,
quantification
),
optimize
,
loddable
);
loader_
->
Load
(
dirname
,
optimize
,
quantification
),
batch_size
,
optimize
,
loddable
);
}
else
{
LOG
(
kLOG_INFO
)
<<
"executor inited"
;
}
...
...
@@ -45,7 +47,8 @@ bool PaddleMobile<Dtype, P>::Load(const std::string &dirname, bool optimize,
template
<
typename
Dtype
,
Precision
P
>
bool
PaddleMobile
<
Dtype
,
P
>::
Load
(
const
std
::
string
&
model_path
,
const
std
::
string
&
para_path
,
bool
optimize
,
bool
quantification
,
bool
loddable
)
{
bool
quantification
,
int
batch_size
,
bool
loddable
)
{
if
(
loader_
.
get
()
==
nullptr
)
{
loader_
=
std
::
make_shared
<
Loader
<
Dtype
,
P
>>
();
}
else
{
...
...
@@ -55,7 +58,7 @@ bool PaddleMobile<Dtype, P>::Load(const std::string &model_path,
if
(
executor_
.
get
()
==
nullptr
)
{
executor_
=
std
::
make_shared
<
Executor
<
Dtype
,
P
>>
(
loader_
->
Load
(
model_path
,
para_path
,
optimize
,
quantification
),
optimize
,
loddable
);
batch_size
,
optimize
,
loddable
);
}
else
{
LOG
(
kLOG_INFO
)
<<
"executor inited"
;
}
...
...
@@ -67,6 +70,7 @@ template <typename Dtype, Precision P>
bool
PaddleMobile
<
Dtype
,
P
>::
LoadCombinedMemory
(
size_t
model_len
,
const
uint8_t
*
model_buf
,
size_t
combined_params_len
,
const
uint8_t
*
combined_params_buf
)
{
int
batch_size
=
1
;
bool
optimise
=
true
;
bool
quantification
=
false
;
...
...
@@ -81,7 +85,7 @@ bool PaddleMobile<Dtype, P>::LoadCombinedMemory(
loader_
->
LoadCombinedMemory
(
model_len
,
model_buf
,
combined_params_len
,
combined_params_buf
,
optimise
,
quantification
),
optimise
);
batch_size
,
optimise
);
}
else
{
LOG
(
kLOG_INFO
)
<<
"executor inited"
;
}
...
...
src/io/paddle_mobile.h
浏览文件 @
d8cea7f7
...
...
@@ -36,11 +36,12 @@ class PaddleMobile {
public:
PaddleMobile
()
{}
bool
Load
(
const
std
::
string
&
dirname
,
bool
optimize
=
false
,
bool
quantification
=
false
,
bool
loddable
=
false
);
bool
quantification
=
false
,
int
batch_size
=
1
,
bool
loddable
=
false
);
bool
Load
(
const
std
::
string
&
model_path
,
const
std
::
string
&
para_path
,
bool
optimize
=
false
,
bool
quantification
=
false
,
bool
loddable
=
false
);
int
batch_size
=
1
,
bool
loddable
=
false
);
std
::
shared_ptr
<
framework
::
Tensor
>
Predict
(
const
framework
::
Tensor
&
t
);
...
...
src/protobuf-c/protobuf-c.c
浏览文件 @
d8cea7f7
此差异已折叠。
点击以展开。
src/protobuf-c/protobuf-c.h
浏览文件 @
d8cea7f7
/*
* Copyright (c) 2008-201
8
, Dave Benson and the protobuf-c authors.
* Copyright (c) 2008-201
7
, Dave Benson and the protobuf-c authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
...
...
@@ -784,13 +784,13 @@ uint32_t protobuf_c_version_number(void);
* The version of the protobuf-c headers, represented as a string using the same
* format as protobuf_c_version().
*/
#define PROTOBUF_C_VERSION "1.3.
1
"
#define PROTOBUF_C_VERSION "1.3.
0
"
/**
* The version of the protobuf-c headers, represented as an integer using the
* same format as protobuf_c_version_number().
*/
#define PROTOBUF_C_VERSION_NUMBER 100300
1
#define PROTOBUF_C_VERSION_NUMBER 100300
0
/**
* The minimum protoc-c version which works with the current version of the
...
...
@@ -798,76 +798,6 @@ uint32_t protobuf_c_version_number(void);
*/
#define PROTOBUF_C_MIN_COMPILER_VERSION 1000000
/**
* Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by name.
*
* \param desc
* The `ProtobufCEnumDescriptor` object.
* \param name
* The `name` field from the corresponding `ProtobufCEnumValue` object to
* match.
* \return
* A `ProtobufCEnumValue` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const
ProtobufCEnumValue
*
protobuf_c_enum_descriptor_get_value_by_name
(
const
ProtobufCEnumDescriptor
*
desc
,
const
char
*
name
);
/**
* Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by numeric
* value.
*
* \param desc
* The `ProtobufCEnumDescriptor` object.
* \param value
* The `value` field from the corresponding `ProtobufCEnumValue` object to
* match.
*
* \return
* A `ProtobufCEnumValue` object.
* \retval NULL
* If not found.
*/
PROTOBUF_C__API
const
ProtobufCEnumValue
*
protobuf_c_enum_descriptor_get_value
(
const
ProtobufCEnumDescriptor
*
desc
,
int
value
);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
* the name of the field.
*
* \param desc
* The `ProtobufCMessageDescriptor` object.
* \param name
* The name of the field.
* \return
* A `ProtobufCFieldDescriptor` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const
ProtobufCFieldDescriptor
*
protobuf_c_message_descriptor_get_field_by_name
(
const
ProtobufCMessageDescriptor
*
desc
,
const
char
*
name
);
/**
* Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by
* the tag value of the field.
*
* \param desc
* The `ProtobufCMessageDescriptor` object.
* \param value
* The tag value of the field.
* \return
* A `ProtobufCFieldDescriptor` object.
* \retval NULL
* If not found.
*/
PROTOBUF_C__API
const
ProtobufCFieldDescriptor
*
protobuf_c_message_descriptor_get_field
(
const
ProtobufCMessageDescriptor
*
desc
,
unsigned
value
);
/**
* Determine the number of bytes required to store the serialised message.
*
...
...
@@ -879,42 +809,6 @@ const ProtobufCFieldDescriptor *protobuf_c_message_descriptor_get_field(
PROTOBUF_C__API
size_t
protobuf_c_message_get_packed_size
(
const
ProtobufCMessage
*
message
);
/**
* Serialise a message from its in-memory representation.
*
* This function stores the serialised bytes of the message in a pre-allocated
* buffer.
*
* \param message
* The message object to serialise.
* \param[out] out
* Buffer to store the bytes of the serialised message. This buffer must
* have enough space to store the packed message. Use
* protobuf_c_message_get_packed_size() to determine the number of bytes
* required.
* \return
* Number of bytes stored in `out`.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_pack
(
const
ProtobufCMessage
*
message
,
uint8_t
*
out
);
/**
* Serialise a message from its in-memory representation to a virtual buffer.
*
* This function calls the `append` method of a `ProtobufCBuffer` object to
* consume the bytes generated by the serialiser.
*
* \param message
* The message object to serialise.
* \param buffer
* The virtual buffer object.
* \return
* Number of bytes passed to the virtual buffer.
*/
PROTOBUF_C__API
size_t
protobuf_c_message_pack_to_buffer
(
const
ProtobufCMessage
*
message
,
ProtobufCBuffer
*
buffer
);
/**
* Unpack a serialised message into an in-memory representation.
*
...
...
@@ -983,33 +877,6 @@ PROTOBUF_C__API
void
protobuf_c_message_init
(
const
ProtobufCMessageDescriptor
*
descriptor
,
void
*
message
);
/**
* Free a service.
*
* \param service
* The service object to free.
*/
PROTOBUF_C__API
void
protobuf_c_service_destroy
(
ProtobufCService
*
service
);
/**
* Look up a `ProtobufCMethodDescriptor` by name.
*
* \param desc
* Service descriptor.
* \param name
* Name of the method.
*
* \return
* A `ProtobufCMethodDescriptor` object.
* \retval NULL
* If not found or if the optimize_for = CODE_SIZE option was set.
*/
PROTOBUF_C__API
const
ProtobufCMethodDescriptor
*
protobuf_c_service_descriptor_get_method_by_name
(
const
ProtobufCServiceDescriptor
*
desc
,
const
char
*
name
);
/**
* Initialise a `ProtobufCBufferSimple` object.
*/
...
...
@@ -1047,18 +914,6 @@ PROTOBUF_C__API
void
protobuf_c_buffer_simple_append
(
ProtobufCBuffer
*
buffer
,
size_t
len
,
const
unsigned
char
*
data
);
PROTOBUF_C__API
void
protobuf_c_service_generated_init
(
ProtobufCService
*
service
,
const
ProtobufCServiceDescriptor
*
descriptor
,
ProtobufCServiceDestroy
destroy
);
PROTOBUF_C__API
void
protobuf_c_service_invoke_internal
(
ProtobufCService
*
service
,
unsigned
method_index
,
const
ProtobufCMessage
*
input
,
ProtobufCClosure
closure
,
void
*
closure_data
);
/**@}*/
PROTOBUF_C__END_DECLS
...
...
test/net/test_nlp.cpp
浏览文件 @
d8cea7f7
...
...
@@ -23,7 +23,7 @@ int main() {
// auto isok = paddle_mobile.Load(std::string(g_mobilenet_detect) + "/model",
// std::string(g_mobilenet_detect) + "/params", true);
auto
isok
=
paddle_mobile
.
Load
(
g_nlp
,
true
,
false
,
true
);
auto
isok
=
paddle_mobile
.
Load
(
g_nlp
,
true
,
false
,
1
,
true
);
// auto isok = paddle_mobile.Load(std::string(g_nlp) + "/model",
// std::string(g_nlp) + "/params", false);
...
...
tools/pre-commit.hooks/cpplint.hook
浏览文件 @
d8cea7f7
...
...
@@ -4,7 +4,8 @@ TOTAL_ERRORS=0
# The trick to remove deleted files: https://stackoverflow.com/a/2413151
for
file
in
$(
git diff
--cached
--name-status
|
awk
'$1 != "D" {print $2}'
|
\
grep
-v
".pb.cpp"
|
grep
-v
".pb.h"
|
grep
-v
".pb-c.h"
|
grep
-v
".pb-c.c"
)
;
do
grep
-v
".pb.cpp"
|
grep
-v
".pb.h"
|
grep
-v
".pb-c.h"
|
grep
-v
".pb-c.c"
|
\
grep
-v
"protobuf-c.h"
|
grep
-v
"protobuf-c.c"
)
;
do
cpplint
$file
;
TOTAL_ERRORS
=
$(
expr
$TOTAL_ERRORS
+
$?
)
;
done
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录