Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
95f8b158
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看板
提交
95f8b158
编写于
9月 18, 2018
作者:
Z
zhangyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add parameter for FetchResutl() for FPGA track
上级
041a31a2
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
18 addition
and
20 deletion
+18
-20
src/fpga/api.h
src/fpga/api.h
+0
-6
src/framework/tensor.h
src/framework/tensor.h
+1
-5
src/io/executor.cpp
src/io/executor.cpp
+6
-4
src/io/executor.h
src/io/executor.h
+1
-1
src/io/paddle_mobile.cpp
src/io/paddle_mobile.cpp
+2
-2
src/io/paddle_mobile.h
src/io/paddle_mobile.h
+1
-1
test/net/test_resnet.cpp
test/net/test_resnet.cpp
+7
-1
未找到文件。
src/fpga/api.h
浏览文件 @
95f8b158
...
@@ -20,8 +20,6 @@ limitations under the License. */
...
@@ -20,8 +20,6 @@ limitations under the License. */
#include <limits>
#include <limits>
#include "framework/tensor.h"
#include "framework/tensor.h"
// memory management;
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
fpga
{
namespace
fpga
{
...
@@ -45,9 +43,6 @@ struct MemoryCopyArgs {
...
@@ -45,9 +43,6 @@ struct MemoryCopyArgs {
size_t
size
;
size_t
size
;
};
};
/**
Conv and Pooling kernel
*/
struct
KernelArgs
{
struct
KernelArgs
{
uint32_t
width
;
uint32_t
width
;
uint32_t
height
;
uint32_t
height
;
...
@@ -109,7 +104,6 @@ struct PoolingArgs {
...
@@ -109,7 +104,6 @@ struct PoolingArgs {
struct
ImageOutputArgs
output
;
struct
ImageOutputArgs
output
;
};
};
// elementwise add arguments
struct
EWAddArgs
{
struct
EWAddArgs
{
bool
relu_enabled
;
bool
relu_enabled
;
...
...
src/framework/tensor.h
浏览文件 @
95f8b158
...
@@ -289,12 +289,8 @@ class Tensor {
...
@@ -289,12 +289,8 @@ class Tensor {
virtual
std
::
type_index
type
()
const
{
return
type_
;
}
virtual
std
::
type_index
type
()
const
{
return
type_
;
}
virtual
void
set_type
(
std
::
type_index
type
)
{
type_
=
type
;
}
virtual
void
set_type
(
std
::
type_index
type
)
{
type_
=
type
;
}
#ifndef PADDLE_MOBILE_FPGA
/*! the pointer of memory block. */
std
::
unique_ptr
<
uint8_t
,
memory
::
PODDeleter
<
uint8_t
>>
ptr_
;
std
::
unique_ptr
<
uint8_t
,
memory
::
PODDeleter
<
uint8_t
>>
ptr_
;
#else
std
::
shared_ptr
<
uint8_t
>
ptr_
;
#endif
/*! the size of memory block. */
/*! the size of memory block. */
size_t
size_
;
size_t
size_
;
...
...
src/io/executor.cpp
浏览文件 @
95f8b158
...
@@ -662,13 +662,15 @@ void Executor<Dtype, P>::FeedData(const framework::Tensor &t) {
...
@@ -662,13 +662,15 @@ void Executor<Dtype, P>::FeedData(const framework::Tensor &t) {
};
};
template
<
typename
Dtype
,
Precision
P
>
template
<
typename
Dtype
,
Precision
P
>
std
::
shared_ptr
<
framework
::
Tensor
>
Executor
<
Dtype
,
P
>::
FetchResult
()
{
std
::
shared_ptr
<
framework
::
Tensor
>
Executor
<
Dtype
,
P
>::
FetchResult
(
int
id
)
{
std
::
shared_ptr
<
framework
::
BlockDesc
>
to_predict_block
=
std
::
shared_ptr
<
framework
::
BlockDesc
>
to_predict_block
=
to_predict_program_
->
Block
(
0
);
to_predict_program_
->
Block
(
0
);
auto
&
ops
=
ops_of_block_
[
*
to_predict_block
.
get
()];
auto
&
ops
=
ops_of_block_
[
*
to_predict_block
.
get
()];
auto
last_op
=
ops
.
rbegin
();
auto
output_map
=
(
*
last_op
)
->
Outputs
();
PADDLE_MOBILE_ENFORCE
(
id
<
ops
.
size
(),
"Index out of range"
);
std
::
vector
<
std
::
string
>
out_keys
=
(
*
last_op
)
->
GetOutKeys
();
auto
last_op
=
id
<
0
?
ops
[
ops
.
size
()
-
1
]
:
ops
[
id
];
auto
output_map
=
last_op
->
Outputs
();
std
::
vector
<
std
::
string
>
out_keys
=
last_op
->
GetOutKeys
();
PADDLE_MOBILE_ENFORCE
(
!
out_keys
.
empty
(),
"the last op contains no output"
);
PADDLE_MOBILE_ENFORCE
(
!
out_keys
.
empty
(),
"the last op contains no output"
);
auto
*
output_tensor
=
framework
::
GetVarValue
<
framework
::
LoDTensor
>
(
auto
*
output_tensor
=
framework
::
GetVarValue
<
framework
::
LoDTensor
>
(
out_keys
[
0
],
output_map
,
*
(
program_
.
scope
));
out_keys
[
0
],
output_map
,
*
(
program_
.
scope
));
...
...
src/io/executor.h
浏览文件 @
95f8b158
...
@@ -99,7 +99,7 @@ class Executor {
...
@@ -99,7 +99,7 @@ class Executor {
public:
public:
void
InjectVariable
(
const
framework
::
Tensor
&
t
,
string
var_name
);
void
InjectVariable
(
const
framework
::
Tensor
&
t
,
string
var_name
);
void
FeedData
(
const
framework
::
Tensor
&
t
);
void
FeedData
(
const
framework
::
Tensor
&
t
);
std
::
shared_ptr
<
framework
::
Tensor
>
FetchResult
();
std
::
shared_ptr
<
framework
::
Tensor
>
FetchResult
(
int
id
=
-
1
);
void
Predict_From_To
(
int
start
=
0
,
int
end
=
-
1
);
void
Predict_From_To
(
int
start
=
0
,
int
end
=
-
1
);
void
Predict_From
(
int
start
);
void
Predict_From
(
int
start
);
void
Predict_To
(
int
end
);
void
Predict_To
(
int
end
);
...
...
src/io/paddle_mobile.cpp
浏览文件 @
95f8b158
...
@@ -138,8 +138,8 @@ void PaddleMobile<Dtype, P>::FeedData(const framework::Tensor &t) {
...
@@ -138,8 +138,8 @@ void PaddleMobile<Dtype, P>::FeedData(const framework::Tensor &t) {
};
};
template
<
typename
Dtype
,
Precision
P
>
template
<
typename
Dtype
,
Precision
P
>
std
::
shared_ptr
<
framework
::
Tensor
>
PaddleMobile
<
Dtype
,
P
>::
FetchResult
()
{
std
::
shared_ptr
<
framework
::
Tensor
>
PaddleMobile
<
Dtype
,
P
>::
FetchResult
(
int
id
)
{
return
executor_
->
FetchResult
();
return
executor_
->
FetchResult
(
id
);
};
};
template
<
typename
Dtype
,
Precision
P
>
template
<
typename
Dtype
,
Precision
P
>
...
...
src/io/paddle_mobile.h
浏览文件 @
95f8b158
...
@@ -97,7 +97,7 @@ class PaddleMobile {
...
@@ -97,7 +97,7 @@ class PaddleMobile {
public:
public:
void
InjectVariable
(
const
framework
::
Tensor
&
t
,
string
var_name
);
void
InjectVariable
(
const
framework
::
Tensor
&
t
,
string
var_name
);
void
FeedData
(
const
framework
::
Tensor
&
t
);
void
FeedData
(
const
framework
::
Tensor
&
t
);
std
::
shared_ptr
<
framework
::
Tensor
>
FetchResult
();
std
::
shared_ptr
<
framework
::
Tensor
>
FetchResult
(
int
id
=
-
1
);
void
Predict_From_To
(
int
start
=
0
,
int
end
=
-
1
);
void
Predict_From_To
(
int
start
=
0
,
int
end
=
-
1
);
void
Predict_From
(
int
start
);
void
Predict_From
(
int
start
);
void
Predict_To
(
int
end
);
void
Predict_To
(
int
end
);
...
...
test/net/test_resnet.cpp
浏览文件 @
95f8b158
...
@@ -54,7 +54,13 @@ int main() {
...
@@ -54,7 +54,13 @@ int main() {
paddle_mobile
.
FeedData
(
input_tensor
);
paddle_mobile
.
FeedData
(
input_tensor
);
paddle_mobile
.
Predict_To
(
10
);
paddle_mobile
.
Predict_To
(
10
);
paddle_mobile
.
Predict_From
(
10
);
paddle_mobile
.
Predict_From
(
10
);
paddle_mobile
.
FetchResult
();
auto
tensor_ptr
=
paddle_mobile
.
FetchResult
(
9
);
std
::
cout
<<
"Tensor element number for op[9]: "
<<
tensor_ptr
->
numel
()
<<
std
::
endl
;
auto
result_ptr
=
paddle_mobile
.
FetchResult
();
std
::
cout
<<
"Result tensor element number: "
<<
result_ptr
->
numel
()
<<
std
::
endl
;
auto
time4
=
time
();
auto
time4
=
time
();
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
<<
std
::
endl
;
<<
std
::
endl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录