Skip to main content

Python function

defaults

defaults()โ€‹

max.experimental.tensor.defaults(dtype=None, device=None)

source

Gets the default dtype and device for tensor creation.

Returns a tuple containing the dtype and device to use for tensor creation, applying defaults when values are not specified. If no dtype is provided, defaults to DType.float32 for CPU and DType.bfloat16 for accelerators. If no device is provided, defaults to an accelerator if available, otherwise CPU.

Parameters:

  • dtype (DType | None) โ€“ The data type to use. If not specified, a default dtype based on the device is returned.
  • device (Device | None) โ€“ The device to use. If not specified, defaults to an available accelerator or CPU.

Returns:

A tuple containing the resolved dtype and device.

Return type:

tuple[DType, Device]