Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
6bb9772c
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
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看板
提交
6bb9772c
编写于
7月 13, 2023
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(lite): support set the consistent stream id when multiconpnode
GitOrigin-RevId: 2eed8c2fbd6079c9cfc24e40e2746361c99f9796
上级
ba9f67eb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
4 deletion
+41
-4
lite/src/mge/network_impl.cpp
lite/src/mge/network_impl.cpp
+15
-3
lite/src/network_impl_base.h
lite/src/network_impl_base.h
+2
-1
lite/test/test_network.cpp
lite/test/test_network.cpp
+24
-0
未找到文件。
lite/src/mge/network_impl.cpp
浏览文件 @
6bb9772c
...
...
@@ -112,10 +112,22 @@ void NetworkImplDft::application_config() {
loc
.
type
=
m_compnode_locator
.
type
;
}
loc
.
device
=
m_compnode_locator
.
device
;
//! the user configured stream
auto
stream
=
m_compnode_locator
.
stream
;
//! if user set the thread number and the compnode is multithread
if
(
loc
.
type
==
mgb
::
CompNode
::
DeviceType
::
MULTITHREAD
&&
m_nr_threads
!=
1
)
{
loc
.
stream
=
m_nr_threads
;
if
(
loc
.
type
==
mgb
::
CompNode
::
DeviceType
::
MULTITHREAD
)
{
if
(
m_nr_threads
!=
1
)
{
loc
.
nr_threads
=
m_nr_threads
;
}
//! user set the stream to separate the different multithread
if
(
stream
!=
0
)
{
auto
device
=
m_compnode_locator
.
device
;
//! the device is also set by user, so combine them to one
//! int
if
(
device
==
-
1
)
{
loc
.
device
=
stream
;
}
}
}
else
{
loc
.
stream
=
m_compnode_locator
.
stream
;
}
...
...
lite/src/network_impl_base.h
浏览文件 @
6bb9772c
...
...
@@ -148,7 +148,8 @@ public:
virtual
void
set_device_id
(
int
device_id
)
=
0
;
virtual
int
get_device_id
()
const
=
0
;
virtual
LiteBackend
get_backend_type
()
const
=
0
;
//! set stream id, default stream id = 0
//! set stream id, default stream id = 0, if there are multi compnode in a
//! model, set all the compnode stream to the stream_id
virtual
void
set_stream_id
(
int
stream_id
)
=
0
;
virtual
int
get_stream_id
()
const
=
0
;
...
...
lite/test/test_network.cpp
浏览文件 @
6bb9772c
...
...
@@ -1665,6 +1665,30 @@ TEST(TestNetWork, AtlasLoadAtlasDeviceInput) {
TEST
(
TestNetWork
,
AtlasDeviceID
)
{
load_device_id
(
LiteDeviceType
::
LITE_ATLAS
,
1
,
"./model_atlas.mgb"
);
}
TEST
(
TestNetWork
,
AtlasCrossCompnodeStreamID
)
{
auto
thread
=
[](
int
stream_id
)
{
lite
::
Config
config
;
config
.
device_type
=
LiteDeviceType
::
LITE_ATLAS
;
auto
network
=
std
::
make_shared
<
lite
::
Network
>
(
config
);
network
->
set_stream_id
(
stream_id
);
network
->
load_model
(
"./model_atlas.mgb"
);
std
::
shared_ptr
<
Tensor
>
input_tensor
=
network
->
get_input_tensor
(
0
);
std
::
shared_ptr
<
Tensor
>
output_tensor
=
network
->
get_output_tensor
(
0
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
network
->
forward
();
network
->
wait
();
}
};
std
::
thread
t0
(
thread
,
1
);
std
::
thread
t1
(
thread
,
2
);
std
::
thread
t2
(
thread
,
3
);
std
::
thread
t3
(
thread
,
4
);
t0
.
join
();
t1
.
join
();
t2
.
join
();
t3
.
join
();
}
#endif
#if MGB_CAMBRICON
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录