Package org.apache.tvm
Class NDArray
java.lang.Object
org.apache.tvm.TVMValue
org.apache.tvm.NDArrayBase
org.apache.tvm.NDArray
Lightweight NDArray class of TVM runtime.
-
Field Summary
Fields inherited from class org.apache.tvm.NDArrayBase
handle, isView
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Return a copied flat java array of current array (row-major).char[]
Return a copied flat java array of current array (row-major).double[]
Return a copied flat java array of current array (row-major).float[]
Return a copied flat java array of current array (row-major).int[]
Return a copied flat java array of current array (row-major).long[]
Return a copied flat java array of current array (row-major).short[]
Return a copied flat java array of current array (row-major).void
copyFrom
(byte[] sourceArray) Copy from a native array.void
copyFrom
(char[] sourceArray) Copy from a native array.void
copyFrom
(double[] sourceArray) Copy from a native array.void
copyFrom
(float[] sourceArray) Copy from a native array.void
copyFrom
(int[] sourceArray) Copy from a native array.void
copyFrom
(long[] sourceArray) Copy from a native array.void
copyFrom
(short[] sourceArray) Copy from a native array.void
copyFromRaw
(byte[] sourceArray) Copy from a raw byte array.device()
Get the device of current array.static NDArray
empty
(long[] shape) Create an empty float32 array on cpu given shape.static NDArray
Create an empty float32 array given shape and device.static NDArray
Create an empty array on cpu given shape and type.static NDArray
Create an empty array given shape, type and device.protected void
finalize()
byte[]
internal()
Return a copied internal byte array of current array (row-major).long[]
shape()
Get shape of current NDArray.long
size()
Get total size of current NDArray.Methods inherited from class org.apache.tvm.NDArrayBase
asNDArray, copyTo, release
-
Method Details
-
finalize
- Overrides:
finalize
in classNDArrayBase
- Throws:
Throwable
-
copyFrom
public void copyFrom(double[] sourceArray) Copy from a native array. The NDArray type must by float64- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(float[] sourceArray) Copy from a native array. The NDArray type must by float32- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(long[] sourceArray) Copy from a native array. The NDArray type must by int64- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(int[] sourceArray) Copy from a native array. The NDArray type must by float32- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(short[] sourceArray) Copy from a native array. The NDArray type must by int16- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(byte[] sourceArray) Copy from a native array. The NDArray type must by int8- Parameters:
sourceArray
- the source data
-
copyFrom
public void copyFrom(char[] sourceArray) Copy from a native array. The NDArray type must by uint16- Parameters:
sourceArray
- the source data
-
copyFromRaw
public void copyFromRaw(byte[] sourceArray) Copy from a raw byte array.- Parameters:
sourceArray
- the source data
-
shape
public long[] shape()Get shape of current NDArray.- Returns:
- an array representing shape of current ndarray
-
size
public long size()Get total size of current NDArray.- Returns:
- size of current NDArray.
-
asDoubleArray
public double[] asDoubleArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be float64- Returns:
- A copy of array content.
-
asFloatArray
public float[] asFloatArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be float32- Returns:
- A copy of array content.
-
asLongArray
public long[] asLongArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be int64- Returns:
- A copy of array content.
-
asIntArray
public int[] asIntArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be int32- Returns:
- A copy of array content.
-
asShortArray
public short[] asShortArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be int16- Returns:
- A copy of array content.
-
asCharArray
public char[] asCharArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be uint16- Returns:
- A copy of array content.
-
asByteArray
public byte[] asByteArray()Return a copied flat java array of current array (row-major). The NDArray dtype must be int8- Returns:
- A copy of array content.
-
internal
public byte[] internal()Return a copied internal byte array of current array (row-major).- Returns:
- A copy of array content.
-
device
Get the device of current array.- Returns:
- the device.
-
empty
Create an empty array given shape, type and device.- Parameters:
shape
- The shape of the array.dtype
- The data type of the array.dev
- The device of the array.- Returns:
- The array tvm supported.
-
empty
Create an empty array on cpu given shape and type.- Parameters:
shape
- The shape of the array.dtype
- The data type of the array.- Returns:
- The array tvm supported.
-
empty
Create an empty float32 array on cpu given shape.- Parameters:
shape
- The shape of the array.- Returns:
- The array tvm supported.
-
empty
Create an empty float32 array given shape and device.- Parameters:
shape
- The shape of the array.dev
- The device of the array.- Returns:
- The array tvm supported.
-