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

feat: add interpolate function and test #26226

Closed
wants to merge 11 commits into from
13 changes: 11 additions & 2 deletions ivy/functional/backends/paddle/experimental/layers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# global
from typing import Optional, Union, Tuple, List, Literal, Sequence, Callable
import paddle

from ivy.functional.ivy.layers import (
_handle_padding,
_depth_max_pooling_helper,
Expand Down Expand Up @@ -436,10 +437,18 @@ def interpolate(
scale_factor: Optional[Union[Sequence[int], int]] = None,
recompute_scale_factor: Optional[bool] = None,
align_corners: Optional[bool] = None,
antialias: Optional[bool] = False,
data_format: str = "NCHW",
out: Optional[paddle.Tensor] = None,
):
raise IvyNotImplementedException()
if recompute_scale_factor is True:
align_mode = 1
elif recompute_scale_factor is False:
align_mode = 0
else:
align_mode = None
return paddle.nn.functional.interpolate(
x, size, scale_factor, mode, align_corners, align_mode, data_format
)


def adaptive_max_pool2d(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# global

import numpy as np
import torch
from hypothesis import strategies as st, assume
Expand Down Expand Up @@ -1085,6 +1086,39 @@ def test_interpolate(
)


@handle_test(
fn_tree="functional.ivy.backends.experimental.paddle.interpolate",
dtype_x_mode=_interp_args(),
test_gradients=st.just(False),
number_positional_args=st.just(2),
)
def test_interpolate_paddle(dtype_x_mode, test_flags, backend_fw, fn_name, on_device):
(
input_dtype,
x,
mode,
size,
align_corners,
scale_factor,
recompute_scale_factor,
) = dtype_x_mode
helpers.test_function(
input_dtypes=input_dtype,
test_flags=test_flags,
backend_to_test=backend_fw,
fn_name=fn_name,
on_device=on_device,
rtol_=1e-01,
atol_=1e-01,
x=x[0],
size=size,
mode=mode,
align_corners=align_corners,
scale_factor=scale_factor,
recompute_scale_factor=recompute_scale_factor,
)


@handle_test(
fn_tree="functional.ivy.experimental.max_pool1d",
x_k_s_p=helpers.arrays_for_pooling(
Expand Down
Loading