Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a4385039
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
a4385039
编写于
5月 26, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify executor for test
上级
6d7461bb
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
41 addition
and
89 deletion
+41
-89
CMakeLists.txt
CMakeLists.txt
+2
-1
src/framework/executor.cpp
src/framework/executor.cpp
+0
-21
src/framework/executor.h
src/framework/executor.h
+0
-32
src/io.cpp
src/io.cpp
+12
-21
src/io.h
src/io.h
+1
-1
test/CMakeLists.txt
test/CMakeLists.txt
+1
-1
test/executor_for_test.h
test/executor_for_test.h
+17
-4
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+1
-1
test/operators/test_cov_op.cpp
test/operators/test_cov_op.cpp
+5
-6
test/test_helper.h
test/test_helper.h
+1
-1
test/test_include.h
test/test_include.h
+1
-0
未找到文件。
CMakeLists.txt
浏览文件 @
a4385039
...
...
@@ -40,7 +40,8 @@ endif ()
#add_dependencies(paddle-mobile openblas_proj)
# gen static
ADD_LIBRARY
(
paddle-mobile SHARED
${
PADDLE_MOBILE_CC
}
${
PADDLE_MOBILE_H
}
src/operators/feed_op.cpp src/operators/feed_op.h src/operators/fetch_op.cpp src/operators/fetch_op.h
)
ADD_LIBRARY
(
paddle-mobile SHARED
${
PADDLE_MOBILE_CC
}
${
PADDLE_MOBILE_H
}
)
if
(
ANDROID
)
# openblas.a need log lib
target_link_libraries
(
paddle-mobile protobuf-lite
)
...
...
src/framework/executor.cpp
已删除
100644 → 0
浏览文件 @
6d7461bb
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "executor.h"
#include "lod_tensor.h"
#include "operators/conv_op.h"
namespace
paddle_mobile
{
namespace
framework
{}
// namespace framework
}
// namespace paddle_mobile
src/framework/executor.h
已删除
100644 → 0
浏览文件 @
6d7461bb
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <map>
#include <string>
#include <vector>
#include "framework.pb.h"
#include "framework/program/block_desc.h"
#include "framework/program/program.h"
#include "framework/program/program_desc.h"
#include "operator.h"
#include "scope.h"
#include "tensor.h"
#include "variable.h"
namespace
paddle_mobile
{
namespace
framework
{}
// namespace framework
}
// namespace paddle_mobile
src/io.cpp
浏览文件 @
a4385039
...
...
@@ -143,7 +143,6 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
std
::
shared_ptr
<
framework
::
Scope
>
scope
=
std
::
make_shared
<
framework
::
Scope
>
();
program
.
scope
=
scope
;
originProgramDesc
->
Block
(
0
);
for
(
const
auto
&
block
:
originProgramDesc
->
Blocks
())
{
...
...
@@ -168,9 +167,6 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
for
(
const
auto
&
block
:
program_desc_proto
.
blocks
())
{
LOG
(
kLOG_DEBUG
)
<<
"block: "
<<
block
.
idx
();
for
(
int
j
=
0
;
j
<
block
.
ops
().
size
();
++
j
)
{
// if (j == 2) {
// break;
// }
framework
::
proto
::
OpDesc
op
=
block
.
ops
()[
j
];
LOG
(
kLOG_DEBUG1
)
<<
"op: "
<<
op
.
type
();
for
(
int
m
=
0
;
m
<
op
.
inputs_size
();
++
m
)
{
...
...
@@ -228,18 +224,6 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
}
for
(
const
auto
&
var
:
block
.
vars
())
{
if
(
var
.
type
().
type
()
==
framework
::
proto
::
VarType
::
LOD_TENSOR
)
{
LOG
(
kLOG_DEBUG1
)
<<
"var name: "
<<
var
.
name
();
const
framework
::
proto
::
VarType
::
TensorDesc
&
tensor_desc
=
var
.
type
().
lod_tensor
().
tensor
();
LOG
(
kLOG_DEBUG2
)
<<
"in var tensor desc dims size: "
<<
tensor_desc
.
dims
().
size
();
for
(
int
l
=
0
;
l
<
tensor_desc
.
dims
().
size
();
++
l
)
{
LOG
(
kLOG_DEBUG3
)
<<
"var tensor desc dim "
<<
l
<<
" value: "
<<
tensor_desc
.
dims
()[
l
];
}
}
if
(
var
.
persistable
()
&&
var
.
type
().
type
()
!=
framework
::
proto
::
VarType
::
FEED_MINIBATCH
&&
var
.
type
().
type
()
!=
framework
::
proto
::
VarType
::
FETCH_LIST
)
{
...
...
@@ -440,8 +424,15 @@ void Executor<Dtype, P>::InitMemory() {
for
(
const
auto
&
block
:
to_predict_program_
->
Blocks
())
{
for
(
const
auto
&
var_desc
:
block
->
Vars
())
{
auto
var
=
program_
.
scope
->
Var
(
var_desc
->
Name
());
auto
tensor
=
var
->
template
GetMutable
<
framework
::
LoDTensor
>();
LoadMemory
(
tensor
,
program_
.
model_path
+
"/"
+
var_desc
->
Name
());
if
(
var_desc
->
Persistable
())
{
auto
tensor
=
var
->
template
GetMutable
<
framework
::
LoDTensor
>();
LoadMemory
(
tensor
,
program_
.
model_path
+
"/"
+
var_desc
->
Name
());
}
else
{
if
(
var_desc
->
GetType
()
==
framework
::
proto
::
VarType
::
LOD_TENSOR
)
{
auto
tensor
=
var
->
template
GetMutable
<
framework
::
Tensor
>();
tensor
->
template
mutable_data
<
Ptype
>();
}
}
}
}
}
...
...
@@ -473,9 +464,9 @@ std::shared_ptr<framework::Tensor> Executor<Dtype, P>::predict(
template
<
typename
Dtype
,
Precision
P
>
void
Executor
<
Dtype
,
P
>::
predict
(
const
framework
::
Tensor
&
t
,
int
block_id
)
{
framework
::
Variable
*
g_feed_value
=
program_
.
scope
->
Var
(
"feed"
);
auto
feed_tensor
=
g_feed_value
->
GetMutable
<
framework
::
Tensor
>
();
feed_tensor
->
ShareDataWith
(
t
);
//
framework::Variable *g_feed_value = program_.scope->Var("feed");
//
auto feed_tensor = g_feed_value->GetMutable<framework::Tensor>();
//
feed_tensor->ShareDataWith(t);
std
::
shared_ptr
<
framework
::
BlockDesc
>
to_predict_block
=
to_predict_program_
->
Block
(
block_id
);
...
...
src/io.h
浏览文件 @
a4385039
...
...
@@ -53,7 +53,7 @@ class Executor {
protected:
void
InitMemory
();
void
LoadMemory
(
framework
::
LoDTensor
*
tensor
,
const
std
::
string
&
file_path
);
const
framework
::
Program
<
Dtype
>
program_
;
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
framework
::
ProgramDesc
>
to_predict_program_
;
void
predict
(
const
framework
::
Tensor
&
t
,
int
block_id
);
std
::
map
<
framework
::
BlockDesc
,
...
...
test/CMakeLists.txt
浏览文件 @
a4385039
...
...
@@ -80,5 +80,5 @@ ADD_EXECUTABLE(test-enforce common/test_enforce.cpp)
target_link_libraries
(
test-enforce paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-googlenet net/test
-googlenet.cpp
test_helper.h test_include.h executor_for_test.h
)
ADD_EXECUTABLE
(
test-googlenet net/test
_googlenet.cpp
test_helper.h test_include.h executor_for_test.h
)
target_link_libraries
(
test-googlenet paddle-mobile
)
test/executor_for_test.h
浏览文件 @
a4385039
...
...
@@ -16,8 +16,8 @@ limitations under the License. */
#include <string>
#include <vector>
#include "common/log.h"
#include "framework/executor.h"
#include "io.h"
#include "operators/conv_op.h"
#include "operators/pool_op.h"
...
...
@@ -38,7 +38,14 @@ template <typename DeviceType, typename OpType>
class
Executor4Test
:
public
Executor
<
DeviceType
>
{
public:
Executor4Test
(
Program
<
DeviceType
>
p
,
string
op_type
)
:
Executor
<
DeviceType
>
(
p
)
{
:
Executor
<
DeviceType
>
()
{
this
->
program_
=
p
;
if
(
this
->
use_optimize_
)
{
this
->
to_predict_program_
=
this
->
program_
.
optimizeProgram
;
}
else
{
this
->
to_predict_program_
=
this
->
program_
.
originProgram
;
}
if
(
this
->
program_
.
originProgram
==
nullptr
)
{
LOG
(
paddle_mobile
::
LogLevel
::
kLOG_ERROR
)
<<
"to_predict_program_ == nullptr"
;
...
...
@@ -52,7 +59,6 @@ class Executor4Test : public Executor<DeviceType> {
std
::
shared_ptr
<
OpType
>
op_ptr
=
std
::
make_shared
<
OpType
>
(
op
->
Type
(),
op
->
GetInputs
(),
op
->
GetOutputs
(),
op
->
GetAttrMap
(),
this
->
program_
.
scope
);
this
->
ops_of_block_
[
*
block_desc
.
get
()].
push_back
(
op_ptr
);
break
;
}
...
...
@@ -73,7 +79,14 @@ class Executor4Test : public Executor<DeviceType> {
std
::
shared_ptr
<
Tensor
>
out_tensor
=
std
::
make_shared
<
LoDTensor
>
();
out_tensor
.
reset
(
output_tensor
);
Executor
<
DeviceType
>::
predict
(
t
,
0
);
std
::
shared_ptr
<
paddle_mobile
::
framework
::
BlockDesc
>
to_predict_block
=
this
->
to_predict_program_
->
Block
(
0
);
for
(
int
j
=
0
;
j
<
this
->
ops_of_block_
[
*
to_predict_block
.
get
()].
size
();
++
j
)
{
auto
op
=
this
->
ops_of_block_
[
*
to_predict_block
.
get
()][
j
];
op
->
Run
();
}
return
out_tensor
;
}
};
test/net/test
-
googlenet.cpp
→
test/net/test
_
googlenet.cpp
浏览文件 @
a4385039
...
...
@@ -16,7 +16,7 @@ limitations under the License. */
#include "../test_helper.h"
#include "../test_include.h"
#include "
framework/executor
.h"
#include "
io
.h"
int
main
()
{
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
...
...
test/operators/test_cov_op.cpp
浏览文件 @
a4385039
...
...
@@ -13,16 +13,15 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "../executor_for_test.h"
#include "../test_helper.h"
#include "io.h"
#include "../test_include.h"
int
main
()
{
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
// ../models/image_classification_resnet.inference.model
auto
program
=
loader
.
Load
(
std
::
string
(
"../models/googlenet"
)
);
if
(
program
.
originProgram
==
nullptr
)
{
DLOG
<<
"program file read fail"
;
}
auto
program
=
loader
.
Load
(
g_googlenet
);
PADDLE_MOBILE_ENFORCE
(
program
.
originProgram
!=
nullptr
,
"program file read fail"
);
Executor4Test
<
paddle_mobile
::
CPU
,
paddle_mobile
::
operators
::
ConvOp
<
paddle_mobile
::
CPU
,
float
>>
...
...
test/test_helper.h
浏览文件 @
a4385039
...
...
@@ -21,7 +21,7 @@ limitations under the License. */
#include "framework/ddim.h"
#include "framework/tensor.h"
static
const
std
::
string
g_google
=
"../models/googlenet"
;
static
const
std
::
string
g_google
net
=
"../models/googlenet"
;
static
const
std
::
string
g_mobilenet
=
"../models/mobilenet"
;
static
const
std
::
string
g_mobilenet_ssd
=
"../models/mobilenet"
;
static
const
std
::
string
g_squeezenet
=
"../models/squeezenet"
;
...
...
test/test_include.h
浏览文件 @
a4385039
...
...
@@ -19,6 +19,7 @@ limitations under the License. */
#include <vector>
#include "./test_helper.h"
#include "common/enforce.h"
#include "common/log.h"
#include "framework/framework.pb.h"
#include "framework/lod_tensor.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录