Skip to content

Commit

Permalink
Fix Frontend Failing Test: torch - linalg.torch.linalg.norm (#28106)
Browse files Browse the repository at this point in the history
Co-authored-by: NripeshN <86844847+NripeshN@users.noreply.github.com>
  • Loading branch information
shruzki and NripeshN authored Feb 25, 2024
1 parent ae4dddc commit 1157ec1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ivy/functional/frontends/torch/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ def norm(input, ord=None, dim=None, keepdim=False, *, dtype=None, out=None):
elif dim is None and ord is None:
input = ivy.flatten(input)
ret = ivy.vector_norm(input, axis=0, keepdims=keepdim, ord=2)
if isinstance(dim, int):
elif isinstance(dim, int):
ret = ivy.vector_norm(input, axis=dim, keepdims=keepdim, ord=ord)
elif isinstance(dim, tuple):
elif isinstance(dim, tuple) and len(dim) <= 2:
ret = ivy.matrix_norm(input, axis=dim, keepdims=keepdim, ord=ord)
elif isinstance(dim, tuple) and len(dim) > 2:
raise RuntimeError(
f"linalg.norm: If dim is specified, it must be of length 1 or 2. Got {dim}"
)
return ret


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _get_axis_and_p(draw):
min_axes_size = 2
else:
min_axes_size = 1
max_axes_size = 5
max_axes_size = 2
x_dtype, values, axis = draw(
helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("valid"),
Expand Down

0 comments on commit 1157ec1

Please sign in to comment.