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)¶
Perform a synchronous 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
numpy.ndarray
- copyto(target, mem_scope=None)¶
Copy array to target
- 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), mem_scope=None)¶
Create an array from source arr.
- tvm.nd.empty(shape, dtype='float32', device=cpu(0), mem_scope=None)¶
Create an empty array given shape and device
- Parameters
shape (Union[tvm.runtime.ShapeTuple, Sequence[typing.SupportsInt]]) – The shape of the array.
device (Device) – The device of the array.
mem_scope (Optional[str]) – The memory scope of the array.
- Returns
arr – The array tvm supported.
- Return type