heterocl.tvm.ndarray module¶
TVM Runtime NDArray API.
tvm.ndarray provides a minimum runtime array API to test the correctness of the program.
-
class
NDArray
(handle, is_view=False)[source]¶ Bases:
heterocl.tvm._ffi.ndarray.NDArrayBase
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.
-
array
(arr, dtype=None, ctx=cpu(0))[source]¶ Create an array from source arr.
- Parameters
arr (numpy.ndarray) – The array to be copied from
ctx (TVMContext, optional) – The device context to create the array
- Returns
ret – The created array
- Return type
-
cl
(dev_id=0)¶ Construct a OpenCL device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
cpu
(dev_id=0)[source]¶ Construct a CPU device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
ext_dev
(dev_id=0)[source]¶ Construct a extension device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
Note
This API is reserved for quick testing of new device by plugin device API as ext_dev.
-
gpu
(dev_id=0)[source]¶ Construct a CPU device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
metal
(dev_id=0)[source]¶ Construct a metal device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
mtl
(dev_id=0)¶ Construct a metal device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
opencl
(dev_id=0)[source]¶ Construct a OpenCL device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
opengl
(dev_id=0)[source]¶ Construct a OpenGL device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext
-
rocm
(dev_id=0)[source]¶ Construct a ROCM device
- Parameters
dev_id (int, optional) – The integer device id
- Returns
ctx – The created context
- Return type
TVMContext