tvm.runtime.ndarray#
Runtime NDArray API
- class tvm.runtime.ndarray.NDArray(handle, is_view=False)[源代码]#
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.
- asnumpy()[源代码]#
Convert this array to numpy array. This API will be deprecated in TVM v0.8 release. Please use numpy instead.
- copyfrom(source_array)[源代码]#
Perform a synchronous copy from the array.
- 参数:
source_array (array_like) -- The data source we should like to copy from.
- 返回:
arr -- Reference to self.
- 返回类型:
- property device#
Device of this array
- property dtype#
Type of this array
- tvm.runtime.ndarray.array(arr, device=cpu(0), mem_scope=None)[源代码]#
Create an array from source arr.
- tvm.runtime.ndarray.cl(dev_id=0)#
Construct a OpenCL device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.cpu(dev_id=0)[源代码]#
Construct a CPU device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.cuda(dev_id=0)[源代码]#
Construct a CUDA GPU device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.device(dev_type, dev_id=0)[源代码]#
Construct a TVM device with given device type and id.
- 参数:
- 返回:
dev -- The corresponding device.
- 返回类型:
tvm.runtime.Device
示例
Device can be used to create reflection of device by string representation of the device type.
assert tvm.device("cpu", 1) == tvm.cpu(1) assert tvm.device("cuda", 0) == tvm.cuda(0)
- tvm.runtime.ndarray.empty(shape, dtype='float32', device=cpu(0), mem_scope=None)[源代码]#
Create an empty array given shape and device
- 参数:
shape (Union[tvm.runtime.ShapeTuple, Sequence[SupportsInt]]) -- The shape of the array.
device (Device) -- The device of the array.
mem_scope (Optional[str]) -- The memory scope of the array.
- 返回:
arr -- The array tvm supported.
- 返回类型:
tvm.nd.NDArray
- tvm.runtime.ndarray.ext_dev(dev_id=0)[源代码]#
Construct a extension device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
备注
This API is reserved for quick testing of new device by plugin device API as ext_dev.
- tvm.runtime.ndarray.from_dlpack(dltensor)[源代码]#
Produces an array from an object with __dlpack__ method or a DLPack tensor w/o memory copy. Retreives the underlying DLPack tensor's pointer to create an array from the data. Removes the original DLPack tensor's destructor as now the array is responsible for destruction.
- 参数:
dltensor (object with __dlpack__ attribute or a DLPack capsule)
- 返回:
arr -- The array view of the tensor data.
- 返回类型:
tvm.nd.NDArray
- tvm.runtime.ndarray.gpu(dev_id=0)[源代码]#
Construct a CUDA GPU device
deprecated:: 0.9.0 Use
tvm.cuda()
instead.- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.hexagon(dev_id=0)[源代码]#
Construct a Hexagon device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.metal(dev_id=0)[源代码]#
Construct a metal device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.mtl(dev_id=0)#
Construct a metal device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.opencl(dev_id=0)[源代码]#
Construct a OpenCL device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.rocm(dev_id=0)[源代码]#
Construct a ROCM device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device
- tvm.runtime.ndarray.vpi(dev_id=0)[源代码]#
Construct a VPI simulated device
- 参数:
dev_id (int, optional) -- The integer device id
- 返回:
dev -- The created device
- 返回类型:
Device