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

fix: Fix ivy.permute_dims for all backends #28009

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions ivy/functional/backends/jax/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def permute_dims(
copy: Optional[bool] = None,
out: Optional[JaxArray] = None,
) -> JaxArray:
if copy:
newarr = jnp.copy(x)
return jnp.transpose(newarr, axes)
return jnp.transpose(x, axes)


Expand Down
3 changes: 3 additions & 0 deletions ivy/functional/backends/numpy/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def permute_dims(
copy: Optional[bool] = None,
out: Optional[np.ndarray] = None,
) -> np.ndarray:
if copy:
newarr = np.copy(x)
return np.transpose(newarr, axes)
return np.transpose(x, axes)


Expand Down
6 changes: 5 additions & 1 deletion ivy/functional/backends/paddle/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def flip(


@with_unsupported_dtypes(
{"2.6.0 and below": ("uint8", "int8", "int16", "bfloat16")}, backend_version
{"2.6.0 and below": ("uint8", "int8", "int16", "bfloat16", "float16")},
backend_version,
)
def permute_dims(
x: paddle.Tensor,
Expand All @@ -101,6 +102,9 @@ def permute_dims(
copy: Optional[bool] = None,
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
if copy:
newarr = paddle.clone(x)
return paddle.transpose(newarr, axes)
return paddle.transpose(x, axes)


Expand Down
4 changes: 4 additions & 0 deletions ivy/functional/backends/torch/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def flip(
return torch.flip(x, new_axis)


@with_unsupported_dtypes({"2.1.2 and below": ("bfloat16", "float16")}, backend_version)
def permute_dims(
x: torch.Tensor,
/,
Expand All @@ -85,6 +86,9 @@ def permute_dims(
copy: Optional[bool] = None,
out: Optional[torch.Tensor] = None,
) -> torch.Tensor:
if copy:
newarr = torch.clone(x).detach()
return torch.permute(newarr, axes)
return torch.permute(x, axes)


Expand Down
Loading