Managed Tensor. The array is backed by reference counted blocks.
More...
#include <tensor.h>
Managed Tensor. The array is backed by reference counted blocks.
◆ Container
◆ Tensor() [1/5]
tvm::runtime::Tensor::Tensor |
( |
| ) |
|
|
default |
◆ Tensor() [2/5]
tvm::runtime::Tensor::Tensor |
( |
ObjectPtr< ffi::TensorObj > |
data | ) |
|
|
inlineexplicit |
constructor.
- Parameters
-
data | ObjectPtr to the data container. |
◆ Tensor() [3/5]
tvm::runtime::Tensor::Tensor |
( |
ffi::UnsafeInit |
tag | ) |
|
|
inlineexplicit |
◆ Tensor() [4/5]
tvm::runtime::Tensor::Tensor |
( |
ffi::Tensor && |
other | ) |
|
|
inline |
◆ Tensor() [5/5]
tvm::runtime::Tensor::Tensor |
( |
const ffi::Tensor & |
other | ) |
|
|
inline |
◆ CopyFrom() [1/2]
void tvm::runtime::Tensor::CopyFrom |
( |
const DLTensor * |
other | ) |
|
|
inline |
Copy data content from another array.
- Parameters
-
other | The source array to be copied from. |
- Note
- The copy may happen asynchronously if it involves a GPU context. TVMSynchronize is necessary.
◆ CopyFrom() [2/2]
void tvm::runtime::Tensor::CopyFrom |
( |
const Tensor & |
other | ) |
|
|
inline |
◆ CopyFromBytes()
void tvm::runtime::Tensor::CopyFromBytes |
( |
const void * |
data, |
|
|
size_t |
nbytes |
|
) |
| |
Copy data content from a byte buffer.
- Parameters
-
data | The source bytes to be copied from. |
nbytes | The size of the buffer in bytes Must be equal to the size of the Tensor. |
- Note
- The copy always triggers a TVMSynchronize.
◆ CopyFromTo()
static void tvm::runtime::Tensor::CopyFromTo |
( |
const DLTensor * |
from, |
|
|
DLTensor * |
to, |
|
|
TVMStreamHandle |
stream = nullptr |
|
) |
| |
|
static |
Function to copy data from one array to another.
- Parameters
-
from | The source array. |
to | The target array. |
stream | The stream used in copy. |
◆ CopyTo() [1/3]
Tensor tvm::runtime::Tensor::CopyTo |
( |
const Device & |
dev, |
|
|
ffi::Optional< ffi::String > |
mem_scope = std::nullopt |
|
) |
| const |
Copy the data to another device.
- Parameters
-
dev | The target device. |
mem_scope | The memory scope of the target array. |
- Returns
- The array under another device.
- Note
- The copy always triggers a TVMSynchronize.
◆ CopyTo() [2/3]
void tvm::runtime::Tensor::CopyTo |
( |
const Tensor & |
other | ) |
const |
|
inline |
◆ CopyTo() [3/3]
void tvm::runtime::Tensor::CopyTo |
( |
DLTensor * |
other | ) |
const |
|
inline |
Copy data content into another array.
- Parameters
-
other | The source array to be copied from. |
- Note
- The copy may happen asynchronously if it involves a GPU context. TVMSynchronize is necessary.
◆ CopyToBytes() [1/2]
static void tvm::runtime::Tensor::CopyToBytes |
( |
const DLTensor * |
from, |
|
|
void * |
to, |
|
|
size_t |
nbytes, |
|
|
TVMStreamHandle |
stream = nullptr |
|
) |
| |
|
static |
Function to copy data from one array to a byte buffer.
- Parameters
-
from | The source array. |
to | The target byte buffer. |
nbytes | The size of the data buffer. |
stream | The stream used in copy. |
◆ CopyToBytes() [2/2]
void tvm::runtime::Tensor::CopyToBytes |
( |
void * |
data, |
|
|
size_t |
nbytes |
|
) |
| const |
Copy data content into another array.
- Parameters
-
data | The source bytes to be copied from. |
nbytes | The size of the data buffer. Must be equal to the size of the Tensor. |
- Note
- The copy always triggers a TVMSynchronize.
◆ CreateView()
Tensor tvm::runtime::Tensor::CreateView |
( |
ffi::Shape |
shape, |
|
|
DLDataType |
dtype, |
|
|
uint64_t |
relative_byte_offset = 0 |
|
) |
| const |
Create a Tensor that shares the data memory with the current one.
- Parameters
-
shape | The shape of the new array. |
dtype | The data type of the new array. |
relative_byte_offset | The offset of the output Tensor, relative to the current byte offset. |
By default, the offset of the view is the same as the offset of the current array.
- Note
- The new array must not allow access of addresses which would be out of bounds in the current array. If the new array is larger than the current array, or if the
relative_byte_offset
would place the end of the new array outside the bounds of the current array, this function will raise an exception.
◆ DataType()
◆ Empty()
static Tensor tvm::runtime::Tensor::Empty |
( |
ffi::Shape |
shape, |
|
|
DLDataType |
dtype, |
|
|
Device |
dev, |
|
|
ffi::Optional< ffi::String > |
mem_scope = std::nullopt |
|
) |
| |
|
static |
Create an empty Tensor.
- Parameters
-
shape | The shape of the new array. |
dtype | The data type of the new array. |
dev | The device of the array. |
mem_scope | The memory scope of the array. |
- Returns
- The created Array
◆ FromDLPack()
static Tensor tvm::runtime::Tensor::FromDLPack |
( |
DLManagedTensor * |
tensor | ) |
|
|
inlinestatic |
◆ FromDLPackVersioned()
static Tensor tvm::runtime::Tensor::FromDLPackVersioned |
( |
DLManagedTensorVersioned * |
tensor | ) |
|
|
inlinestatic |
◆ Load()
bool tvm::runtime::Tensor::Load |
( |
dmlc::Stream * |
stream | ) |
|
|
inline |
Load Tensor from stream.
- Parameters
-
stream | The input data stream |
- Returns
- Whether load is successful
◆ Save()
void tvm::runtime::Tensor::Save |
( |
dmlc::Stream * |
stream | ) |
const |
|
inline |
Save Tensor to stream.
- Parameters
-
stream | The output data stream |
◆ Shape()
ffi::Shape tvm::runtime::Tensor::Shape |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: