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

Add layer conv1d_transpose for paddle backend #20899

Merged
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
28 changes: 26 additions & 2 deletions ivy/functional/backends/paddle/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ def conv1d(
raise IvyNotImplementedException()


# noinspection PyUnresolvedReferences
@with_unsupported_device_and_dtypes(
{"2.5.0 and below": {"cpu": ("float16", "bfloat16")}},
backend_version,
)
def conv1d_transpose(
x: paddle.Tensor,
filters: paddle.Tensor,
Expand All @@ -149,7 +152,28 @@ def conv1d_transpose(
dilations: Union[int, Tuple[int]] = 1,
out: Optional[paddle.Tensor] = None,
):
raise IvyNotImplementedException()
if data_format == "NWC":
x = x.transpose([0, 2, 1])
strides = [strides] if isinstance(strides, int) else strides
dilations = [dilations] if isinstance(dilations, int) else dilations
filters = filters.transpose([1, 2, 0])
not_valid_pad, padding_list, output_padding = _pad_before_conv_tranpose(
x, filters, strides, padding, 1, dilations, output_shape, filters.shape[2:]
)
res = paddle.nn.functional.conv1d_transpose(
x,
filters,
stride=strides,
padding=padding_list,
output_padding=output_padding,
dilation=dilations,
data_format="NCL",
)
if not_valid_pad[0]:
res = res[:, :, 0:-1]
if data_format == "NWC":
res = res.transpose([0, 2, 1])
return res


# noinspection PyUnresolvedReferences
Expand Down
Loading