Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Max Pool 3D to Paddle pooling.py #26587

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ivy/functional/frontends/paddle/nn/functional/pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,39 @@ def max_unpool1d(
name=None,
):
return ivy.max_unpool1d(x, indices, kernel_size, stride, padding, data_format)


@to_ivy_arrays_and_back
@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
def max_pool3d(
x,
kernel_size,
stride=None,
padding=0,
return_mask=False,
ceil_mode=False,
data_format='NCDHW',
name=None
):
if stride is None:
stride = kernel_size
kernel_size = _broadcast_pooling_helper(kernel_size, "3d", name="kernel_size")
padding = _broadcast_pooling_helper(padding, "3d", name="padding")
# Figure out padding string
if all(
[pad == ivy.ceil((kernel - 1) / 2) for kernel, pad in zip(kernel_size, padding)]
):
padding = "SAME"
else:
padding = "VALID"


return ivy.max_pool3d(
x,
kernel_size,
stride,
padding,
return_mask=return_mask,
ceil_mode=ceil_mode,
data_format=data_format
)
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,41 @@ def test_paddle_avg_pool2d(
)


# max_pool3d
@handle_frontend_test(
fn_tree="paddle.nn.functional.max_pool3d",
x_k_s_p=helpers.arrays_for_pooling(min_dims=5, max_dims=5, min_side=1, max_side=5),
stride=st.tuples(st.integers(1, 2), st.integers(1, 2)),
test_with_out=st.just(False),
)
def test_paddle_max_pool3d(
*,
x_k_s_p,
stride,
data_format,
frontend,
test_flags,
fn_tree,
backend_fw,
on_device,
):
input_dtype, x, kernel_size, _, padding = x_k_s_p
data_format = data_format
helpers.test_frontend_function(
input_dtypes=input_dtype,
backend_to_test=backend_fw,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
x=x[0],
kernel_size=kernel_size,
stride=stride,
padding=padding,
data_format=data_format,
)


# max_unpool1d
@handle_frontend_test(
fn_tree="paddle.nn.functional.max_unpool1d",
Expand Down
Loading