Rate this Page

Type Info#

Created On: Jun 06, 2025 | Last Updated On: Aug 14, 2025

The numerical properties of atorch.dtype can be accessed through either thetorch.finfo or thetorch.iinfo.

torch.finfo#

classtorch.finfo#

Atorch.finfo is an object that represents the numerical properties of a floating pointtorch.dtype, (i.e.torch.float32,torch.float64,torch.float16, andtorch.bfloat16).This is similar tonumpy.finfo.

Atorch.finfo provides the following attributes:

Name

Type

Description

bits

int

The number of bits occupied by the type.

eps

float

The difference between 1.0 and the next smallest representable float larger than 1.0.

max

float

The largest representable number.

min

float

The smallest representable number (typically-max).

tiny

float

The smallest positive normal number. Equivalent tosmallest_normal.

smallest_normal

float

The smallest positive normal number. See notes.

resolution

float

The approximate decimal resolution of this type, i.e.,10**-precision.

Note

The constructor oftorch.finfo can be called without argument,in which case the class is created for the pytorch default dtype (as returned bytorch.get_default_dtype()).

Note

smallest_normal returns the smallestnormal number, but there are smallersubnormal numbers. See https://en.wikipedia.org/wiki/Denormal_numberfor more information.

torch.iinfo#

classtorch.iinfo#

Atorch.iinfo is an object that represents the numerical properties of a integertorch.dtype (i.e.torch.uint8,torch.int8,torch.int16,torch.int32, andtorch.int64).This is similar tonumpy.iinfo.

Atorch.iinfo provides the following attributes:

Name

Type

Description

bits

int

The number of bits occupied by the type.

max

int

The largest representable number.

min

int

The smallest representable number.