Type Info¶
The numerical properties of a oneflow.dtype
can be accessed through either the oneflow.finfo
or the oneflow.iinfo
.
oneflow
oneflow.finfo¶
-
class
oneflow.
finfo
¶
A oneflow.finfo
is an object that represents the numerical properties of a floating point oneflow.dtype
, (i.e. oneflow.float32
, oneflow.float64
and oneflow.float16
). This is similar to numpy.finfo.
A oneflow.finfo
provides the following attributes:
Name |
Type |
Description |
---|---|---|
bits |
int |
The number of bits occupied by the type. |
eps |
float |
The smallest representable number such that |
min |
float |
The largest representable number. |
max |
float |
The smallest representable number (typically |
tiny |
float |
The smallest positive normal number. See notes. |
resolution |
float |
The approximate decimal resolution of this type, i.e., |
For example:
>>> import oneflow as flow
>>> flow.finfo()
finfo(resolution=1e-06, min=-3.40282e+38, max=3.40282e+38, eps=1.19209e-07, tiny=1.17549e-38, dtype=oneflow.float32, bits=32)
>>> flow.finfo(flow.float)
finfo(resolution=1e-06, min=-3.40282e+38, max=3.40282e+38, eps=1.19209e-07, tiny=1.17549e-38, dtype=oneflow.float32, bits=32)
>>> flow.finfo(flow.float16).bits
16
>>> flow.finfo(flow.float16).max
65504.0
oneflow.iinfo¶
-
class
oneflow.
iinfo
¶
A oneflow.iinfo
is an object that represents the numerical properties of a integer oneflow.dtype
(i.e. oneflow.uint8
, oneflow.int8
, oneflow.int16
, oneflow.int32
, and oneflow.int64
). This is similar to numpy.iinfo.
A oneflow.iinfo
provides the following attributes:
Name |
Type |
Description |
---|---|---|
bits |
int |
The number of bits occupied by the type. |
min |
float |
The largest representable number. |
max |
float |
The smallest representable number. |
For example:
>>> import oneflow as flow
>>> flow.iinfo(flow.int8)
iinfo(min=-128, max=127, dtype=oneflow.int8, bits=8)
>>> flow.iinfo(flow.int).max
2147483647
>>> flow.iinfo(flow.int).bits
32