Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
73b518b7
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看板
提交
73b518b7
编写于
2月 22, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(lite): add get physic addr interface in lite
GitOrigin-RevId: e5a9eb199999a0fe7af5a0401b927f1ded42be05
上级
f67086ad
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
56 addition
and
0 deletion
+56
-0
lite/include/lite/global.h
lite/include/lite/global.h
+5
-0
lite/lite-c/include/lite-c/global_c.h
lite/lite-c/include/lite-c/global_c.h
+6
-0
lite/lite-c/src/global.cpp
lite/lite-c/src/global.cpp
+8
-0
lite/pylite/megenginelite/global_setting.py
lite/pylite/megenginelite/global_setting.py
+10
-0
lite/pylite/test/test_global.py
lite/pylite/test/test_global.py
+14
-0
lite/src/global.cpp
lite/src/global.cpp
+13
-0
未找到文件。
lite/include/lite/global.h
浏览文件 @
73b518b7
...
...
@@ -169,6 +169,11 @@ LITE_API bool clear_memory_pair(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
=
LiteBackend
::
LITE_DEFAULT
);
/**
* get the physic address by the virtual address in mge.
*/
void
*
lookup_physic_ptr
(
void
*
vir_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
}
// namespace lite
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/lite-c/include/lite-c/global_c.h
浏览文件 @
73b518b7
...
...
@@ -175,6 +175,12 @@ LITE_API int LITE_register_memory_pair(
LITE_API
int
LITE_clear_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
/**
* get the physical by the virtual address pair in mge.
*/
LITE_API
int
LITE_lookup_physic_ptr
(
void
*
vir_ptr
,
void
**
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
#ifdef __cplusplus
}
#endif
...
...
lite/lite-c/src/global.cpp
浏览文件 @
73b518b7
...
...
@@ -204,4 +204,12 @@ int LITE_clear_memory_pair(
LITE_CAPI_END
();
}
int
LITE_lookup_physic_ptr
(
void
*
vir_ptr
,
void
**
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_CAPI_BEGIN
();
LITE_ASSERT
(
vir_ptr
&&
phy_ptr
,
"The ptr pass to vir and phy is nullptr"
);
*
phy_ptr
=
lite
::
lookup_physic_ptr
(
vir_ptr
,
device
,
backend
);
LITE_CAPI_END
();
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/pylite/megenginelite/global_setting.py
浏览文件 @
73b518b7
...
...
@@ -44,6 +44,7 @@ class _GlobalAPI(_LiteCObjBase):
(
"LITE_dump_tensor_rt_cache"
,
[
c_char_p
]),
(
"LITE_register_memory_pair"
,
[
c_void_p
,
c_void_p
,
c_size_t
,
c_int
,
c_int
]),
(
"LITE_clear_memory_pair"
,
[
c_void_p
,
c_void_p
,
c_int
,
c_int
]),
(
"LITE_lookup_physic_ptr"
,
[
c_void_p
,
POINTER
(
c_void_p
),
c_int
,
c_int
]),
]
...
...
@@ -141,3 +142,12 @@ class LiteGlobal(object):
phy_ptr
,
c_void_p
),
"clear memory pair only accept c_void_p type."
LiteGlobal
.
_api
.
LITE_clear_memory_pair
(
vir_ptr
,
phy_ptr
,
device
,
backend
)
@
staticmethod
def
lookup_physic_ptr
(
vir_ptr
,
device
,
backend
=
LiteBackend
.
LITE_DEFAULT
):
assert
isinstance
(
vir_ptr
,
c_void_p
),
"lookup physic ptr only accept c_void_p type."
mem
=
c_void_p
()
LiteGlobal
.
_api
.
LITE_lookup_physic_ptr
(
vir_ptr
,
byref
(
mem
),
device
,
backend
)
return
mem
lite/pylite/test/test_global.py
浏览文件 @
73b518b7
...
...
@@ -9,6 +9,7 @@
import
os
import
unittest
from
ctypes
import
*
import
numpy
as
np
...
...
@@ -71,3 +72,16 @@ class TestGlobal(TestShuffleNet):
network
.
load
(
model_path
)
self
.
do_forward
(
network
)
def
test_set_get_memory_pair
(
self
):
if
LiteGlobal
.
get_device_count
(
LiteDeviceType
.
LITE_AX
)
>
0
:
arr1
=
np
.
ones
([
2
,
3
])
arr2
=
np
.
ones
([
2
,
3
])
vir_ptr
=
arr1
.
ctypes
.
data_as
(
c_void_p
)
phy_ptr
=
arr2
.
ctypes
.
data_as
(
c_void_p
)
LiteGlobal
.
register_memory_pair
(
vir_ptr
,
phy_ptr
,
10
,
LiteDeviceType
.
LITE_AX
)
phy_ptr2
=
LiteGlobal
.
lookup_physic_ptr
(
vir_ptr
,
LiteDeviceType
.
LITE_AX
)
assert
phy_ptr
.
value
==
phy_ptr2
.
value
LiteGlobal
.
clear_memory_pair
(
vir_ptr
,
phy_ptr
,
LiteDeviceType
.
LITE_AX
)
lite/src/global.cpp
浏览文件 @
73b518b7
...
...
@@ -232,6 +232,14 @@ bool lite::clear_memory_pair(
LITE_THROW
(
"clear_memory_pair is not implement yet!"
);
}
void
*
lite
::
lookup_physic_ptr
(
void
*
vir_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_MARK_USED_VAR
(
vir_ptr
);
LITE_MARK_USED_VAR
(
device
);
LITE_MARK_USED_VAR
(
backend
);
LITE_THROW
(
"lookup_physic_ptr is not implement yet!"
);
}
#else // LITE_BUILD_WITH_MGE
void
lite
::
try_coalesce_all_free_memory
()
{}
...
...
@@ -266,6 +274,11 @@ bool lite::clear_memory_pair(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
beckend
)
{
LITE_THROW
(
"clear_memory_pair is not implement yet!"
);
}
void
*
lite
::
lookup_physic_ptr
(
void
*
vir_ptr
,
LiteDeviceType
device
,
LiteBackend
beckend
)
{
LITE_THROW
(
"lookup_physic_ptr is not implement yet!"
);
}
#endif
namespace
lite
{
REGIST_DECRYPTION_METHOD
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录