Skip to content

Commit

Permalink
Update dtype.py
Browse files Browse the repository at this point in the history
  • Loading branch information
OccupyMars2025 committed Sep 6, 2022
1 parent cf221c9 commit 05dd1a7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/paddle/framework/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def iinfo(dtype):
"""
paddle.iinfo is a function that returns an object that represents the numerical properties of
an integer paddle.dtype
(i.e. paddle.uint8, paddle.int8, paddle.int16, paddle.int32, and paddle.int64).
This is similar to numpy.iinfo.
an integer paddle.dtype.
This is similar to numpy.iinfo, see here:
https://numpy.org/doc/stable/reference/generated/numpy.iinfo.html#numpy-iinfo
Args:
dtype(paddle.dtype): One of paddle.uint8, paddle.int8, paddle.int16, paddle.int32, and paddle.int64
Expand All @@ -54,21 +54,18 @@ def iinfo(dtype):
bits: int, The number of bits occupied by the type.
dtype: str, The string name of the argument dtype.
Raises:
ValueError: If the input "dtype" is not an integer paddle.dtype, it will raise an ValueError
Examples:
.. code-block:: python
import paddle
iinfo_uint8 = paddle.iinfo(paddle.uint8)
# output: paddle.iinfo(min=0, max=255, bits=8, dtype=uint8)
print(iinfo_uint8)
print(iinfo_uint8.min)
print(iinfo_uint8.max)
print(iinfo_uint8.bits)
print(iinfo_uint8.dtype)
# paddle.iinfo(min=0, max=255, bits=8, dtype=uint8)
print(iinfo_uint8.min) # 0
print(iinfo_uint8.max) # 255
print(iinfo_uint8.bits) # 8
print(iinfo_uint8.dtype) # uint8
"""
return core_iinfo(dtype)

0 comments on commit 05dd1a7

Please sign in to comment.