Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
27ec5deb
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看板
未验证
提交
27ec5deb
编写于
2月 14, 2020
作者:
X
xiaogang
提交者:
GitHub
2月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix fpga run the feed/fetch op (#2868)
fix fpga lite_tensor compile bug add fake quantize_abs_max op test=develop
上级
5f8e3f3e
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
58 addition
and
7 deletion
+58
-7
lite/api/cxx_api.cc
lite/api/cxx_api.cc
+37
-0
lite/api/resnet50_test_fpga.cc
lite/api/resnet50_test_fpga.cc
+1
-5
lite/backends/fpga/lite_tensor.h
lite/backends/fpga/lite_tensor.h
+4
-0
lite/core/mir/node.cc
lite/core/mir/node.cc
+5
-0
lite/core/mir/node.h
lite/core/mir/node.h
+1
-0
lite/core/program.cc
lite/core/program.cc
+4
-0
lite/operators/fake_quantize_range_abs_max.cc
lite/operators/fake_quantize_range_abs_max.cc
+2
-0
lite/operators/fake_quantize_range_abs_max.h
lite/operators/fake_quantize_range_abs_max.h
+4
-2
未找到文件。
lite/api/cxx_api.cc
浏览文件 @
27ec5deb
...
...
@@ -121,6 +121,7 @@ void Predictor::SaveOpKernelInfo(const std::string &model_dir) {
<<
kpf_path
;
}
#ifndef LITE_WITH_FPGA
lite
::
Tensor
*
Predictor
::
GetInput
(
size_t
offset
)
{
CHECK
(
input_names_
.
size
()
>
offset
)
<<
"The network has "
<<
input_names_
.
size
()
<<
" inputs"
...
...
@@ -130,6 +131,17 @@ lite::Tensor *Predictor::GetInput(size_t offset) {
<<
" in exec_scope"
;
return
in_var
->
GetMutable
<
lite
::
Tensor
>
();
}
#else
lite
::
Tensor
*
Predictor
::
GetInput
(
size_t
offset
)
{
auto
*
_feed_list
=
exec_scope_
->
FindVar
(
"feed"
);
CHECK
(
_feed_list
)
<<
"no feed variable in exec_scope"
;
auto
*
feed_list
=
_feed_list
->
GetMutable
<
std
::
vector
<
lite
::
Tensor
>>
();
if
(
offset
>=
feed_list
->
size
())
{
feed_list
->
resize
(
offset
+
1
);
}
return
&
feed_list
->
at
(
offset
);
}
#endif
// get inputs names
std
::
vector
<
std
::
string
>
Predictor
::
GetInputNames
()
{
return
input_names_
;
}
...
...
@@ -167,6 +179,8 @@ void Predictor::PrepareFeedFetch() {
}
}
#ifndef LITE_WITH_FPGA
const
lite
::
Tensor
*
Predictor
::
GetOutput
(
size_t
offset
)
const
{
CHECK
(
output_names_
.
size
()
>
offset
)
<<
"The network has "
<<
output_names_
.
size
()
<<
" outputs"
...
...
@@ -186,6 +200,29 @@ std::vector<const lite::Tensor *> Predictor::GetOutputs() const {
}
return
outputs
;
}
#else
const
lite
::
Tensor
*
Predictor
::
GetOutput
(
size_t
offset
)
const
{
auto
*
_fetch_list
=
exec_scope_
->
FindVar
(
"fetch"
);
CHECK
(
_fetch_list
)
<<
"no fatch variable in exec_scope"
;
auto
&
fetch_list
=
*
_fetch_list
->
GetMutable
<
std
::
vector
<
lite
::
Tensor
>>
();
CHECK_LT
(
offset
,
fetch_list
.
size
())
<<
"offset "
<<
offset
<<
" overflow"
;
return
&
fetch_list
.
at
(
offset
);
}
std
::
vector
<
const
lite
::
Tensor
*>
Predictor
::
GetOutputs
()
const
{
auto
*
_fetch_list
=
exec_scope_
->
FindVar
(
"fetch"
);
CHECK
(
_fetch_list
)
<<
"no fatch variable in exec_scope"
;
auto
&
fetch_list
=
*
_fetch_list
->
GetMutable
<
std
::
vector
<
lite
::
Tensor
>>
();
std
::
vector
<
const
lite
::
Tensor
*>
outputs
;
for
(
auto
out
:
fetch_list
)
{
outputs
.
push_back
(
&
out
);
}
return
outputs
;
}
#endif
const
cpp
::
ProgramDesc
&
Predictor
::
program_desc
()
const
{
return
program_desc_
;
...
...
lite/api/resnet50_test_fpga.cc
浏览文件 @
27ec5deb
...
...
@@ -31,11 +31,7 @@ TEST(ResNet50, test) {
std
::
vector
<
Place
>
valid_places
(
{
Place
{
TARGET
(
kFPGA
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNHWC
)}});
predictor
.
Build
(
FLAGS_model_dir
,
""
,
""
,
Place
{
TARGET
(
kFPGA
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNHWC
)},
valid_places
);
predictor
.
Build
(
FLAGS_model_dir
,
""
,
""
,
valid_places
);
auto
*
input_tensor
=
predictor
.
GetInput
(
0
);
input_tensor
->
Resize
(
DDim
(
std
::
vector
<
DDim
::
value_type
>
({
1
,
3
,
224
,
224
})));
...
...
lite/backends/fpga/lite_tensor.h
浏览文件 @
27ec5deb
...
...
@@ -151,6 +151,10 @@ class TensorLite {
size_t
offset
()
const
{
return
offset_
;
}
bool
IsInitialized
()
const
{
return
buffer_
->
data
();
}
void
clear
()
{
buffer_
->
Free
();
offset_
=
0
;
}
// Other share data to this.
void
ShareDataWith
(
const
TensorLite
&
other
);
...
...
lite/core/mir/node.cc
浏览文件 @
27ec5deb
...
...
@@ -53,6 +53,11 @@ void mir::Node::Stmt::ResetOp(const cpp::OpDesc &op_desc,
}
valid_kernels_
=
op_
->
CreateKernels
(
valid_places
);
}
void
mir
::
Node
::
Stmt
::
ResetKernels
(
const
std
::
vector
<
Place
>
&
valid_places
)
{
CHECK
(
op_
)
<<
"change valid place failed, not created op"
;
valid_kernels_
.
clear
();
valid_kernels_
=
op_
->
CreateKernels
(
valid_places
);
}
mir
::
Node
::
Arg
&
mir
::
Node
::
AsArg
(
const
std
::
string
&
name
,
int
id
)
{
auto
&
x
=
AsArg
();
...
...
lite/core/mir/node.h
浏览文件 @
27ec5deb
...
...
@@ -53,6 +53,7 @@ class Node {
const
std
::
vector
<
Place
>&
valid_places
,
lite
::
Scope
*
scope
=
nullptr
);
void
ResetKernels
(
const
std
::
vector
<
Place
>&
valid_places
);
std
::
string
op_type
()
const
{
return
op_info
()
->
Type
();
}
const
OpInfo
*
op_info
()
const
;
OpInfo
*
mutable_op_info
();
...
...
lite/core/program.cc
浏览文件 @
27ec5deb
...
...
@@ -137,11 +137,15 @@ void RuntimeProgram::UpdateVarsOfProgram(cpp::ProgramDesc* desc) {
void
RuntimeProgram
::
Run
()
{
for
(
auto
&
inst
:
instructions_
)
{
#ifndef LITE_WITH_FPGA
if
(
inst
.
is_feed_fetch_op
())
continue
;
#endif
inst
.
Run
();
#ifdef LITE_WITH_PROFILE
#ifdef LITE_WITH_PRECISION_PROFILE
#ifndef LITE_WITH_FPGA
LITE_PRECISION_PROFILE
(
inst
)
#endif
#endif // LITE_WITH_PRECISION_PROFILE
#endif // LITE_WITH_PROFILE
}
...
...
lite/operators/fake_quantize_range_abs_max.cc
浏览文件 @
27ec5deb
...
...
@@ -23,3 +23,5 @@ namespace operators {} // namespace operators
REGISTER_LITE_OP
(
fake_quantize_range_abs_max
,
paddle
::
lite
::
operators
::
FakeQuantizeRangeMaxAbsOpLite
);
REGISTER_LITE_OP
(
fake_quantize_abs_max
,
paddle
::
lite
::
operators
::
FakeQuantizeRangeMaxAbsOpLite
);
lite/operators/fake_quantize_range_abs_max.h
浏览文件 @
27ec5deb
...
...
@@ -40,13 +40,15 @@ class FakeQuantizeRangeMaxAbsOpLite : public OpLite {
bool
AttachImpl
(
const
cpp
::
OpDesc
&
op_desc
,
lite
::
Scope
*
scope
)
override
{
auto
x
=
op_desc
.
Input
(
"X"
).
front
();
if
(
op_desc
.
HasInput
(
"InScale"
))
{
auto
in_scale
=
op_desc
.
Input
(
"InScale"
).
front
();
param_
.
in_scale
=
scope
->
FindVar
(
in_scale
)
->
GetMutable
<
lite
::
Tensor
>
();
}
auto
out
=
op_desc
.
Output
(
"Out"
).
front
();
auto
out_scale
=
op_desc
.
Output
(
"OutScale"
).
front
();
param_
.
x
=
scope
->
FindVar
(
x
)
->
GetMutable
<
lite
::
Tensor
>
();
param_
.
in_scale
=
scope
->
FindVar
(
in_scale
)
->
GetMutable
<
lite
::
Tensor
>
();
param_
.
out
=
scope
->
FindVar
(
out
)
->
GetMutable
<
lite
::
Tensor
>
();
param_
.
out_scale
=
scope
->
FindVar
(
out_scale
)
->
GetMutable
<
lite
::
Tensor
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录