Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
87447df0
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看板
提交
87447df0
编写于
11月 17, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(lite): fix lite zero copy
GitOrigin-RevId: 3ceacb452438c1ad5987890bc513fc0c97787b82
上级
f16e4311
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
12 deletion
+18
-12
.gitattributes
.gitattributes
+1
-0
lite/src/mge/network_impl.cpp
lite/src/mge/network_impl.cpp
+11
-9
lite/src/mge/tensor_impl.cpp
lite/src/mge/tensor_impl.cpp
+6
-3
未找到文件。
.gitattributes
浏览文件 @
87447df0
...
@@ -30,3 +30,4 @@ lite/test/resource/lite/resnet50_input.npy filter=lfs diff=lfs merge=lfs -text
...
@@ -30,3 +30,4 @@ lite/test/resource/lite/resnet50_input.npy filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/resnet50.mge filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/resnet50.mge filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/resnet50_uint8.mge filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/resnet50_uint8.mge filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/cat.ppm filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/cat.ppm filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/ax_model_zero_copy.mge filter=lfs diff=lfs merge=lfs -text
lite/src/mge/network_impl.cpp
浏览文件 @
87447df0
...
@@ -585,17 +585,18 @@ void NetworkImplDft::configure_after_loaded() {
...
@@ -585,17 +585,18 @@ void NetworkImplDft::configure_after_loaded() {
cross_compnode_model_detect
();
cross_compnode_model_detect
();
//! update the IO of the network
//! update the IO of the network
update_io
();
update_input
();
replace_dev_input_pass
();
if
(
!
m_user_config
->
discrete_input_name
.
empty
())
{
replace_src_discrete_input_opr_pass
();
}
update_output
();
//! replace the IO when there is device input or output
//! replace the IO when there is device input or output
compile_graph
();
compile_graph
();
}
}
void
NetworkImplDft
::
compile_graph
()
{
void
NetworkImplDft
::
compile_graph
()
{
replace_dev_input_pass
();
if
(
!
m_user_config
->
discrete_input_name
.
empty
())
{
replace_src_discrete_input_opr_pass
();
}
make_output_spec
();
make_output_spec
();
m_execute_func
=
m_load_result
.
graph_compile
(
m_output_spec
);
m_execute_func
=
m_load_result
.
graph_compile
(
m_output_spec
);
}
}
...
@@ -882,24 +883,25 @@ void NetworkImplDft::update_output() {
...
@@ -882,24 +883,25 @@ void NetworkImplDft::update_output() {
}
else
{
}
else
{
for
(
auto
&&
out
:
m_load_result
.
output_var_list
)
{
for
(
auto
&&
out
:
m_load_result
.
output_var_list
)
{
std
::
shared_ptr
<
Tensor
>
lite_tensor
=
nullptr
;
std
::
shared_ptr
<
Tensor
>
lite_tensor
=
nullptr
;
auto
device
=
get_device_from_locator
(
out
.
node
()
->
comp_node
().
locator
());
auto
it
=
std
::
find_if
(
auto
it
=
std
::
find_if
(
m_network_io
->
outputs
.
begin
(),
m_network_io
->
outputs
.
end
(),
m_network_io
->
outputs
.
begin
(),
m_network_io
->
outputs
.
end
(),
[
&
out
](
const
IOInner
io
)
{
return
io
.
name
==
out
.
node
()
->
name
();
});
[
&
out
](
const
IOInner
io
)
{
return
io
.
name
==
out
.
node
()
->
name
();
});
if
(
it
!=
m_network_io
->
outputs
.
end
())
{
if
(
it
!=
m_network_io
->
outputs
.
end
())
{
if
(
it
->
is_host
)
{
if
(
it
->
is_host
)
{
it
->
lite_tensor
=
std
::
make_shared
<
Tensor
>
(
it
->
lite_tensor
=
std
::
make_shared
<
Tensor
>
(
device_id
,
stream_id
,
device
_type
,
true
);
device_id
,
stream_id
,
device
,
true
);
}
else
{
}
else
{
it
->
lite_tensor
=
it
->
lite_tensor
=
std
::
make_shared
<
Tensor
>
(
device_id
,
stream_id
,
device
_type
);
std
::
make_shared
<
Tensor
>
(
device_id
,
stream_id
,
device
);
}
}
try_infer_tensor_layout
(
it
->
lite_tensor
,
out
);
try_infer_tensor_layout
(
it
->
lite_tensor
,
out
);
lite_tensor
=
it
->
lite_tensor
;
lite_tensor
=
it
->
lite_tensor
;
}
else
{
}
else
{
IOInner
output
;
IOInner
output
;
output
.
name
=
out
.
node
()
->
name
();
output
.
name
=
out
.
node
()
->
name
();
output
.
lite_tensor
=
std
::
make_shared
<
Tensor
>
(
output
.
lite_tensor
=
device_id
,
stream_id
,
device_typ
e
,
true
);
std
::
make_shared
<
Tensor
>
(
device_id
,
stream_id
,
devic
e
,
true
);
m_network_io
->
outputs
.
push_back
({
output
});
m_network_io
->
outputs
.
push_back
({
output
});
try_infer_tensor_layout
(
output
.
lite_tensor
,
out
);
try_infer_tensor_layout
(
output
.
lite_tensor
,
out
);
lite_tensor
=
output
.
lite_tensor
;
lite_tensor
=
output
.
lite_tensor
;
...
...
lite/src/mge/tensor_impl.cpp
浏览文件 @
87447df0
...
@@ -452,9 +452,12 @@ void TensorImplDft::device_share_host_memory() {
...
@@ -452,9 +452,12 @@ void TensorImplDft::device_share_host_memory() {
m_host_tensor
->
comp_node
(),
m_host_tensor
->
layout
());
m_host_tensor
->
comp_node
(),
m_host_tensor
->
layout
());
}
}
if
(
m_host_tensor
->
raw_ptr
()
!=
m_dev_tensor
->
raw_ptr
())
{
if
(
m_host_tensor
->
raw_ptr
()
!=
m_dev_tensor
->
raw_ptr
())
{
auto
&&
storage
=
auto
&
host_storage
=
m_host_tensor
->
storage
();
mgb
::
DeviceTensorStorage
::
make_proxy
(
m_host_tensor
->
storage
());
mgb
::
DeviceTensorStorage
device_storage
;
m_dev_tensor
->
only_reset_raw_storage
(
storage
);
device_storage
.
reset
(
host_storage
.
comp_node
(),
host_storage
.
size
(),
host_storage
.
raw_storage
());
m_dev_tensor
->
only_reset_raw_storage
(
device_storage
);
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录