@Namespace(value="tvm::runtime") @Properties(inherit=tvm_runtime.class) public class NDArray extends ObjectRef
| Modifier and Type | Class and Description |
|---|---|
static class |
NDArray.Container
\brief NDArray internal container type
|
static class |
NDArray.ContainerBase
\brief ContainerBase used to back the TVMArrayHandle
|
static class |
NDArray.Internal |
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter_type_is_nullable| Constructor and Description |
|---|
NDArray()
\brief default constructor
|
NDArray(long size)
Native array allocator.
|
NDArray(ObjectPtr data)
\brief constructor.
|
NDArray(Pointer p)
Pointer cast constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
AbilityOfZeroCopyForDLTensor(DLTensor tensor,
DLDevice dev)
\brief Check conditions for construction NDArray over DLTensor without copying.
|
DLTensor |
accessDLTensor() |
void |
CopyFrom(DLTensor other)
\brief Copy data content from another array.
|
void |
CopyFrom(NDArray other) |
void |
CopyFromBytes(Pointer data,
long nbytes)
\brief Copy data content from a byte buffer.
|
static void |
CopyFromTo(DLTensor from,
DLTensor to) |
static void |
CopyFromTo(DLTensor from,
DLTensor to,
TVMStreamHandle stream)
\brief Function to copy data from one array to another.
|
NDArray |
CopyTo(DLDevice dev) |
NDArray |
CopyTo(DLDevice dev,
TVMStringOptional mem_scope)
\brief Copy the data to another device.
|
void |
CopyTo(DLTensor other)
\brief Copy data content into another array.
|
void |
CopyTo(NDArray other) |
void |
CopyToBytes(Pointer data,
long nbytes)
\brief Copy data content into another array.
|
NDArray |
CreateView(ShapeTuple shape,
DLDataType dtype) |
NDArray |
CreateView(ShapeTuple shape,
DLDataType dtype,
long relative_byte_offset)
\brief Create a NDArray that shares the data memory with the current one.
|
DataType |
DataType() |
static NDArray |
Empty(ShapeTuple shape,
DLDataType dtype,
DLDevice dev) |
static NDArray |
Empty(ShapeTuple shape,
DLDataType dtype,
DLDevice dev,
TVMStringOptional mem_scope)
\brief Create an empty NDArray.
|
static NDArray |
FromDLPack(DLManagedTensor tensor)
\brief Create a NDArray backed by a dlpack tensor.
|
static NDArray |
FromExternalDLTensor(DLTensor dl_tensor)
\brief Create a NDArray backed by an external DLTensor without memory copying.
|
NDArray |
getPointer(long i) |
boolean |
IsContiguous() |
boolean |
Load(Stream stream)
\brief Load NDArray from stream
|
static NDArray |
NewFromDLTensor(DLTensor dl_tensor,
DLDevice dev)
\brief Create new NDArray, data is copied from DLTensor.
|
NDArray |
position(long position) |
void |
Save(Stream stream)
\brief Save NDArray to stream
|
ShapeTuple |
Shape() |
DLManagedTensor |
ToDLPack()
\brief Create a reference view of NDArray that
represents as DLManagedTensor.
|
int |
use_count() |
_type_is_nullable, access, defined, equals, get, lessThan, notEquals, same_as, uniqueaddress, 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 NDArray(Pointer p)
Pointer(Pointer).public NDArray(long size)
Pointer.position(long).public NDArray()
public NDArray getPointer(long i)
getPointer in class ObjectRefpublic int use_count()
@Const @Name(value="operator ->") public DLTensor accessDLTensor()
@Cast(value="bool") public boolean IsContiguous()
public void CopyFrom(@Const DLTensor other)
other - The source array to be copied from.
\note The copy may happen asynchronously if it involves a GPU context.
TVMSynchronize is necessary.public void CopyFromBytes(@Const Pointer data, @Cast(value="size_t") long nbytes)
data - The source bytes to be copied from.nbytes - The size of the buffer in bytes
Must be equal to the size of the NDArray.
\note The copy always triggers a TVMSynchronize.public void CopyTo(DLTensor other)
other - The source array to be copied from.
\note The copy may happen asynchronously if it involves a GPU context.
TVMSynchronize is necessary.public void CopyToBytes(Pointer data, @Cast(value="size_t") long nbytes)
data - The source bytes to be copied from.nbytes - The size of the data buffer.
Must be equal to the size of the NDArray.
\note The copy always triggers a TVMSynchronize.@ByVal public NDArray CopyTo(@Cast(value="const tvm::Device*") @ByRef DLDevice dev, @ByVal(nullValue="tvm::runtime::Optional<tvm::runtime::String>(tvm::NullOpt)") TVMStringOptional mem_scope)
dev - The target device.mem_scope - The memory scope of the target array.@Cast(value="bool") public boolean Load(Stream stream)
stream - The input data streampublic void Save(Stream stream)
stream - The output data stream@ByVal public NDArray CreateView(@ByVal ShapeTuple shape, @ByVal DLDataType dtype, @Cast(value="uint64_t") long relative_byte_offset)
shape - The shape of the new array.dtype - The data type of the new array.relative_byte_offset - The offset of the output NDArray,
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.@ByVal public NDArray CreateView(@ByVal ShapeTuple shape, @ByVal DLDataType dtype)
public DLManagedTensor ToDLPack()
@ByVal public static NDArray Empty(@ByVal ShapeTuple shape, @ByVal DLDataType dtype, @ByVal @Cast(value="tvm::Device*") DLDevice dev, @ByVal(nullValue="tvm::runtime::Optional<tvm::runtime::String>(tvm::NullOpt)") TVMStringOptional mem_scope)
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.@ByVal public static NDArray Empty(@ByVal ShapeTuple shape, @ByVal DLDataType dtype, @ByVal @Cast(value="tvm::Device*") DLDevice dev)
@ByVal public static NDArray FromExternalDLTensor(@Const @ByRef DLTensor dl_tensor)
dl_tensor - The DLTensor for NDArray base.@ByVal public static NDArray NewFromDLTensor(DLTensor dl_tensor, @Cast(value="const tvm::Device*") @ByRef DLDevice dev)
dl_tensor - The DLTensor to copy from.dev - device location of the created NDArray.@ByVal public static NDArray FromDLPack(DLManagedTensor tensor)
tensor - The DLPack tensor to copy from.public static void CopyFromTo(@Const DLTensor from, DLTensor to, TVMStreamHandle stream)
from - The source array.to - The target array.stream - The stream used in copy.@ByVal public ShapeTuple Shape()
@Cast(value="bool") public static boolean AbilityOfZeroCopyForDLTensor(DLTensor tensor, @Cast(value="const tvm::Device*") @ByRef DLDevice dev)
tensor - the DLTensor.dev - destination device.Copyright © 2024. All rights reserved.