Skip to content

Commit

Permalink
Merge pull request #31 from auphelia/fix/documentation
Browse files Browse the repository at this point in the history
[Docs] Fix docstring in quant node
  • Loading branch information
maltanar committed Jan 6, 2023
2 parents 2bf2502 + da08e6e commit b9d231a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/qonnx/custom_op/general/quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@
def min_int(signed: bool, narrow_range: bool, bit_width: int) -> int:
"""Compute the minimum integer representable by a given number of bits.
Args:
signed (bool): Indicates whether the represented integer is signed or not.
narrow_range (bool): Indicates whether to narrow the minimum value
represented by 1.
bit_width (int): Number of bits available for the representation.
Returns:
int: Maximum unsigned integer that can be represented according to
the input arguments.
Examples:
>>> min_int(signed=True, narrow_range=True, bit_width=8)
int(-127)
>>> min_int(signed=False, narrow_range=True, bit_width=8)
Expand All @@ -52,6 +57,7 @@ def min_int(signed: bool, narrow_range: bool, bit_width: int) -> int:
int(-128)
>>> min_int(signed=False, narrow_range=False, bit_width=8)
int(0)
"""
if signed and narrow_range:
value = -(2 ** (bit_width - 1)) + 1
Expand All @@ -65,14 +71,19 @@ def min_int(signed: bool, narrow_range: bool, bit_width: int) -> int:
def max_int(signed: bool, narrow_range: bool, bit_width: int) -> int:
"""Compute the maximum integer representable by a given number of bits.
Args:
signed (bool): Indicates whether the represented integer is signed or not.
narrow_range (bool): Indicates whether to narrow the maximum unsigned value
represented by 1.
bit_width (int): Number of bits available for the representation.
Returns:
Tensor: Maximum integer that can be represented according to
the input arguments.
Examples:
>>> max_int(signed=True, narrow_range=True, bit_width=8)
int(127)
>>> max_int(signed=False, narrow_range=True, bit_width=8)
Expand All @@ -81,6 +92,7 @@ def max_int(signed: bool, narrow_range: bool, bit_width: int) -> int:
int(127)
>>> max_int(signed=False, narrow_range=False, bit_width=8)
int(255)
"""
if not signed and not narrow_range:
value = (2**bit_width) - 1
Expand Down
2 changes: 2 additions & 0 deletions src/qonnx/transformation/channels_last.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class ConvertToChannelsLastAndClean(Transformation):
Converts data layout dependent nodes to ChannelsLast nodes and inserts transformations.
Then it tries to eliminate as many transformations as possible and moves the
still existing ones as far upstream as possible.
:param make_input_channels_last: Also makes the input of the network channels last,
otherwise a transpose node will be left at the beginning of the network. Defaults to False
:type make_input_channels_last: bool
"""

def __init__(self, make_input_channels_last=False):
Expand Down

0 comments on commit b9d231a

Please sign in to comment.