Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
5845523a
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看板
未验证
提交
5845523a
编写于
9月 28, 2020
作者:
H
hong19860320
提交者:
GitHub
9月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry-pick][apu][cache] Refine Cache flow for performance. test=develop (#4469) (
#4471
)
上级
f0d50ff1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
3 deletion
+21
-3
lite/kernels/apu/subgraph_compute.cc
lite/kernels/apu/subgraph_compute.cc
+21
-3
未找到文件。
lite/kernels/apu/subgraph_compute.cc
浏览文件 @
5845523a
...
@@ -85,8 +85,7 @@ bool DeviceProgram::LoadFromCacheFile(
...
@@ -85,8 +85,7 @@ bool DeviceProgram::LoadFromCacheFile(
VLOG
(
3
)
<<
"[APU] Complete Load model!"
;
VLOG
(
3
)
<<
"[APU] Complete Load model!"
;
// Deserialize the preicisions and shapes of the origin output tensors from
// Deserialize the preicisions and shapes of the origin output tensors from
// the
// the cached configuration file
// cached configuration file
auto
config_path
=
model_cache_dir
+
"/"
+
model_name_
+
".cfg"
;
auto
config_path
=
model_cache_dir
+
"/"
+
model_name_
+
".cfg"
;
VLOG
(
3
)
<<
"[APU] Load configuration from "
<<
config_path
;
VLOG
(
3
)
<<
"[APU] Load configuration from "
<<
config_path
;
std
::
vector
<
char
>
config_buffer
;
std
::
vector
<
char
>
config_buffer
;
...
@@ -213,6 +212,7 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
...
@@ -213,6 +212,7 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
VLOG
(
1
)
<<
"[APU] APU DLA model created, Build cost "
VLOG
(
1
)
<<
"[APU] APU DLA model created, Build cost "
<<
GetCurrentUS
()
-
start_time
<<
" us"
;
<<
GetCurrentUS
()
-
start_time
<<
" us"
;
start_time
=
GetCurrentUS
();
CHECK_EQ
(
origin_otensors
.
size
(),
output_names
.
size
());
CHECK_EQ
(
origin_otensors
.
size
(),
output_names
.
size
());
origin_otypes_
.
resize
(
output_names
.
size
());
origin_otypes_
.
resize
(
output_names
.
size
());
origin_odims_
.
resize
(
output_names
.
size
());
origin_odims_
.
resize
(
output_names
.
size
());
...
@@ -228,9 +228,10 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
...
@@ -228,9 +228,10 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
size_t
compilationSize
;
size_t
compilationSize
;
status
=
NeuronCompilation_getCompiledNetworkSize
(
compilation_
,
status
=
NeuronCompilation_getCompiledNetworkSize
(
compilation_
,
&
compilationSize
);
&
compilationSize
);
std
::
vector
<
char
>
model_buffer
;
if
(
status
==
NEURON_NO_ERROR
)
{
if
(
status
==
NEURON_NO_ERROR
)
{
// Serialization DLA
// Serialization DLA
std
::
vector
<
char
>
model_buffer
;
model_buffer
.
resize
(
compilationSize
);
model_buffer
.
resize
(
compilationSize
);
status
=
NeuronCompilation_storeCompiledNetwork
(
status
=
NeuronCompilation_storeCompiledNetwork
(
compilation_
,
&
model_buffer
[
0
],
compilationSize
);
compilation_
,
&
model_buffer
[
0
],
compilationSize
);
...
@@ -261,6 +262,23 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
...
@@ -261,6 +262,23 @@ bool DeviceProgram::BuildGraphAndCacheToFile(
if
(
!
WriteFile
(
config_path
,
config_buffer
))
{
if
(
!
WriteFile
(
config_path
,
config_buffer
))
{
LOG
(
WARNING
)
<<
"[APU] Open "
<<
config_path
<<
" for writting failed!"
;
LOG
(
WARNING
)
<<
"[APU] Open "
<<
config_path
<<
" for writting failed!"
;
}
}
// Workaround: after calling storeCompiledNetwork, model will be modificated
// that will cause a low performace, so we need restore it. after we fix
// this bug, below code will be deleted
NeuronCompilation_free
(
compilation_
);
NeuronModel_free
(
model_
);
model_
=
nullptr
;
compilation_
=
nullptr
;
status
=
NeuronModel_restoreFromCompiledNetwork
(
&
model_
,
&
compilation_
,
&
model_buffer
[
0
],
compilationSize
);
if
(
status
!=
NEURON_NO_ERROR
)
{
LOG
(
WARNING
)
<<
"[APU] Load model failed!"
<<
compilationSize
;
return
false
;
}
VLOG
(
3
)
<<
"[APU] Complete Load model!"
;
VLOG
(
1
)
<<
"[APU] APU DLA model cached, cache cost "
<<
GetCurrentUS
()
-
start_time
<<
" us"
;
}
}
return
true
;
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录