Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
f7e034b5
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
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看板
提交
f7e034b5
编写于
12月 31, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(lite): add global layout transform python interface for lite
GitOrigin-RevId: f159f492082911a366dc5fe2f60f92af290636f4
上级
e70c07a2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
4 deletion
+48
-4
lite/include/lite/network.h
lite/include/lite/network.h
+1
-2
lite/pylite/megenginelite/network.py
lite/pylite/megenginelite/network.py
+9
-0
lite/pylite/test/test_network.py
lite/pylite/test/test_network.py
+17
-0
lite/pylite/test/test_network_cuda.py
lite/pylite/test/test_network_cuda.py
+19
-0
lite/src/mge/network_impl.cpp
lite/src/mge/network_impl.cpp
+1
-1
lite/test/test_network.cpp
lite/test/test_network.cpp
+1
-1
未找到文件。
lite/include/lite/network.h
浏览文件 @
f7e034b5
...
@@ -97,7 +97,7 @@ struct LITE_API Options {
...
@@ -97,7 +97,7 @@ struct LITE_API Options {
bool
no_profiling_on_shape_change
=
false
;
bool
no_profiling_on_shape_change
=
false
;
uint8_t
jit_level
=
0
;
uint8_t
jit_level
=
0
;
uint8_t
comp_node_seq_record_level
=
0
;
uint8_t
comp_node_seq_record_level
=
0
;
uint8_t
graph_opt_level
=
0
;
uint8_t
graph_opt_level
=
2
;
uint16_t
async_exec_level
=
1
;
uint16_t
async_exec_level
=
1
;
//! layout transform options
//! layout transform options
...
@@ -368,7 +368,6 @@ public:
...
@@ -368,7 +368,6 @@ public:
const
std
::
shared_ptr
<
Network
>
src_network
);
const
std
::
shared_ptr
<
Network
>
src_network
);
//! set global layout transform optimization for network
//! set global layout transform optimization for network
static
void
enable_global_layout_transform
(
std
::
shared_ptr
<
Network
>
network
);
static
void
enable_global_layout_transform
(
std
::
shared_ptr
<
Network
>
network
);
//! dump network after global layout transform optimization
//! dump network after global layout transform optimization
...
...
lite/pylite/megenginelite/network.py
浏览文件 @
f7e034b5
...
@@ -362,6 +362,8 @@ class _NetworkAPI(_LiteCObjBase):
...
@@ -362,6 +362,8 @@ class _NetworkAPI(_LiteCObjBase):
(
"LITE_set_start_callback"
,
[
_Cnetwork
,
LiteStartCallback
]),
(
"LITE_set_start_callback"
,
[
_Cnetwork
,
LiteStartCallback
]),
(
"LITE_set_finish_callback"
,
[
_Cnetwork
,
LiteFinishCallback
]),
(
"LITE_set_finish_callback"
,
[
_Cnetwork
,
LiteFinishCallback
]),
(
"LITE_get_static_memory_alloc_info"
,
[
_Cnetwork
,
c_char_p
]),
(
"LITE_get_static_memory_alloc_info"
,
[
_Cnetwork
,
c_char_p
]),
(
"LITE_enable_global_layout_transform"
,
[
_Cnetwork
]),
(
"LITE_dump_layout_transform_model"
,
[
_Cnetwork
,
c_char_p
]),
]
]
...
@@ -610,3 +612,10 @@ class LiteNetwork(object):
...
@@ -610,3 +612,10 @@ class LiteNetwork(object):
def
get_static_memory_alloc_info
(
self
,
log_dir
=
"logs/test"
):
def
get_static_memory_alloc_info
(
self
,
log_dir
=
"logs/test"
):
c_log_dir
=
log_dir
.
encode
(
"utf-8"
)
c_log_dir
=
log_dir
.
encode
(
"utf-8"
)
self
.
_api
.
LITE_get_static_memory_alloc_info
(
self
.
_network
,
c_log_dir
)
self
.
_api
.
LITE_get_static_memory_alloc_info
(
self
.
_network
,
c_log_dir
)
def
enable_global_layout_transform
(
self
):
self
.
_api
.
LITE_enable_global_layout_transform
(
self
.
_network
)
def
dump_layout_transform_model
(
self
,
model_file
):
c_file
=
model_file
.
encode
(
"utf-8"
)
self
.
_api
.
LITE_dump_layout_transform_model
(
self
.
_network
,
c_file
)
lite/pylite/test/test_network.py
浏览文件 @
f7e034b5
...
@@ -451,3 +451,20 @@ class TestNetwork(TestShuffleNet):
...
@@ -451,3 +451,20 @@ class TestNetwork(TestShuffleNet):
network
.
wait
()
network
.
wait
()
self
.
check_correct
(
out_array
)
self
.
check_correct
(
out_array
)
def
test_enable_global_layout_transform
(
self
):
network
=
LiteNetwork
()
network
.
enable_global_layout_transform
()
network
.
load
(
self
.
model_path
)
self
.
do_forward
(
network
)
def
test_dump_layout_transform_model
(
self
):
network
=
LiteNetwork
()
network
.
enable_global_layout_transform
()
network
.
load
(
self
.
model_path
)
network
.
dump_layout_transform_model
(
"./model_afer_layoutTrans.mgb"
)
self
.
do_forward
(
network
)
fi
=
open
(
"./model_afer_layoutTrans.mgb"
,
"r"
)
fi
.
close
()
os
.
remove
(
"./model_afer_layoutTrans.mgb"
)
lite/pylite/test/test_network_cuda.py
浏览文件 @
f7e034b5
...
@@ -272,3 +272,22 @@ class TestNetwork(TestShuffleNetCuda):
...
@@ -272,3 +272,22 @@ class TestNetwork(TestShuffleNetCuda):
|
LiteAlgoSelectStrategy
.
LITE_ALGO_REPRODUCIBLE
|
LiteAlgoSelectStrategy
.
LITE_ALGO_REPRODUCIBLE
)
)
self
.
do_forward
(
network
)
self
.
do_forward
(
network
)
@
require_cuda
()
def
test_enable_global_layout_transform
(
self
):
network
=
LiteNetwork
()
network
.
enable_global_layout_transform
()
network
.
load
(
self
.
model_path
)
self
.
do_forward
(
network
)
@
require_cuda
()
def
test_dump_layout_transform_model
(
self
):
network
=
LiteNetwork
()
network
.
enable_global_layout_transform
()
network
.
load
(
self
.
model_path
)
network
.
dump_layout_transform_model
(
"./model_afer_layoutTrans.mgb"
)
self
.
do_forward
(
network
)
fi
=
open
(
"./model_afer_layoutTrans.mgb"
,
"r"
)
fi
.
close
()
os
.
remove
(
"./model_afer_layoutTrans.mgb"
)
lite/src/mge/network_impl.cpp
浏览文件 @
f7e034b5
...
@@ -406,7 +406,7 @@ void NetworkImplDft::load_model(
...
@@ -406,7 +406,7 @@ void NetworkImplDft::load_model(
use_tensorrt
();
use_tensorrt
();
}
}
m_load_result
=
m_loader
->
load
(
m_load_config
,
fals
e
);
m_load_result
=
m_loader
->
load
(
m_load_config
,
tru
e
);
global_layout_transform
();
global_layout_transform
();
...
...
lite/test/test_network.cpp
浏览文件 @
f7e034b5
...
@@ -910,7 +910,6 @@ TEST(TestNetWork, LoadPackedModel) {
...
@@ -910,7 +910,6 @@ TEST(TestNetWork, LoadPackedModel) {
}
}
TEST
(
TestNetWork
,
GlabalLayoutTransform
)
{
TEST
(
TestNetWork
,
GlabalLayoutTransform
)
{
// set_log_level(LiteLogLevel::DEBUG);
auto
tensor
=
get_input_data
(
"./input_data.npy"
);
auto
tensor
=
get_input_data
(
"./input_data.npy"
);
std
::
string
model_path
=
"./shufflenet.mge"
;
std
::
string
model_path
=
"./shufflenet.mge"
;
std
::
string
input_name
=
"data"
;
std
::
string
input_name
=
"data"
;
...
@@ -931,6 +930,7 @@ TEST(TestNetWork, GlabalLayoutTransform) {
...
@@ -931,6 +930,7 @@ TEST(TestNetWork, GlabalLayoutTransform) {
network
->
forward
();
network
->
forward
();
network
->
wait
();
network
->
wait
();
ASSERT_TRUE
(
fopen
(
dump_model_name
.
c_str
(),
"r"
));
ASSERT_TRUE
(
fopen
(
dump_model_name
.
c_str
(),
"r"
));
remove
(
dump_model_name
.
c_str
());
}
}
TEST
(
TestNetWork
,
GetDeviceType
)
{
TEST
(
TestNetWork
,
GetDeviceType
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录