Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
262bab3d
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看板
提交
262bab3d
编写于
6月 08, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format files
上级
51704db5
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
27 addition
and
29 deletion
+27
-29
src/common/protobuf-c.c
src/common/protobuf-c.c
+1
-1
src/framework/program/block_desc.cpp
src/framework/program/block_desc.cpp
+4
-7
src/framework/program/block_desc.h
src/framework/program/block_desc.h
+1
-1
src/framework/program/program-optimize/node.cpp
src/framework/program/program-optimize/node.cpp
+1
-1
src/framework/program/program-optimize/node.h
src/framework/program/program-optimize/node.h
+2
-2
src/framework/program/program.h
src/framework/program/program.h
+1
-0
src/framework/tensor.h
src/framework/tensor.h
+1
-1
src/io/io.cpp
src/io/io.cpp
+10
-12
src/io/io.h
src/io/io.h
+2
-1
test/framework/test_load.cpp
test/framework/test_load.cpp
+2
-1
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+2
-2
未找到文件。
src/common/protobuf-c.c
浏览文件 @
262bab3d
...
...
@@ -2095,4 +2095,4 @@ protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *message) {
/* === services === */
typedef
void
(
*
GenericHandler
)(
void
*
service
,
const
ProtobufCMessage
*
input
,
ProtobufCClosure
closure
,
void
*
closure_data
);
\ No newline at end of file
ProtobufCClosure
closure
,
void
*
closure_data
);
src/framework/program/block_desc.cpp
浏览文件 @
262bab3d
...
...
@@ -17,9 +17,7 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
framework
{
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
return
vars_
;
}
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
BlockDesc
::
Vars
()
const
{
return
vars_
;
}
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
BlockDesc
::
Ops
()
const
{
return
ops_
;
}
...
...
@@ -30,11 +28,10 @@ BlockDesc::BlockDesc(PaddleMobile__Framework__Proto__BlockDesc *desc)
vars_
.
emplace_back
(
std
::
shared_ptr
<
VarDesc
>
(
new
VarDesc
(
var_desc
)));
}
std
::
sort
(
vars_
.
begin
(),
vars_
.
end
(),
[](
std
::
shared_ptr
<
VarDesc
>
left
,
std
::
shared_ptr
<
VarDesc
>
right
){
std
::
sort
(
vars_
.
begin
(),
vars_
.
end
(),
[](
std
::
shared_ptr
<
VarDesc
>
left
,
std
::
shared_ptr
<
VarDesc
>
right
)
{
return
left
->
Name
()
<
right
->
Name
();
});
});
for
(
int
j
=
0
;
j
<
desc
->
n_ops
;
++
j
)
{
PaddleMobile__Framework__Proto__OpDesc
*
op_desc
=
desc
->
ops
[
j
];
...
...
src/framework/program/block_desc.h
浏览文件 @
262bab3d
...
...
@@ -36,7 +36,7 @@ class BlockDesc {
for
(
int
i
=
0
;
i
<
block_desc
.
vars_
.
size
();
++
i
)
{
auto
&
var_desc
=
block_desc
.
vars_
[
i
];
vars_
.
emplace_back
(
std
::
make_shared
<
VarDesc
>
(
*
var_desc
))
;
vars_
.
emplace_back
(
std
::
make_shared
<
VarDesc
>
(
*
var_desc
));
}
}
...
...
src/framework/program/program-optimize/node.cpp
浏览文件 @
262bab3d
...
...
@@ -91,7 +91,7 @@ int Node::Depth(int begin) {
}
Node
&
Node
::
Folder
(
int
size
,
std
::
string
type
,
int
size
,
std
::
string
type
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
change
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
)
{
std
::
shared_ptr
<
framework
::
OpDesc
>
op_desc
=
...
...
src/framework/program/program-optimize/node.h
浏览文件 @
262bab3d
...
...
@@ -14,10 +14,10 @@ limitations under the License. */
#pragma once
#include <cinttypes>
#include <map>
#include <string>
#include <vector>
#include <cinttypes>
#include "common/log.h"
#include "framework/program/op_desc.h"
...
...
@@ -42,7 +42,7 @@ class Node {
std
::
shared_ptr
<
Node
>
To
(
int
size
);
int
Depth
(
int
begin
=
0
);
Node
&
Folder
(
int
size
,
std
::
string
type
,
int
size
,
std
::
string
type
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
change_map
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
);
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
OpDescs
(
int
size
);
...
...
src/framework/program/program.h
浏览文件 @
262bab3d
...
...
@@ -30,6 +30,7 @@ class Program {
std
::
string
model_path
;
std
::
string
para_path
;
bool
is_commbine
=
false
;
private:
};
...
...
src/framework/tensor.h
浏览文件 @
262bab3d
...
...
@@ -23,9 +23,9 @@ limitations under the License. */
#include "common/enforce.h"
#include "common/enforce.h"
#include "framework/data_layout.h"
#include "framework/ddim.h"
#include "memory/t_malloc.h"
#include "framework/data_layout.h"
namespace
paddle_mobile
{
namespace
framework
{
...
...
src/io/io.cpp
浏览文件 @
262bab3d
...
...
@@ -164,9 +164,9 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
}
template
<
typename
Dtype
,
Precision
P
>
const
framework
::
Program
<
Dtype
,
P
>
Loader
<
Dtype
,
P
>::
Load
(
const
std
::
string
&
model_path
,
const
std
::
string
&
para_path
,
bool
optimize
)
{
const
framework
::
Program
<
Dtype
,
P
>
Loader
<
Dtype
,
P
>::
Load
(
const
std
::
string
&
model_path
,
const
std
::
string
&
para_path
,
bool
optimize
)
{
auto
program
=
this
->
LoadProgram
(
model_path
,
optimize
);
program
.
para_path
=
para_path
;
program
.
is_commbine
=
true
;
...
...
@@ -174,9 +174,8 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(const std::string &mod
}
template
<
typename
Dtype
,
Precision
P
>
const
framework
::
Program
<
Dtype
,
P
>
Loader
<
Dtype
,
P
>::
LoadProgram
(
const
std
::
string
&
model_path
,
bool
optimize
){
const
framework
::
Program
<
Dtype
,
P
>
Loader
<
Dtype
,
P
>::
LoadProgram
(
const
std
::
string
&
model_path
,
bool
optimize
)
{
std
::
string
model_filename
=
model_path
;
PaddleMobile__Framework__Proto__ProgramDesc
*
c_program
;
uint8_t
*
buf
=
NULL
;
...
...
@@ -185,7 +184,7 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::LoadProgram(const std::stri
PADDLE_MOBILE_ENFORCE
(
buf
!=
NULL
,
"read from __model__ is null"
);
c_program
=
paddle_mobile__framework__proto__program_desc__unpack
(
NULL
,
read_size
,
buf
);
NULL
,
read_size
,
buf
);
//
PADDLE_MOBILE_ENFORCE
(
c_program
!=
NULL
,
"program is null"
);
//
...
...
@@ -228,7 +227,7 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::LoadProgram(const std::stri
if
(
optimize
)
{
framework
::
ProgramOptimize
program_optimize
;
program
.
optimizeProgram
=
program_optimize
.
FushionOptimize
(
originProgramDesc
);
program_optimize
.
FushionOptimize
(
originProgramDesc
);
}
if
(
optimize
)
{
program
.
optimizeProgram
->
Description
(
"optimize: "
);
...
...
@@ -276,14 +275,12 @@ Executor<Dtype, P>::Executor(const framework::Program<Dtype> p, int batch_size,
}
else
{
InitMemory
();
}
}
template
<
typename
Dtype
,
Precision
P
>
void
Executor
<
Dtype
,
P
>::
LoadMemory
(
const
framework
::
VarDesc
var_desc
,
framework
::
LoDTensor
*
tensor
,
const
std
::
string
&
file_path
,
char
*
data
)
{
// 1. version
uint32_t
version
=
*
(
uint32_t
*
)
data
;
data
+=
sizeof
(
uint32_t
);
...
...
@@ -383,7 +380,8 @@ void Executor<Dtype, P>::InitMemory() {
continue
;
}
char
*
origin_data
=
Get_binary_data
(
program_
.
model_path
+
"/"
+
var_desc
->
Name
());
char
*
origin_data
=
Get_binary_data
(
program_
.
model_path
+
"/"
+
var_desc
->
Name
());
LoadMemory
(
*
var_desc
,
tensor
,
program_
.
model_path
+
"/"
+
var_desc
->
Name
(),
origin_data
);
delete
origin_data
;
...
...
@@ -399,7 +397,7 @@ void Executor<Dtype, P>::InitMemory() {
}
template
<
typename
Dtype
,
Precision
P
>
void
Executor
<
Dtype
,
P
>::
InitCombineMemory
(){
void
Executor
<
Dtype
,
P
>::
InitCombineMemory
()
{
char
*
origin_data
=
Get_binary_data
(
program_
.
para_path
);
for
(
const
auto
&
block
:
to_predict_program_
->
Blocks
())
{
...
...
src/io/io.h
浏览文件 @
262bab3d
...
...
@@ -63,7 +63,8 @@ class Executor {
void
InitMemory
();
void
LoadMemory
(
const
framework
::
VarDesc
var_desc
,
framework
::
LoDTensor
*
tensor
,
const
std
::
string
&
file_path
,
char
*
data
);
framework
::
LoDTensor
*
tensor
,
const
std
::
string
&
file_path
,
char
*
data
);
void
InitCombineMemory
();
framework
::
Program
<
Dtype
>
program_
;
int
batch_size_
=
1
;
...
...
test/framework/test_load.cpp
浏览文件 @
262bab3d
...
...
@@ -20,7 +20,8 @@ int main() {
// ../../../test/models/googlenet
// ../../../test/models/mobilenet
auto
program
=
loader
.
Load
(
g_resnet
,
true
);
loader
.
Load
(
g_googlenet_combine
+
"/model"
,
g_googlenet_combine
+
"/params"
,
true
);
loader
.
Load
(
g_googlenet_combine
+
"/model"
,
g_googlenet_combine
+
"/params"
,
true
);
program
.
originProgram
->
Description
(
"program desc: "
);
return
0
;
...
...
test/net/test_googlenet.cpp
浏览文件 @
262bab3d
...
...
@@ -22,8 +22,8 @@ int main() {
auto
time1
=
time
();
auto
program
=
loader
.
Load
(
g_googlenet
,
optimize
);
// auto program = loader.Load(g_googlenet_combine + "/model",
// g_googlenet_combine + "/params", optimize);
// auto program = loader.Load(g_googlenet_combine + "/model",
// g_googlenet_combine + "/params", optimize);
auto
time2
=
time
();
DLOG
<<
"load cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms
\n
"
;
paddle_mobile
::
Executor
<
paddle_mobile
::
CPU
>
executor
(
program
,
1
,
optimize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录