Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
d5ef7923
MegEngine
项目概览
MegEngine 天元
/
MegEngine
11 个月 前同步成功
通知
393
Star
4703
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d5ef7923
编写于
1月 26, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf(lite): optimized lite tensor get data by share
GitOrigin-RevId: 62e48ca53926514b87df35e5e08df904949518be
上级
ce9ad07a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
10 deletion
+12
-10
lite/lite-c/include/lite-c/global_c.h
lite/lite-c/include/lite-c/global_c.h
+1
-1
lite/lite-c/src/global.cpp
lite/lite-c/src/global.cpp
+1
-1
lite/pylite/megenginelite/tensor.py
lite/pylite/megenginelite/tensor.py
+10
-8
未找到文件。
lite/lite-c/include/lite-c/global_c.h
浏览文件 @
d5ef7923
...
@@ -173,7 +173,7 @@ LITE_API int LITE_register_memory_pair(
...
@@ -173,7 +173,7 @@ LITE_API int LITE_register_memory_pair(
* clear the physical and virtual address pair in mge.
* clear the physical and virtual address pair in mge.
*/
*/
LITE_API
int
LITE_clear_memory_pair
(
LITE_API
int
LITE_clear_memory_pair
(
void
*
phy_ptr
,
void
*
vir
_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
void
*
vir_ptr
,
void
*
phy
_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
lite/lite-c/src/global.cpp
浏览文件 @
d5ef7923
...
@@ -198,7 +198,7 @@ int LITE_register_memory_pair(
...
@@ -198,7 +198,7 @@ int LITE_register_memory_pair(
}
}
int
LITE_clear_memory_pair
(
int
LITE_clear_memory_pair
(
void
*
phy_ptr
,
void
*
vir
_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
void
*
vir_ptr
,
void
*
phy
_ptr
,
LiteDeviceType
device
,
LiteBackend
backend
)
{
LITE_CAPI_BEGIN
();
LITE_CAPI_BEGIN
();
lite
::
clear_memory_pair
(
vir_ptr
,
phy_ptr
,
device
,
backend
);
lite
::
clear_memory_pair
(
vir_ptr
,
phy_ptr
,
device
,
backend
);
LITE_CAPI_END
();
LITE_CAPI_END
();
...
...
lite/pylite/megenginelite/tensor.py
浏览文件 @
d5ef7923
...
@@ -225,6 +225,7 @@ class LiteTensor(object):
...
@@ -225,6 +225,7 @@ class LiteTensor(object):
tensor_desc
.
device_id
=
device_id
tensor_desc
.
device_id
=
device_id
tensor_desc
.
is_pinned_host
=
is_pinned_host
tensor_desc
.
is_pinned_host
=
is_pinned_host
self
.
_api
.
LITE_make_tensor
(
tensor_desc
,
byref
(
self
.
_tensor
))
self
.
_api
.
LITE_make_tensor
(
tensor_desc
,
byref
(
self
.
_tensor
))
self
.
update
()
def
__del__
(
self
):
def
__del__
(
self
):
self
.
_api
.
LITE_destroy_tensor
(
self
.
_tensor
)
self
.
_api
.
LITE_destroy_tensor
(
self
.
_tensor
)
...
@@ -318,6 +319,11 @@ class LiteTensor(object):
...
@@ -318,6 +319,11 @@ class LiteTensor(object):
self
.
_device_type
=
device_type
self
.
_device_type
=
device_type
self
.
_api
.
LITE_get_tensor_layout
(
self
.
_tensor
,
byref
(
self
.
_layout
))
self
.
_api
.
LITE_get_tensor_layout
(
self
.
_tensor
,
byref
(
self
.
_layout
))
c_types
=
_lite_dtypes_to_ctype
[
self
.
_layout
.
data_type
]
self
.
np_array_type
=
np
.
ctypeslib
.
_ctype_ndarray
(
c_types
,
list
(
self
.
_layout
.
shapes
)[
0
:
self
.
_layout
.
ndim
]
)
def
copy_from
(
self
,
src_tensor
):
def
copy_from
(
self
,
src_tensor
):
"""
"""
copy memory form the src_tensor
copy memory form the src_tensor
...
@@ -447,15 +453,11 @@ class LiteTensor(object):
...
@@ -447,15 +453,11 @@ class LiteTensor(object):
return the numpy arrray, be careful, the data in numpy is valid before
return the numpy arrray, be careful, the data in numpy is valid before
the tensor memory is write again, such as LiteNetwok forward next time.
the tensor memory is write again, such as LiteNetwok forward next time.
"""
"""
assert
self
.
is_continue
,
"get_data_by_share can only apply in continue tensor."
assert
(
self
.
is_pinned_host
or
self
.
device_type
==
LiteDeviceType
.
LITE_CPU
),
"get_data_by_share can only apply in CPU tensor or cpu pinned tensor."
memory
=
self
.
get_ctypes_memory
()
buffer
=
c_void_p
()
c_type
=
_lite_dtypes_to_ctype
[
LiteDataType
(
self
.
_layout
.
data_type
)]
self
.
_api
.
LITE_get_tensor_memory
(
self
.
_tensor
,
byref
(
buffer
))
pnt
=
cast
(
memory
,
POINTER
(
c_type
)
)
buffer
=
self
.
np_array_type
.
from_address
(
buffer
.
value
)
return
np
.
ctypeslib
.
as_array
(
pnt
,
self
.
_layout
.
shapes
)
return
np
.
ctypeslib
.
as_array
(
buffer
)
def
to_numpy
(
self
):
def
to_numpy
(
self
):
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录