tvm.runtime.ndarray¶
Runtime NDArray API
- class tvm.nd.NDArray¶
Lightweight NDArray class of TVM runtime.
Strictly this is only an Array Container (a buffer object) No arthimetic operations are defined. All operations are performed by TVM functions.
The goal is not to re-build yet another array library. Instead, this is a minimal data structure to demonstrate how can we use TVM in existing project which might have their own array containers.
- property dtype¶
Type of this array
- property device¶
Device of this array
- same_as(other)¶
Check object identity equality
- copyfrom(source_array)¶
Peform an synchronize copy from the array.
- Parameters
source_array (array_like) – The data source we should like to copy from.
- Returns
arr – Reference to self.
- Return type
- asnumpy()¶
Convert this array to numpy array. This API will be deprecated in TVM v0.8 release. Please use numpy instead.
- numpy()¶
Convert this array to numpy array
- Returns
np_arr – The corresponding numpy array.
- Return type
- copyto(target)¶
Copy array to target
- Parameters
target (NDArray) – The target array to be copied, must have same shape as this array.
- shape¶
Shape of this array
- to_dlpack()¶
Produce an array from a DLPack Tensor without copying memory
- Returns
dlpack
- Return type
DLPack tensor view of the array data
- tvm.nd.array(arr, device=cpu(0))¶
Create an array from source arr.
- Parameters
arr (numpy.ndarray) – The array to be copied from
device (Device, optional) – The device device to create the array
- Returns
ret – The created array
- Return type
- tvm.nd.empty(shape, dtype='float32', device=cpu(0), mem_scope=None)¶
Create an empty array given shape and device
- Parameters
- Returns
arr – The array tvm supported.
- Return type