Skip to content

Commit

Permalink
doc: add docstring and type hints to _padding_ceil_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam-Armstrong committed Jul 15, 2024
1 parent adfd2fc commit bb9a052
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion ivy/functional/ivy/experimental/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,36 @@ def _output_ceil_shape(w, f, p, s):
return math.ceil((w - f + p) / s) + 1


def _padding_ceil_mode(w, f, p, s, return_added_padding=False):
def _padding_ceil_mode(
w: int,
f: int,
p: Tuple[int],
s: int,
return_added_padding: Optional[bool] = False,
) -> Union[Tuple[int], Tuple[Tuple[int], int]]:
"""Adjust padding to ensure the output size is computed using ceiling mode.
Parameters
----------
w
The width or height (i.e., spatial dimension) of the array
f
The size of the kernel/filter
p
A tuple of two integers representing the padding before (left or top) and after (right or bottom) the input array
s
The stride
return_added_padding
If True, the function also returns the amount of padding added to the original padding
Returns
-------
p
The adjusted padding values as a tuple (left/top padding, right/bottom padding)
added_padding (optional)
The amount of padding added to the original right/bottom padding to ensure correct output size when `return_added_padding` is True
"""

remaining_pixels = (w - f + sum(p)) % s
added_padding = 0
# if the additional pixels potentially captured thanks to ceil mode
Expand Down

0 comments on commit bb9a052

Please sign in to comment.