Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
8bdcf6b5
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
399
Star
4705
Fork
582
代码
文件
提交
分支
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看板
提交
8bdcf6b5
编写于
10月 15, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(lite): add get static mem info function in lite c++
GitOrigin-RevId: 8c9e42a74409381d17601bdb0bac7dd08483193a
上级
b84d2893
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
68 addition
and
0 deletion
+68
-0
lite/include/lite/network.h
lite/include/lite/network.h
+3
-0
lite/src/mge/network_impl.cpp
lite/src/mge/network_impl.cpp
+10
-0
lite/src/mge/network_impl.h
lite/src/mge/network_impl.h
+4
-0
lite/src/network.cpp
lite/src/network.cpp
+14
-0
lite/src/network_impl_base.h
lite/src/network_impl_base.h
+8
-0
lite/test/test_network.cpp
lite/test/test_network.cpp
+29
-0
未找到文件。
lite/include/lite/network.h
浏览文件 @
8bdcf6b5
...
...
@@ -282,6 +282,9 @@ public:
//! get device type
LiteDeviceType
get_device_type
()
const
;
//! get static peak memory info showed by Graph visualization
void
get_static_memory_alloc_info
(
const
std
::
string
&
log_dir
=
"logs/test"
)
const
;
public:
friend
class
NetworkHelper
;
...
...
lite/src/mge/network_impl.cpp
浏览文件 @
8bdcf6b5
...
...
@@ -778,6 +778,16 @@ void inline NetworkImplDft::output_plugin_result() const {
}
#endif
}
void
NetworkImplDft
::
get_static_memory_alloc_info
(
const
std
::
string
&
log_dir
)
const
{
#ifndef __IN_TEE_ENV__
#if MGB_ENABLE_JSON
m_execute_func
->
get_static_memory_alloc_info
(
log_dir
);
return
;
#endif
#endif
LITE_MARK_USED_VAR
(
log_dir
);
}
#endif
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/src/mge/network_impl.h
浏览文件 @
8bdcf6b5
...
...
@@ -163,6 +163,10 @@ public:
//! directory, in binary format
void
enable_io_bin_dump
(
std
::
string
io_bin_out_dir
);
//! get static peak memory info showed by Graph visualization
void
get_static_memory_alloc_info
(
const
std
::
string
&
log_dir
=
"logs/test"
)
const
override
;
private:
//! construct the outputspec according to the m_network_io, and set the
//! call_back to the outputspec
...
...
lite/src/network.cpp
浏览文件 @
8bdcf6b5
...
...
@@ -283,6 +283,20 @@ LiteDeviceType Network::get_device_type() const {
LITE_ERROR_HANDLER_END
}
void
Network
::
get_static_memory_alloc_info
(
const
std
::
string
&
log_dir
)
const
{
LITE_ERROR_HANDLER_BEGIN
#ifndef __IN_TEE_ENV__
#if MGB_ENABLE_JSON
LITE_ASSERT
(
m_loaded
,
"get_all_output_name should be used after model loaded."
);
m_impl
->
get_static_memory_alloc_info
(
log_dir
);
return
;
#endif
#endif
LITE_MARK_USED_VAR
(
log_dir
);
LITE_THROW
(
"Doesn't support get_static_memory_alloc_info().Please check macro."
);
LITE_ERROR_HANDLER_END
}
/*********************** MGE special network function ***************/
void
Runtime
::
set_cpu_threads_number
(
...
...
lite/src/network_impl_base.h
浏览文件 @
8bdcf6b5
...
...
@@ -125,6 +125,14 @@ public:
//! enable profile the network, a file will be generated
virtual
void
enable_profile_performance
(
std
::
string
profile_file_path
)
=
0
;
//! get static peak memory info showed by Graph visualization
virtual
void
get_static_memory_alloc_info
(
const
std
::
string
&
log_dir
)
const
{
LITE_MARK_USED_VAR
(
log_dir
);
LITE_THROW
(
"This nerworkimpl doesn't support get_static_memory_alloc_info() "
"function."
);
}
};
/******************************** friend class *****************************/
...
...
lite/test/test_network.cpp
浏览文件 @
8bdcf6b5
...
...
@@ -646,6 +646,35 @@ TEST(TestNetWork, GetModelExtraInfo) {
printf
(
"extra_info %s
\n
"
,
extra_info
.
c_str
());
}
#ifndef __IN_TEE_ENV__
#if MGB_ENABLE_JSON
TEST
(
TestNetWork
,
GetMemoryInfo
)
{
Config
config
;
auto
lite_tensor
=
get_input_data
(
"./input_data.npy"
);
std
::
string
model_path
=
"./shufflenet.mge"
;
auto
result_mgb
=
mgb_lar
(
model_path
,
config
,
"data"
,
lite_tensor
);
std
::
shared_ptr
<
Network
>
network
=
std
::
make_shared
<
Network
>
(
config
);
Runtime
::
set_cpu_threads_number
(
network
,
2
);
network
->
load_model
(
model_path
);
network
->
get_static_memory_alloc_info
();
std
::
shared_ptr
<
Tensor
>
input_tensor
=
network
->
get_input_tensor
(
0
);
auto
src_ptr
=
lite_tensor
->
get_memory_ptr
();
auto
src_layout
=
lite_tensor
->
get_layout
();
input_tensor
->
reset
(
src_ptr
,
src_layout
);
network
->
forward
();
network
->
wait
();
std
::
shared_ptr
<
Tensor
>
output_tensor
=
network
->
get_output_tensor
(
0
);
compare_lite_tensor
<
float
>
(
output_tensor
,
result_mgb
);
}
#endif
#endif
#if LITE_WITH_CUDA
TEST
(
TestNetWork
,
BasicDevice
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录