Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
ba1508e3
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
410
Star
4707
Fork
583
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ba1508e3
编写于
7月 01, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(lite): fix exception bug for load and run
GitOrigin-RevId: 339a343a80d65a523b60b4c97360927970149e7f
上级
603d0941
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
15 deletion
+17
-15
lite/load_and_run/BUILD
lite/load_and_run/BUILD
+1
-0
lite/load_and_run/src/models/model_mdl.cpp
lite/load_and_run/src/models/model_mdl.cpp
+2
-2
lite/load_and_run/src/strategys/strategy_fitting.cpp
lite/load_and_run/src/strategys/strategy_fitting.cpp
+13
-12
lite/load_and_run/src/strategys/strategy_normal.cpp
lite/load_and_run/src/strategys/strategy_normal.cpp
+1
-1
未找到文件。
lite/load_and_run/BUILD
浏览文件 @
ba1508e3
...
...
@@ -5,6 +5,7 @@ cc_library(
hdrs
=
glob
([
"src/**/*.h"
]),
includes
=
[
"src"
],
features
=
if_opt
([
"no_exceptions"
,
"no_rtti"
,
]),
...
...
lite/load_and_run/src/models/model_mdl.cpp
浏览文件 @
ba1508e3
...
...
@@ -7,7 +7,7 @@ DECLARE_bool(share_param_mem);
using
namespace
lar
;
ModelMdl
::
ModelMdl
(
const
std
::
string
&
path
)
:
model_path
(
path
)
{
mgb_log
_warn
(
"creat mdl model use XPU as default comp node"
);
mgb_log
(
"creat mdl model use XPU as default comp node"
);
m_load_config
.
comp_graph
=
mgb
::
ComputingGraph
::
make
();
m_load_config
.
comp_graph
->
options
().
graph_opt_level
=
0
;
testcase_num
=
0
;
...
...
@@ -16,7 +16,7 @@ ModelMdl::ModelMdl(const std::string& path) : model_path(path) {
void
ModelMdl
::
load_model
()
{
//! read dump file
if
(
share_model_mem
)
{
mgb_log
_warn
(
"enable share model memory"
);
mgb_log
(
"enable share model memory"
);
FILE
*
fin
=
fopen
(
model_path
.
c_str
(),
"rb"
);
mgb_assert
(
fin
,
"failed to open %s: %s"
,
model_path
.
c_str
(),
strerror
(
errno
));
fseek
(
fin
,
0
,
SEEK_END
);
...
...
lite/load_and_run/src/strategys/strategy_fitting.cpp
浏览文件 @
ba1508e3
...
...
@@ -170,7 +170,7 @@ void OptionsTimeProfiler::profile_with_given_options(
auto
start
=
timer
.
get_msecs
();
model
->
run_model
();
model
->
wait
();
mgb_log
_warn
(
"warm up %ld time %f ms"
,
i
,
timer
.
get_msecs
()
-
start
);
mgb_log
(
"warm up %ld time %f ms"
,
i
,
timer
.
get_msecs
()
-
start
);
}
};
double
inference_time
=
0.0
;
...
...
@@ -180,7 +180,7 @@ void OptionsTimeProfiler::profile_with_given_options(
model
->
run_model
();
model
->
wait
();
auto
end
=
timer
.
get_msecs
();
mgb_log
_warn
(
"run iter %ld time %f ms"
,
i
,
end
-
start
);
mgb_log
(
"run iter %ld time %f ms"
,
i
,
end
-
start
);
inference_time
+=
end
-
start
;
mgb_throw_if
(
inference_time
>
TIME_OUT
,
mgb
::
TimeoutError
,
...
...
@@ -213,7 +213,7 @@ void OptionsTimeProfiler::profile_with_given_options(
auto
start
=
timer
.
get_msecs
();
config_model_before_runing
();
auto
end
=
timer
.
get_msecs
();
mgb_log
_warn
(
"config model time %f ms"
,
end
-
start
);
mgb_log
(
"config model time %f ms"
,
end
-
start
);
warm_up
();
run_iter
();
}
...
...
@@ -228,9 +228,10 @@ void OptionsTimeProfiler::profile_with_given_options(
auto
average
=
inference_time
/
runtime_param
.
run_iter
;
if
(
exception_state
)
{
average
=
TIME_OUT
;
printf
(
"out of time (this may be caused by some exception, please checkout the "
"log) when profile option:
\n
%s
\n
"
,
option_code
.
c_str
());
mgb_log_error
(
"out of time (this may be caused by some exception, please checkout "
"the log) when profile option:
\n
%s
\n
"
,
option_code
.
c_str
());
}
else
{
printf
(
"profile option:
\n
%s
\n
average time = %.2f
\n
"
,
option_code
.
c_str
(),
average
);
...
...
@@ -369,7 +370,7 @@ void UserInfoParser::parse_info(std::shared_ptr<OptionsFastManager>& manager) {
FittingStrategy
::
FittingStrategy
(
std
::
string
model_path
)
{
m_manager
=
std
::
make_shared
<
OptionsFastManager
>
();
m_dumped_model
=
FLAGS_dump_fitting_model
;
mgb
::
set_log_level
(
mgb
::
LogLevel
::
WARN
);
mgb
::
set_log_level
(
mgb
::
LogLevel
::
INFO
);
m_options
=
std
::
make_shared
<
OptionMap
>
();
m_model_path
=
model_path
;
auto
option_creator_map
=
OptionFactory
::
get_Instance
().
get_option_creator_map
();
...
...
@@ -458,10 +459,10 @@ void FittingStrategy::dump_best_options_with_model() {
model
->
run_model
();
model
->
wait
();
std
::
vector
<
uint8_t
>
model_data
=
model
->
get_model_data
();
mgb_log
_warn
(
"model_data size=%zu"
,
model_data
.
size
());
mgb_log
_warn
(
"json_info size=%zu"
,
json_info
.
size
());
mgb_log
_warn
(
"info_algo_policy_data size=%zu"
,
info_algo_policy_data
.
size
());
mgb_log
_warn
(
"info_binary_cache_data size=%zu"
,
info_binary_cache_data
.
size
());
mgb_log
(
"model_data size=%zu"
,
model_data
.
size
());
mgb_log
(
"json_info size=%zu"
,
json_info
.
size
());
mgb_log
(
"info_algo_policy_data size=%zu"
,
info_algo_policy_data
.
size
());
mgb_log
(
"info_binary_cache_data size=%zu"
,
info_binary_cache_data
.
size
());
lite
::
ModelPacker
packer
(
model_data
,
m_dumped_model
,
json_info
,
info_algo_policy_data
,
info_binary_cache_data
);
...
...
@@ -508,7 +509,7 @@ void FittingStrategy::AutoCleanFile::dump_model() {
model
->
wait
();
std
::
vector
<
uint8_t
>
model_data
=
model
->
get_model_data
();
mgb_log
_warn
(
"dumped model_data size=%zu
\n
"
,
model_data
.
size
());
mgb_log
(
"dumped model_data size=%zu
\n
"
,
model_data
.
size
());
auto
fp
=
fopen
(
m_filename
.
c_str
(),
"wb"
);
fwrite
(
model_data
.
data
(),
1
,
model_data
.
size
(),
fp
);
fclose
(
fp
);
...
...
lite/load_and_run/src/strategys/strategy_normal.cpp
浏览文件 @
ba1508e3
...
...
@@ -109,7 +109,7 @@ void NormalStrategy::run_subline() {
//! config model
config_after_load
();
//! config when running model
mgb_log
_warn
(
"run testcase: %zu "
,
idx
);
mgb_log
(
"run testcase: %zu "
,
idx
);
m_runtime_param
.
stage
=
RunStage
::
MODEL_RUNNING
;
stage_config_model
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录