@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)
\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)
\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)
dev - The target device.@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)
shape - The shape of the new array.dtype - The data type of the new array.
\note The memory size of new array must be smaller than the current one.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 © 2022. All rights reserved.