Python module
driver
CPU
β
class max.driver.CPU(id: int = -1)
This represents an instance of a logical cpu device.
CUDA
β
class max.driver.CUDA(id: int = -1)
This represents a CUDA GPU device.
Device
β
class max.driver.Device(id: int = -1)
Abstract device class. Base class for all device objects.
Tensor
β
class max.driver.Tensor(shape: ~typing.Tuple[int, ...], dt: ~max.dtype.dtype.DType, device: ~max.driver.driver.Device = <max.driver.driver.CPU object>, **kwargs)
Device-resident tensor representation. Allocates memory onto a given device with the provided shape and dtype. Tensors can be sliced to provide strided views of the underlying memory, but any tensors input into model execution must be contiguous. Does not currently support setting items across multiple indices, but does support numpy-style slicing.
-
Parameters:
- dt β DType of tensor
- shape β Tuple of positive, non-zero integers denoting the tensor shape.
- device β Device to allocate tensor onto.
contiguous()
β
contiguous() β Tensor
Creates a contiguous copy of the parent tensor.
copy_to()
β
Copies a tensor to the provided device.
dtype
β
property dtype*: DType*
DType of constituent elements in tensor.
from_numpy()
β
classmethod from_numpy(arr: ~numpy.ndarray, device: ~max.driver.driver.Device = <max.driver.driver.CPU object>) β Tensor
Creates a tensor from a provided numpy array, allocated on the provided device. If the target device is a CPU, the underlying data will not be copied. If the target device is a GPU, the device will be copied to the target.
is_contiguous
β
property is_contiguous*: bool*
Whether or not tensor is contiguously allocated in memory. Returns false if the tensor is a non-contiguous slice.
Currently, we consider certain situations that are contiguous as non-contiguous for the purposes of our engine. These situations include: * A tensor with negative steps. * A 1-dimensional tensor slice that is derived from a larger tensor.
is_host
β
property is_host*: bool*
Whether or not tensor is host-resident. Returns false for GPU tensors, true for CPU tensors.
item()
β
item() β Any
Returns the scalar value at a given location. Currently implemented only for zero-rank tensors. The return type is converted to a Python built-in type.
rank
β
property rank*: int*
Tensor rank.
shape
β
Shape of tensor.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
π What went wrong?