Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
b04c3d14
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看板
提交
b04c3d14
编写于
1月 21, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(lite): add set address ptr pair interface
GitOrigin-RevId: 285dacb4da51cb1e23f411967d612bb520d611d8
上级
17f2dffb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
101 addition
and
1 deletion
+101
-1
.gitattributes
.gitattributes
+3
-0
lite/include/lite/global.h
lite/include/lite/global.h
+15
-0
lite/lite-c/include/lite-c/global_c.h
lite/lite-c/include/lite-c/global_c.h
+16
-1
lite/lite-c/src/global.cpp
lite/lite-c/src/global.cpp
+15
-0
lite/pylite/megenginelite/global_setting.py
lite/pylite/megenginelite/global_setting.py
+20
-0
lite/pylite/test/test_network_device.py
lite/pylite/test/test_network_device.py
+0
-0
lite/src/global.cpp
lite/src/global.cpp
+31
-0
lite/test/test_network.cpp
lite/test/test_network.cpp
+1
-0
未找到文件。
.gitattributes
浏览文件 @
b04c3d14
...
...
@@ -21,3 +21,6 @@ ci/resource/prof/model_with_err_assert.mdl filter=lfs diff=lfs merge=lfs -text
ci/resource/prof/test_mge.mge filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/ax_models/64-58063ce2.axe filter=lfs diff=lfs merge=lfs -text
imperative/python/test/unit/module/MagicMindRuntimeOprTest.GraphShapeMutable.mlu filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/ax_data_input.npy filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/ax_data_output.npy filter=lfs diff=lfs merge=lfs -text
lite/test/resource/lite/ax_model.mge filter=lfs diff=lfs merge=lfs -text
lite/include/lite/global.h
浏览文件 @
b04c3d14
...
...
@@ -154,6 +154,21 @@ LITE_API void set_tensor_rt_cache(std::string tensorrt_cache_path);
*/
LITE_API
void
dump_tensor_rt_cache
();
/**
* register the physical and virtual address pair to the mge, some device
* need the map from physical to virtual.
*/
LITE_API
bool
register_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
size_t
length
,
LiteDeviceType
device
,
LiteBackend
backend
=
LiteBackend
::
LITE_DEFAULT
);
/**
* clear the physical and virtual address pair in mge.
*/
LITE_API
bool
clear_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
=
LiteBackend
::
LITE_DEFAULT
);
}
// namespace lite
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/lite-c/include/lite-c/global_c.h
浏览文件 @
b04c3d14
...
...
@@ -160,9 +160,24 @@ LITE_API int LITE_dump_persistent_cache(const char* cache_path);
* \brief dump the tensorrt policy cache to file
*/
LITE_API
int
LITE_dump_tensor_rt_cache
();
#endif
/**
* register the physical and virtual address pair to the mge, some device
* need the map from physical to virtual.
*/
LITE_API
int
LITE_register_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
size_t
length
,
LiteDeviceType
device
,
LiteBackend
backend
);
/**
* clear the physical and virtual address pair in mge.
*/
LITE_API
int
LITE_clear_memory_pair
(
void
*
phy_ptr
,
void
*
vir_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
#ifdef __cplusplus
}
#endif
#endif
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/lite-c/src/global.cpp
浏览文件 @
b04c3d14
...
...
@@ -189,4 +189,19 @@ int LITE_dump_tensor_rt_cache() {
LITE_CAPI_END
();
}
int
LITE_register_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
size_t
length
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_CAPI_BEGIN
();
lite
::
register_memory_pair
(
vir_ptr
,
phy_ptr
,
length
,
device
,
backend
);
LITE_CAPI_END
();
}
int
LITE_clear_memory_pair
(
void
*
phy_ptr
,
void
*
vir_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_CAPI_BEGIN
();
lite
::
clear_memory_pair
(
vir_ptr
,
phy_ptr
,
device
,
backend
);
LITE_CAPI_END
();
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
lite/pylite/megenginelite/global_setting.py
浏览文件 @
b04c3d14
...
...
@@ -42,6 +42,8 @@ class _GlobalAPI(_LiteCObjBase):
# ('LITE_set_tensor_rt_cache', [c_char_p]),
(
"LITE_dump_persistent_cache"
,
[
c_char_p
]),
(
"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
]),
]
...
...
@@ -121,3 +123,21 @@ class LiteGlobal(object):
@
staticmethod
def
try_coalesce_all_free_memory
():
LiteGlobal
.
_api
.
LITE_try_coalesce_all_free_memory
()
@
staticmethod
def
register_memory_pair
(
vir_ptr
,
phy_ptr
,
length
,
device
,
backend
=
LiteBackend
.
LITE_DEFAULT
):
assert
isinstance
(
vir_ptr
,
c_void_p
)
and
isinstance
(
phy_ptr
,
c_void_p
),
"clear memory pair only accept c_void_p type."
LiteGlobal
.
_api
.
LITE_register_memory_pair
(
vir_ptr
,
phy_ptr
,
length
,
device
,
backend
)
@
staticmethod
def
clear_memory_pair
(
vir_ptr
,
phy_ptr
,
device
,
backend
=
LiteBackend
.
LITE_DEFAULT
):
assert
isinstance
(
vir_ptr
,
c_void_p
)
and
isinstance
(
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
)
lite/pylite/test/test_network_
cuda
.py
→
lite/pylite/test/test_network_
device
.py
浏览文件 @
b04c3d14
文件已移动
lite/src/global.cpp
浏览文件 @
b04c3d14
...
...
@@ -212,6 +212,26 @@ void lite::dump_tensor_rt_cache() {
#endif
}
bool
lite
::
register_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
size_t
length
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_MARK_USED_VAR
(
vir_ptr
);
LITE_MARK_USED_VAR
(
phy_ptr
);
LITE_MARK_USED_VAR
(
length
);
LITE_MARK_USED_VAR
(
device
);
LITE_MARK_USED_VAR
(
backend
);
LITE_THROW
(
"register_memory_pair is not implement yet!"
);
}
bool
lite
::
clear_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_MARK_USED_VAR
(
vir_ptr
);
LITE_MARK_USED_VAR
(
phy_ptr
);
LITE_MARK_USED_VAR
(
device
);
LITE_MARK_USED_VAR
(
backend
);
LITE_THROW
(
"clear_memory_pair is not implement yet!"
);
}
#else // LITE_BUILD_WITH_MGE
void
lite
::
try_coalesce_all_free_memory
()
{}
...
...
@@ -235,6 +255,17 @@ void lite::set_tensor_rt_cache(std::string) {
void
lite
::
dump_tensor_rt_cache
()
{
LITE_THROW
(
"mge is disbale at build time, please build with mge"
);
}
bool
lite
::
register_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
size_t
length
,
LiteDeviceType
device
,
LiteBackend
beckend
)
{
LITE_THROW
(
"register_memory_pair is not implement yet!"
);
}
bool
lite
::
clear_memory_pair
(
void
*
vir_ptr
,
void
*
phy_ptr
,
LiteDeviceType
device
,
LiteBackend
beckend
)
{
LITE_THROW
(
"clear_memory_pair is not implement yet!"
);
}
#endif
namespace
lite
{
REGIST_DECRYPTION_METHOD
(
...
...
lite/test/test_network.cpp
浏览文件 @
b04c3d14
...
...
@@ -1357,5 +1357,6 @@ TEST(TestNetWork, CambriconDeviceID) {
load_device_id
(
LiteDeviceType
::
LITE_CAMBRICON
,
0
,
"./model_magicmind.mgb"
);
}
#endif
#endif
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录