Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
5821c0b6
MegEngine
项目概览
MegEngine 天元
/
MegEngine
9 个月 前同步成功
通知
392
Star
4702
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,体验更适合开发者的 AI 搜索 >>
提交
5821c0b6
编写于
4月 19, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs(lite): initial part of lite::Tensor comments as template
GitOrigin-RevId: d89636f1f6baed68a85c8d535d3a69ddb47de2cc
上级
26c2563b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
17 deletion
+41
-17
lite/include/lite/tensor.h
lite/include/lite/tensor.h
+41
-17
未找到文件。
lite/include/lite/tensor.h
浏览文件 @
5821c0b6
...
...
@@ -28,19 +28,27 @@ struct LITE_API Layout {
/*!
* \brief warpper of the MegEngine Tensor
*
* The memory is not alloc directly, when call get_memory_ptr() the memory
* will be allocated in tensor implement, which will be deleted automatically
* \verbatim embed:rst:leading-asterisk
*
* Note: if the tensor memory is set through reset() interface, the memory is
* managed by the user, it will not be freed by the tensor
* Some more things here.
*
* If the device or layout is not set, when copy form other source tensor, its
* device and layout will be copy form the source tensor
* .. note::
*
* if is_pinned_host is set, the storage memory of the tensor is pinned memory,
* this is used to Optimize the H2D or D2H memory copy, if the device or layout
* is not set, when copy form other device(CUDA) tensor, this tensor
* will be automatically set to pinned tensor
* * If the tensor memory is set through :cpp:func:`~reset()` interface, the memory
* is managed by the user, it will not be freed by the tensor;
* * If the ``device_type`` or ``layout`` is not set, when copy form other source
* tensor, its device and layout will be copy form the source tensor;
* * If ``is_pinned_host`` is set, the storage memory of the tensor is pinned memory,
* this is used to Optimize the H2D or D2H memory copy, if the device or layout
* is not set, when copy form other device(CUDA) tensor, this tensor
* will be automatically set to pinned tensor.
*
* .. warning::
*
* The memory is not alloc directly, when call :cpp:func:`get_memory_ptr()` the
* memory will be allocated in tensor implement, which will be deleted automatically.
*
* \endverbatim
*/
class
LITE_API
Tensor
{
class
TensorImpl
;
...
...
@@ -48,6 +56,16 @@ class LITE_API Tensor {
public:
class
TensorImplBase
;
/*!
* @name Constructor
*
* @param device_type The desired device type of created Tensor.
* @param device_id The desired device id of created Tensor.
* @param is_pinned_host Whether to use pinned memory.
* @param layout The desired layout of created Tensor.
*
*/
//@{
Tensor
();
Tensor
(
LiteDeviceType
device_type
,
bool
is_pinned_host
=
false
);
Tensor
(
LiteDeviceType
device_type
,
const
Layout
&
layout
,
...
...
@@ -58,8 +76,13 @@ public:
bool
is_pinned_host
=
false
);
Tensor
(
LiteBackend
backend
,
LiteDeviceType
device_type
=
LiteDeviceType
::
LITE_CPU
,
int
device_id
=
0
,
const
Layout
&
layout
=
{},
bool
is_pinned_host
=
false
);
//@}
~
Tensor
();
/*!
* @name Getter
*/
//@{
LiteDeviceType
get_device_type
()
const
{
return
m_device_type
;
};
int
get_device_id
()
const
{
return
m_device_id
;
};
...
...
@@ -68,9 +91,6 @@ public:
bool
is_pinned_host
()
const
{
return
m_is_pinned_host
;
};
//! set layout will change the layout and reallocate memory of the tensor
void
set_layout
(
const
Layout
&
layout
);
//! which will trigger memory alloc in tensor implement
void
*
get_memory_ptr
()
const
;
...
...
@@ -80,6 +100,13 @@ public:
//! get the tensor capacity in byte
size_t
get_tensor_total_size_in_byte
()
const
;
//! whether the memory of tensor is continue
bool
is_continue_memory
()
const
;
//@}
//! set layout will change the layout and reallocate memory of the tensor
void
set_layout
(
const
Layout
&
layout
);
//! use the user allocated data to reset the memory of the tensor, the
//! memory will not be managed by the lite, later, the user should delete
//! it.
...
...
@@ -102,7 +129,7 @@ public:
void
fill_zero
();
//! copy tensor form other tensor
//!
Note:
the best way for tensor copy is just set the dst device, left
//!
@note
the best way for tensor copy is just set the dst device, left
//! layout empty, when copying the dst layout will be set the same with
//! src
void
copy_from
(
const
Tensor
&
src
);
...
...
@@ -110,9 +137,6 @@ public:
//! share memory with other tensor
void
share_memory_with
(
const
Tensor
&
src_tensor
);
//! whether the memory of tensor is continue
bool
is_continue_memory
()
const
;
//! update the menbers from the implement
void
update_from_implement
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录