For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python function
defaults
defaults()โ
max.experimental.tensor.defaults(dtype=None, device=None)
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 the one set by
default_device(), or else 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 | DeviceMesh | None) โ The device or mesh to use. If not specified, defaults to the
one set by
default_device(), or else an available accelerator or CPU.
-
Returns:
-
A tuple containing the resolved dtype and device mesh. A single device is returned as a one-device mesh; use
mesh.devices[0]where aDeviceis needed. -
Return type: