@Properties(inherit=tvm_runtime.class) public class DLTensor extends Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter| Constructor and Description |
|---|
DLTensor()
Default native constructor.
|
DLTensor(long size)
Native array allocator.
|
DLTensor(Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
byte_offset()
\brief The offset in bytes to the beginning pointer to data
|
DLTensor |
byte_offset(long setter) |
Pointer |
data()
\brief The data pointer points to the allocated data.
|
DLTensor |
data(Pointer setter) |
DLDevice |
device()
\brief The device of the tensor
|
DLTensor |
device(DLDevice setter) |
DLDataType |
dtype()
\brief The data type of the pointer
|
DLTensor |
dtype(DLDataType setter) |
DLTensor |
getPointer(long i) |
int |
ndim()
\brief Number of dimensions
|
DLTensor |
ndim(int setter) |
DLTensor |
position(long position) |
LongPointer |
shape()
\brief The shape of the tensor
|
DLTensor |
shape(LongPointer setter) |
LongPointer |
strides()
\brief strides of the tensor (in number of elements, not bytes)
can be NULL, indicating tensor is compact and row-majored.
|
DLTensor |
strides(LongPointer setter) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zeropublic DLTensor()
public DLTensor(long size)
Pointer.position(long).public DLTensor(Pointer p)
Pointer(Pointer).public DLTensor getPointer(long i)
getPointer in class Pointerpublic Pointer data()
byte_offset field should be used to point to the beginning of the data.
Note that as of Nov 2021, multiply libraries (CuPy, PyTorch, TensorFlow,
TVM, perhaps others) do not adhere to this 256 byte aligment requirement
on CPU/CUDA/ROCm, and always use byte_offset=0. This must be fixed
(after which this note will be updated); at the moment it is recommended
to not rely on the data pointer being correctly aligned.
For given DLTensor, the size of memory required to store the contents of
data is calculated as follows:
{.c}
static inline size_t GetDataSize(const DLTensor* t) {
size_t size = 1;
for (tvm_index_t i = 0; i < t->ndim; ++i) {
size *= t->shape[i];
}
size *= (t->dtype.bits * t->dtype.lanes + 7) / 8;
return size;
}
public DLTensor ndim(int setter)
@ByRef public DLDataType dtype()
public DLTensor dtype(DLDataType setter)
@Cast(value="int64_t*") public LongPointer shape()
public DLTensor shape(LongPointer setter)
@Cast(value="int64_t*") public LongPointer strides()
public DLTensor strides(LongPointer setter)
@Cast(value="uint64_t") public long byte_offset()
public DLTensor byte_offset(long setter)
Copyright © 2024. All rights reserved.