Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
af1fd538
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看板
提交
af1fd538
编写于
2月 12, 2019
作者:
Z
zhangyang0701
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs
上级
0719bf08
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
31 addition
and
43 deletion
+31
-43
src/fpga/V1/pe.cpp
src/fpga/V1/pe.cpp
+0
-3
src/framework/executor.cpp
src/framework/executor.cpp
+1
-1
src/framework/operator.h
src/framework/operator.h
+0
-21
src/framework/scope.cpp
src/framework/scope.cpp
+0
-2
src/framework/scope.h
src/framework/scope.h
+0
-1
src/operators/kernel/fpga/V1/fetch_kernel.cpp
src/operators/kernel/fpga/V1/fetch_kernel.cpp
+4
-1
test/fpga/test_resnet50.cpp
test/fpga/test_resnet50.cpp
+26
-14
未找到文件。
src/fpga/V1/pe.cpp
浏览文件 @
af1fd538
...
...
@@ -290,14 +290,11 @@ int ComputeBasicConv(const struct ConvArgs &args) {
reg_writeq
(
args
.
driver
.
deconv_param
,
0xd18
);
reg_writeq
(
args
.
driver
.
fpga_bias_scale_len
/
4
,
0xd20
);
reg_writeq
(
args
.
driver
.
cmd
,
REG_CONV_CMD
);
DLOG
<<
"before reg poll"
;
if
(
0
!=
fpga_regpoll
(
REG_INTERRUPT
,
INTERRUPT_CONV
,
PE_IRQ_TIMEOUT
))
{
g_fpgainfo
.
pe_data
->
pes
[
PE_IDX_CONV
]
->
status
=
ERROR
;
ret
=
-
EIO
;
DLOG
<<
"Conv Wait Irq Timeout!"
;
}
DLOG
<<
"after reg poll"
;
output_scale
=
reg_readq
(
REG_SCALE_PARAMETER
);
output_scale
=
(
output_scale
<<
32
)
|
(
output_scale
>>
32
);
fpga_copy
(
args
.
output
.
scale_address
,
&
output_scale
,
sizeof
(
float
)
*
2
);
...
...
src/framework/executor.cpp
浏览文件 @
af1fd538
...
...
@@ -459,7 +459,7 @@ void Executor<Device, T>::InjectVariable(const Tensor &t,
template
<
typename
Device
,
typename
T
>
void
Executor
<
Device
,
T
>::
FeedData
(
const
Tensor
&
t
)
{
InjectVariable
(
t
,
"feed"
);
InjectVariable
(
t
,
"feed
0
"
);
}
template
<
typename
Device
,
typename
T
>
...
...
src/framework/operator.h
浏览文件 @
af1fd538
...
...
@@ -80,7 +80,6 @@ class OperatorBase {
}
#ifdef PADDLE_MOBILE_FPGA
void
InsertTensors
();
void
ChangeNameMap
(
string
key
,
std
::
vector
<
string
>
value
);
#endif
protected:
std
::
shared_ptr
<
Scope
>
scope_
;
...
...
@@ -96,7 +95,6 @@ class OperatorBase {
template
<
typename
Dtype
,
typename
ParamType
,
typename
KernelType
>
class
OperatorWithKernel
:
public
OperatorBase
<
Dtype
>
{
public:
#ifndef PADDLE_MOBILE_FPGA1
OperatorWithKernel
(
const
std
::
string
&
type
,
const
VariableNameMap
&
inputs
,
const
VariableNameMap
&
outputs
,
const
AttributeMap
&
attrs
,
std
::
shared_ptr
<
Scope
>
scope
)
...
...
@@ -106,25 +104,6 @@ class OperatorWithKernel : public OperatorBase<Dtype> {
kernel_
.
InitCLHelper
(
scope
->
GetCLScpoe
());
#endif
}
#else
OperatorWithKernel
(
const
std
::
string
&
type
,
const
VariableNameMap
inputs
,
const
VariableNameMap
&
outputs
,
const
AttributeMap
&
attrs
,
std
::
shared_ptr
<
Scope
>
scope
)
:
OperatorBase
<
Dtype
>
(
type
,
inputs
,
outputs
,
attrs
,
scope
)
{
static
int
feed_num
=
0
;
static
int
fetch_num
=
0
;
if
(
type
==
"feed"
)
{
auto
new_name
=
string
(
"feed"
)
+
std
::
to_string
(
feed_num
++
);
auto
var
=
scope
->
Var
(
new_name
);
(
const_cast
<
VariableNameMap
&>
(
inputs
)).
at
(
"X"
)
=
{
string
(
new_name
)};
}
else
if
(
type
==
"fetch"
)
{
auto
new_name
=
string
(
"fetch"
)
+
std
::
to_string
(
fetch_num
++
);
auto
var
=
scope
->
Var
(
new_name
);
(
const_cast
<
VariableNameMap
&>
(
outputs
)).
at
(
"Out"
)
=
{
string
(
new_name
)};
}
param_
=
ParamType
(
inputs
,
outputs
,
attrs
,
*
scope
);
}
#endif
virtual
void
RunImpl
()
{
this
->
kernel_
.
Compute
(
this
->
param_
);
}
virtual
void
InferShape
()
const
=
0
;
...
...
src/framework/scope.cpp
浏览文件 @
af1fd538
...
...
@@ -126,8 +126,6 @@ std::vector<Variable *> Scope::VarContain(const std::string substring) {
return
v
;
}
void
Scope
::
InsertVar
(
const
std
::
string
str
,
Variable
*
var
)
{}
void
Scope
::
print_vars
()
{
DLOG
<<
"====================start to print variables================="
;
for
(
auto
pair
:
vars_
)
{
...
...
src/framework/scope.h
浏览文件 @
af1fd538
...
...
@@ -86,7 +86,6 @@ class Scope {
#ifdef PADDLE_MOBILE_FPGA
Variable
*
Var
(
const
std
::
string
&
name
,
const
int
id
);
std
::
vector
<
Variable
*>
VarContain
(
const
std
::
string
substring
);
void
InsertVar
(
const
std
::
string
str
,
Variable
*
var
);
void
print_vars
();
#endif
...
...
src/operators/kernel/fpga/V1/fetch_kernel.cpp
浏览文件 @
af1fd538
...
...
@@ -22,7 +22,6 @@ bool FetchKernel<FPGA, float>::Init(FetchParam<FPGA> *param) {
auto
input
=
const_cast
<
Tensor
*>
(
param
->
InputX
());
auto
output
=
param
->
Out
();
if
(
input
->
type
()
==
typeid
(
float
))
{
output
->
ShareDataWith
(
*
input
);
return
true
;
}
output
->
init
(
typeid
(
float
));
...
...
@@ -52,9 +51,13 @@ template <>
void
FetchKernel
<
FPGA
,
float
>::
Compute
(
const
FetchParam
<
FPGA
>
&
param
)
{
auto
input
=
param
.
InputX
();
if
(
input
->
type
()
==
typeid
(
float
))
{
auto
output
=
param
.
Out
();
output
->
ShareDataWith
(
*
input
);
return
;
}
fpga
::
PerformBypass
(
param
.
fpga_bypass_args
);
fpga
::
fpga_invalidate
(
param
.
fpga_bypass_args
.
output
.
address
,
param
.
fpga_bypass_args
.
image
.
channels
*
sizeof
(
float
));
// TODO: DEalign: get rid of extra 0
}
...
...
test/fpga/test_resnet50.cpp
浏览文件 @
af1fd538
...
...
@@ -61,15 +61,16 @@ void dump(std::string filename, Tensor input_tensor) {
}
out
.
close
();
}
void
dump_stride
(
std
::
string
filename
,
Tensor
input_tensor
,
const
int
dumpnum
)
{
void
dump_stride_half
(
std
::
string
filename
,
Tensor
input_tensor
,
const
int
dumpnum
)
{
int
c
=
(
input_tensor
.
dims
())[
1
];
int
h
=
(
input_tensor
.
dims
())[
2
];
int
w
=
(
input_tensor
.
dims
())[
3
];
auto
data_ptr
=
input_tensor
.
get_data
();
int16_t
*
data_tmp
=
(
int16_t
*
)
malloc
(
c
*
h
*
w
*
sizeof
(
int16_t
));
int16_t
*
data_ptr_16
=
(
int16_t
*
)
data_ptr
;
auto
*
data_tmp
=
reinterpret_cast
<
half
*>
(
malloc
(
c
*
h
*
w
*
sizeof
(
int16_t
)));
auto
*
data_ptr_16
=
reinterpret_cast
<
half
*>
(
data_ptr
);
convert_to_chw
(
&
data_ptr_16
,
c
,
h
,
w
,
data_tmp
);
// const int16_t *dataptr = input_tensor.data<int16_t>();
std
::
ofstream
out
(
filename
.
c_str
());
float
result
=
0
;
int
stride
=
input_tensor
.
numel
()
/
dumpnum
;
...
...
@@ -81,6 +82,20 @@ void dump_stride(std::string filename, Tensor input_tensor, const int dumpnum) {
out
.
close
();
free
(
data_tmp
);
}
void
dump_stride_float
(
std
::
string
filename
,
Tensor
input_tensor
,
const
int
dumpnum
)
{
auto
data_ptr
=
reinterpret_cast
<
float
*>
(
input_tensor
.
get_data
());
std
::
ofstream
out
(
filename
.
c_str
());
float
result
=
0
;
int
stride
=
input_tensor
.
numel
()
/
dumpnum
;
stride
=
stride
>
0
?
stride
:
1
;
for
(
int
i
=
0
;
i
<
input_tensor
.
numel
();
i
+=
stride
)
{
result
=
data_ptr
[
i
];
out
<<
result
<<
std
::
endl
;
}
out
.
close
();
}
static
const
char
*
g_resnet50
=
"../models/resnet50"
;
const
std
::
string
g_image_src_float
=
"../images/image_src_float"
;
int
main
()
{
...
...
@@ -99,22 +114,19 @@ int main() {
std
::
string
saveName
=
"resnet50_result_"
+
std
::
to_string
(
i
);
paddle_mobile
::
fpga
::
fpga_invalidate
((
*
tensor_ptr
).
get_data
(),
tensor_ptr
->
numel
()
*
sizeof
(
half
));
// dump_stride
(saveName, (*tensor_ptr), 20);
dump_stride_half
(
saveName
,
(
*
tensor_ptr
),
20
);
// dump(saveName, (*tensor_ptr));
}
std
::
shared_ptr
<
Tensor
>
output_tensor
=
paddle_mobile
.
FetchResult
(
73
);
//(*output_tensor).dump<float>("resnet50_result_73");
output_tensor
=
paddle_mobile
.
FetchResult
(
74
);
//(*output_tensor).dump<float>("resnet50_result_74");
// std::shared_ptr<Tensor> output_tensor = paddle_mobile.FetchResult(74);
// output_tensor = paddle_mobile.FetchResult(74);
auto
tensor_ptr
=
paddle_mobile
.
FetchResult
(
73
);
dump_stride_float
(
"resnet50_result_73"
,
(
*
tensor_ptr
),
20
);
tensor_ptr
=
paddle_mobile
.
FetchResult
(
74
);
dump_stride_float
(
"resnet50_result_74"
,
(
*
tensor_ptr
),
9999
);
float
max
=
0
;
auto
data_ptr
=
output_tenso
r
->
data
<
float
>
();
auto
data_ptr
=
tensor_pt
r
->
data
<
float
>
();
int
maximumIdx
=
0
;
for
(
int
i
=
0
;
i
<
(
*
output_tenso
r
).
numel
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
*
tensor_pt
r
).
numel
();
i
++
)
{
if
(
data_ptr
[
i
]
>
max
)
{
maximumIdx
=
i
;
max
=
data_ptr
[
i
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录