|
tvm
|
Managed Tensor. The array is backed by reference counted blocks. More...
#include <tensor.h>
Public Member Functions | |
| Tensor ()=default | |
| Tensor (ffi::ObjectPtr< ffi::TensorObj > data) | |
| constructor. | |
| Tensor (ffi::UnsafeInit tag) | |
| Tensor (ffi::Tensor &&other) | |
| Tensor (const ffi::Tensor &other) | |
| ffi::ShapeView | Shape () const |
| DLDataType | DataType () const |
| const DLTensor * | operator-> () const |
| void | CopyFrom (const DLTensor *other) |
| Copy data content from another array. | |
| void | CopyFrom (const Tensor &other) |
| TVM_RUNTIME_DLL void | CopyFromBytes (const void *data, size_t nbytes) |
| Copy data content from a byte buffer. | |
| void | CopyTo (DLTensor *other) const |
| Copy data content into another array. | |
| void | CopyTo (const Tensor &other) const |
| TVM_RUNTIME_DLL void | CopyToBytes (void *data, size_t nbytes) const |
| Copy data content into another array. | |
| TVM_RUNTIME_DLL Tensor | CopyTo (const Device &dev, ffi::Optional< ffi::String > mem_scope=std::nullopt) const |
| Copy the data to another device. | |
| bool | Load (support::Stream *stream) |
| Load Tensor from stream. | |
| void | Save (support::Stream *stream) const |
| Save Tensor to stream. | |
| TVM_RUNTIME_DLL 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. | |
Managed Tensor. The array is backed by reference counted blocks.
|
default |
|
inlineexplicit |
constructor.
| data | ffi::ObjectPtr to the data container. |
|
inlineexplicit |
|
inline |
|
inline |
Copy data content from another array.
| other | The source array to be copied from. |
|
static |
Function to copy data from one array to a byte buffer.
| from | The source array. |
| to | The target byte buffer. |
| nbytes | The size of the data buffer. |
| stream | The stream used in copy. |
| TVM_RUNTIME_DLL void tvm::runtime::Tensor::CopyFromBytes | ( | const void * | data, |
| size_t | nbytes | ||
| ) |
Copy data content from a byte buffer.
| 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. |
|
static |
Function to copy data from one array to another.
| from | The source array. |
| to | The target array. |
| stream | The stream used in copy. |
| TVM_RUNTIME_DLL Tensor tvm::runtime::Tensor::CopyTo | ( | const Device & | dev, |
| ffi::Optional< ffi::String > | mem_scope = std::nullopt |
||
| ) | const |
Copy the data to another device.
| dev | The target device. |
| mem_scope | The memory scope of the target array. |
Copy data content into another array.
| other | The source array to be copied from. |
|
static |
Function to copy data from one array to a byte buffer.
| from | The source array. |
| to | The target byte buffer. |
| nbytes | The size of the data buffer. |
| stream | The stream used in copy. |
| TVM_RUNTIME_DLL void tvm::runtime::Tensor::CopyToBytes | ( | void * | data, |
| size_t | nbytes | ||
| ) | const |
Copy data content into another array.
| data | The source bytes to be copied from. |
| nbytes | The size of the data buffer. Must be equal to the size of the Tensor. |
| TVM_RUNTIME_DLL 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.
| 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.
relative_byte_offset would place the end of the new array outside the bounds of the current array, this function will raise an exception.
|
inline |
|
static |
Create an empty Tensor.
| 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. |
|
inlinestatic |
|
inlinestatic |
|
static |
Check if two tensors share the same underlying storage.
This detects runtime storage aliasing (e.g. views from CreateView, etc.) but does not imply either tensor was created by CreateView.
| a | The first tensor. |
| b | The second tensor. |
Tensor overload of IsStorageShared.
| a | The first tensor. |
| b | The second tensor. |
|
inline |
|
inline |
Save Tensor to stream.
| stream | The output data stream |
|
inline |