@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 |
|---|---|
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(DLContext ctx)
\brief Copy the data to another context.
|
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(long[] shape,
DLDataType dtype) |
NDArray |
CreateView(LongBuffer shape,
DLDataType dtype) |
NDArray |
CreateView(LongPointer shape,
DLDataType dtype)
\brief Create a NDArray that shares the data memory with the current one.
|
DataType |
DataType() |
static NDArray |
Empty(long[] shape,
DLDataType dtype,
DLContext ctx) |
static NDArray |
Empty(LongBuffer shape,
DLDataType dtype,
DLContext ctx) |
static NDArray |
Empty(LongPointer shape,
DLDataType dtype,
DLContext ctx)
\brief Create an empty NDArray.
|
static NDArray |
FromDLPack(DLManagedTensor tensor)
\brief Create a NDArray backed by a dlpack tensor.
|
NDArray |
getPointer(long i) |
boolean |
IsContiguous() |
boolean |
Load(Stream stream)
\brief Load NDArray from stream
|
NDArray |
position(long position) |
void |
Save(Stream stream)
\brief Save NDArray to stream
|
LongPointer |
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, getPointer, getPointer, getPointer, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, 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(@Const @ByRef DLContext ctx)
ctx - The target context.@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(@Cast(value="int64_t*") @StdVector LongPointer 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.@ByVal public NDArray CreateView(@Cast(value="int64_t*") @StdVector LongBuffer shape, @ByVal DLDataType dtype)
@ByVal public NDArray CreateView(@Cast(value="int64_t*") @StdVector long[] shape, @ByVal DLDataType dtype)
public DLManagedTensor ToDLPack()
@ByVal public static NDArray Empty(@Cast(value="int64_t*") @StdVector LongPointer shape, @ByVal DLDataType dtype, @ByVal DLContext ctx)
shape - The shape of the new array.dtype - The data type of the new array.ctx - The context of the Array.@ByVal public static NDArray Empty(@Cast(value="int64_t*") @StdVector LongBuffer shape, @ByVal DLDataType dtype, @ByVal DLContext ctx)
@ByVal public static NDArray Empty(@Cast(value="int64_t*") @StdVector long[] shape, @ByVal DLDataType dtype, @ByVal DLContext ctx)
@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.@Cast(value="int64_t*") @StdVector public LongPointer Shape()
Copyright © 2021. All rights reserved.