internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ivy-llc/ivy

Issue:
lognormal



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/random/functions.py b/ivy/functional/frontends/numpy/random/functions.py
--- a/ivy/functional/frontends/numpy/random/functions.py
+++ b/ivy/functional/frontends/numpy/random/functions.py
@@ -110,3 +110,10 @@ def chisquare(df, size=None):
         df = df * ivy.ones(size)
 
     return ivy.gamma(df / 2, 2, dtype="float64")
+
+
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def lognormal(mean=0.0, sigma=1.0, size=None):
+    ret = ivy.exp(ivy.random_normal(mean=mean, std=sigma, shape=size, dtype="float64"))
+    return ret


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_random/test_functions.py
@@ -444,3 +444,37 @@ def test_numpy_chisquare(
         df=df,
         size=size,
     )
+
+
+# lognormal
+# min value is set 0
+@handle_frontend_test(
+    fn_tree="numpy.random.lognormal",
+    input_dtypes=helpers.get_dtypes("float", index=2),
+    mean=st.floats(allow_nan=False, allow_infinity=False, width=32, min_value=-5, max_value=5),
+    sigma=st.floats(allow_nan=False, allow_infinity=False, width=32, min_value=0, max_value=5),
+    size=st.tuples(
+        st.integers(min_value=2, max_value=5), st.integers(min_value=2, max_value=5)
+    ),
+)
+def test_numpy_lognormal(
+    input_dtypes,
+    size,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+    mean,
+    sigma,
+):
+    helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=False,
+        mean=mean,
+        sigma=sigma,
+        size=size,
+    )
Repository: ivy-llc/ivy

Issue:
sign



Discussion:
This issue has been labelled as stale. If you would like to continue working on this issue, then please add another comment or create a PR . If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. For more information please refer to this page in our documentation: https://lets-unify.ai/ivy/contributing/1_the_basics.html#todo-list-issues

Resolving patch:
diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py
--- a/ivy/functional/frontends/torch/tensor.py
+++ b/ivy/functional/frontends/torch/tensor.py
@@ -1061,3 +1061,9 @@ def normal_(self, mean=0, std=1, *, generator=None):
     @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
     def addcdiv(self, tensor1, tensor2, *, value=1):
         return torch_frontend.addcdiv(self, tensor1, tensor2, value=value)
+
+    sign_decorator_dtypes = ("float16", "complex", "bool")
+
+    @with_unsupported_dtypes({"1.11.0 and below": sign_decorator_dtypes}, "torch")
+    def sign(self):
+        return torch_frontend.sign(self._ivy_array)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
@@ -7605,3 +7605,34 @@ def test_torch_instance_addcdiv(
         on_device=on_device,
         atol_=1e-03,
     )
+
+
+# sign
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="sign",
+    dtype_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+    ),
+)
+def test_torch_instance_sign(
+    dtype_x,
+    frontend,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    on_device,
+):
+    input_dtype, x = dtype_x
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        init_all_as_kwargs_np={"data": x[0]},
+        method_input_dtypes=input_dtype,
+        method_all_as_kwargs_np={},
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
Repository: ivy-llc/ivy

Issue:
 fftshift



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
--- a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
+++ b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
@@ -35,3 +35,24 @@ def ifftshift(x, axes=None):
 @to_ivy_arrays_and_back
 def fft(a, n=None, axis=-1, norm=None):
     return ivy.fft(ivy.astype(a, ivy.complex128), axis, norm=norm, n=n)
+
+
+@to_ivy_arrays_and_back
+@with_unsupported_dtypes({"1.23.0 and below": ("float16",)}, "numpy")
+def fftshift(x, axes=None):
+    x = ivy.asarray(x)
+
+    if axes is None:
+        axes = tuple(range(x.ndim))
+        shift = [(dim // 2) for dim in x.shape]
+    elif isinstance(
+        axes,
+        (int, type(ivy.uint8), type(ivy.uint16), type(ivy.uint32), type(ivy.uint64)),
+    ):
+        shift = x.shape[axes] // 2
+    else:
+        shift = [(x.shape[ax] // 2) for ax in axes]
+
+    roll = ivy.roll(x, shift, axis=axes)
+
+    return roll


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
@@ -70,3 +70,23 @@ def test_numpy_fft(dtype_input_axis, norm, n, frontend, test_flags, fn_tree, on_
         axis=axis,
         norm=norm,
     )
+
+
+@handle_frontend_test(
+    fn_tree="numpy.fft.fftshift",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"), shape=(4,), array_api_dtypes=True
+    ),
+)
+def test_numpy_fttshift(dtype_and_x, frontend, test_flags, fn_tree, on_device):
+    input_dtype, arr = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=True,
+        x=arr[0],
+        axes=None,
+    )
Repository: ivy-llc/ivy

Issue:
fft



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
--- a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
+++ b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py
@@ -30,3 +30,8 @@ def ifftshift(x, axes=None):
     roll = ivy.roll(x, shift, axis=axes)
 
     return roll
+
+
+@to_ivy_arrays_and_back
+def fft(a, n=None, axis=-1, norm=None):
+    return ivy.fft(ivy.astype(a, ivy.complex128), axis, norm=norm, n=n)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_fft/test_discrete_fourier_transform.py
@@ -1,5 +1,6 @@
 import ivy_tests.test_ivy.helpers as helpers
 from ivy_tests.test_ivy.helpers import handle_frontend_test
+from hypothesis import strategies as st
 
 
 @handle_frontend_test(
@@ -42,3 +43,29 @@ def test_numpy_ifttshift(dtype_and_x, frontend, test_flags, fn_tree, on_device):
         x=arr[0],
         axes=None,
     )
+
+
+@handle_frontend_test(
+    fn_tree="numpy.fft.fft",
+    dtype_input_axis=helpers.dtype_values_axis(
+        available_dtypes=helpers.get_dtypes("float_and_complex"), shape=(2,),
+        min_axis=-1,
+        force_int_axis=True,
+    ),
+    norm=st.sampled_from(["backward", "ortho", "forward"]),
+    n=st.integers(min_value=2, max_value=10),
+)
+def test_numpy_fft(dtype_input_axis, norm, n, frontend, test_flags, fn_tree, on_device):
+    input_dtype, x , axis = dtype_input_axis
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_values=True,
+        a=x[0],
+        n=n,
+        axis=axis,
+        norm=norm,
+    )
Repository: ivy-llc/ivy

Issue:
[Bug]: ivy.gamma implementation bug
### Bug Explanation

Currently, backend implementations of `gamma` are failing due to `ivy.Shape` being passed to framework specific backend functions. I suspect that this is related to the `ivy.Shape` refactor and is independent of the following issue.

`ivy.experimental.random.gamma` is not congruent with the backend implementations of `gamma`.  It is implemented as an `ivy` function with
```python 
return ivy.current_backend().gamma(
        shape, alpha, beta, device=device, dtype=dtype, seed=seed, out=out
    )
``` 
`shape` is being passed as a positional argument instead of a keyword argument as it is implemented in the backends.

e.g. `numpy.experimental.random`:
```python
def gamma(
    alpha: Union[float, np.ndarray],
    beta: Union[float, np.ndarray],
    /,
    *,
    shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,
    ...
) -> np.ndarray:
```

### Steps to Reproduce Bug

1.
```python
def test_gamma():
...
test_gamma(
           dtype_and_alpha_beta=(['float32', 'float32'],
            [ivy.array([1.]), ivy.array([1.])]),
           seed=0,
           test_flags=FunctionTestFlags(
               num_positional_args=2,
               with_out=False,
               instance_method=False,
               test_gradients=False,
               test_compile=None,
               as_variable=[False],
               native_arrays=[False],
               container=[False],
           ),
           fn_name='gamma',
           ground_truth_backend='tensorflow',
           backend_fw=ivy.functional.backends.numpy,
           on_device='cpu',
       )
```

### Environment

Windows 10 using PyCharm w/ Docker

### Ivy Version

v1.1.9

### Backend

- [ ] NumPy
- [ ] TensorFlow
- [ ] PyTorch
- [ ] JAX

### Device

_No response_


Discussion:

Resolving patch:
diff --git a/ivy/functional/ivy/experimental/random.py b/ivy/functional/ivy/experimental/random.py
--- a/ivy/functional/ivy/experimental/random.py
+++ b/ivy/functional/ivy/experimental/random.py
@@ -177,7 +177,7 @@ def gamma(
         Returns an array filled with random values sampled from a gamma distribution.
     """
     return ivy.current_backend().gamma(
-        shape, alpha, beta, device=device, dtype=dtype, seed=seed, out=out
+        alpha, beta, shape=shape, device=device, dtype=dtype, seed=seed, out=out
     )
 
 


Test patch:
Repository: ivy-llc/ivy

Issue:
nanmedian
added frontend and test for jax nanmedian function


Discussion:
#14214
Hi @shireenchand, thanks for you PR! Test is failing due to torch backend implementation of nanmedian (torch does not have overwrite_input argument). Feel free to add fixes for it in this PR. Also, please use *available_dtypes=helpers.get_dtypes("valid")* in the tests.
This PR has been labelled as stale because it has been inactive for more than 7 days. If you would like to continue working on this PR, then please add another comment or this PR will be closed in 7 days.
> Hi @shireenchand, thanks for you PR! Test is failing due to torch backend implementation of nanmedian (torch does not have overwrite_input argument). Feel free to add fixes for it in this PR. Also, please use _available_dtypes=helpers.get_dtypes("valid")_ in the tests.

Hi, issues mentioned above still exist, could you please make sure tests are passing on you local machine!
Thanks

Resolving patch:
diff --git a/ivy/functional/frontends/jax/numpy/statistical.py b/ivy/functional/frontends/jax/numpy/statistical.py
--- a/ivy/functional/frontends/jax/numpy/statistical.py
+++ b/ivy/functional/frontends/jax/numpy/statistical.py
@@ -451,3 +451,18 @@ def nanmean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=None):
     )
     ret_nanmean = ivy.divide(array_sum1, count_zero_handel)
     return ret_nanmean
+
+  
+@to_ivy_arrays_and_back
+def nanmedian(
+    a,
+    /,
+    *,
+    axis=None,
+    keepdims=False,
+    out=None,
+    overwrite_input=False,
+):
+    return ivy.nanmedian(
+        a, axis=axis, keepdims=keepdims, out=out, overwrite_input=overwrite_input
+    )


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
@@ -972,3 +972,39 @@ def test_jax_numpy_nanmean(
         keepdims=keepdims,
         where=where,
     )
+
+
+@handle_frontend_test(
+    fn_tree="jax.numpy.nanmedian",
+    dtype_x_axis=helpers.dtype_values_axis(
+        available_dtypes=helpers.get_dtypes("float"),
+        min_num_dims=1,
+        min_value=-(2**10),
+        max_value=2**10,
+        valid_axis=True,
+    ),
+    keepdims=st.booleans(),
+    overwrite_input=st.booleans(),
+)
+def test_jax_numpy_nanmedian(
+    on_device,
+    frontend,
+    *,
+    dtype_x_axis,
+    keepdims,
+    fn_tree,
+    test_flags,
+):
+    input_dtype, x, axis = dtype_x_axis
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        a=x[0],
+        axis=axis,
+        out=None,
+        overwrite_input=False,
+        keepdims=keepdims,
+    )
Repository: ivy-llc/ivy

Issue:
bitwise_right_shift



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py
--- a/ivy/functional/frontends/torch/tensor.py
+++ b/ivy/functional/frontends/torch/tensor.py
@@ -1132,6 +1132,12 @@ def tolist(self):
     def topk(self, k, dim=None, largest=True, sorted=True):
         return torch_frontend.topk(self, k, dim=dim, largest=largest, sorted=sorted)
 
+    rshift_dtypes = ("float16", "bfloat16", "float32", "float64", "bool", "complex")
+
+    @with_unsupported_dtypes({"1.11.0 and below": rshift_dtypes}, "torch")
+    def bitwise_right_shift(self, other, *, out=None):
+        return torch_frontend.bitwise_right_shift(self._ivy_array, other)
+
 
 class Size(tuple):
     def __new__(cls, iterable=()):


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
@@ -3,8 +3,9 @@
 from types import SimpleNamespace
 import numpy as np
 
-from ivy_tests.test_ivy.test_frontends.test_torch.test_comparison_ops import \
-    _topk_helper
+from ivy_tests.test_ivy.test_frontends.test_torch.test_comparison_ops import (
+    _topk_helper,
+)
 
 try:
     import torch
@@ -7941,7 +7942,11 @@ def test_torch_instance_topk(
         init_all_as_kwargs_np={"data": input[0]},
         method_input_dtypes=input_dtype,
         method_all_as_kwargs_np={
-            "k": k, "dim": axis, "largest": largest, "sorted": sorted},
+            "k": k,
+            "dim": axis,
+            "largest": largest,
+            "sorted": sorted,
+        },
         frontend=frontend,
         frontend_method_data=frontend_method_data,
         init_flags=init_flags,
@@ -7949,3 +7954,45 @@ def test_torch_instance_topk(
         on_device=on_device,
         test_values=False,
     )
+
+
+# bitwise right shift
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="bitwise_right_shift",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        num_arrays=2,
+        shared_dtype=True,
+    ),
+)
+def test_torch_instance_bitwise_right_shift(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+):
+    input_dtype, x = dtype_and_x
+    # negative shifts will throw an exception
+    # shifts >= dtype witdth produce backend-defined behavior
+    x[1] = np.asarray(
+        np.clip(x[1], 0, np.iinfo(input_dtype[1]).bits - 1), dtype=input_dtype[1]
+    )
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        init_all_as_kwargs_np={
+            "data": x[0],
+        },
+        method_input_dtypes=input_dtype,
+        method_all_as_kwargs_np={
+            "other": x[1],
+        },
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
Repository: ivy-llc/ivy

Issue:
pad



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/nn/functional/vision_functions.py b/ivy/functional/frontends/torch/nn/functional/vision_functions.py
--- a/ivy/functional/frontends/torch/nn/functional/vision_functions.py
+++ b/ivy/functional/frontends/torch/nn/functional/vision_functions.py
@@ -107,22 +107,12 @@ def _handle_padding_shape(padding, n, mode):
 
 @to_ivy_arrays_and_back
 def pad(input, pad, mode="constant", value=0):
+    mode_dict = {"constant": "constant", "reflect": "reflect", "replicate": "edge", "circular": "wrap"}
+    if mode not in mode_dict:
+        raise ValueError(f"Unsupported padding mode: {mode}")
     pad = _handle_padding_shape(pad, len(input.shape), mode)
-    if mode == "constant":
-        return ivy.pad(input, pad, mode="constant", constant_values=value)
-    elif mode == "reflect":
-        return ivy.pad(input, pad, mode="reflect", reflect_type="even")
-    elif mode == "replicate":
-        return ivy.pad(input, pad, mode="edge")
-    elif mode == "circular":
-        return ivy.pad(input, pad, mode="wrap")
-    else:
-        raise ivy.utils.exceptions.IvyException(
-            (
-                "mode '{}' must be in "
-                + "['constant', 'reflect', 'replicate', 'circular']"
-            ).format(mode)
-        )
+    return ivy.pad(input, pad, mode=mode_dict[mode], constant_values=value)
+
 
 
 def _get_new_width_height(w_old, h_old, size=None, scale_factor=None):


Test patch:
Repository: ivy-llc/ivy

Issue:
while_loop



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/lax/control_flow_operators.py b/ivy/functional/frontends/jax/lax/control_flow_operators.py
--- a/ivy/functional/frontends/jax/lax/control_flow_operators.py
+++ b/ivy/functional/frontends/jax/lax/control_flow_operators.py
@@ -46,3 +46,15 @@ def fori_loop(lower, upper, body_fun, init_val):
     for i in range(lower, upper):
         val = body_fun(i, val)
     return val
+
+
+@to_ivy_arrays_and_back
+def while_loop(cond_fun, body_fun, init_val):
+    if not (callable(body_fun) and callable(cond_fun)):
+        raise ivy.exceptions.IvyException(
+            "jax.lax.while_loop: Arguments body_fun and cond_fun should be callable."
+        )
+    val = init_val
+    while cond_fun(val):
+        val = body_fun(val)
+    return val


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_lax_control_flow_operators.py
@@ -153,3 +153,51 @@ def _test_body_fn(x, y):
         body_fun=_test_body_fn,
         init_val=x[0],
     )
+
+
+@handle_frontend_test(
+    fn_tree="jax.lax.while_loop",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("numeric"),
+        min_value=-1000,
+        max_value=1000,
+        min_num_dims=1,
+        min_dim_size=1,
+    ),
+)
+def test_jax_lax_while_loop(
+    *,
+    dtype_and_x,
+    test_flags,
+    on_device,
+    fn_tree,
+    frontend,
+):
+    def _test_cond_fn(x):
+        def any_negative_real(arr):
+            for elem in arr:
+                if isinstance(elem, (int, float)) and elem < 0:
+                    return True
+                elif isinstance(elem, complex):
+                    return False
+                elif isinstance(elem, (list, tuple)):
+                    if any_negative_real(elem):
+                        return True
+            return False
+
+        return any_negative_real(x)
+
+    def _test_body_fn(x):
+        return x + 1
+
+    input_dtype, x = dtype_and_x
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        test_flags=test_flags,
+        frontend=frontend,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        cond_fun=_test_cond_fn,
+        body_fun=_test_body_fn,
+        init_val=x[0],
+    )
Repository: ivy-llc/ivy

Issue:
 torch.norm



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/reduction_ops.py b/ivy/functional/frontends/torch/reduction_ops.py
--- a/ivy/functional/frontends/torch/reduction_ops.py
+++ b/ivy/functional/frontends/torch/reduction_ops.py
@@ -248,3 +248,13 @@ def unique(input, sorted=True, return_inverse=False, return_counts=False, dim=No
         values.append(results.counts)
 
     return Results(*values)
+
+
+@to_ivy_arrays_and_back
+def norm(input, p="fro", dim=None, keepdim=False, out=None, dtype=None):
+    if (type(dim) in [tuple, list]) and (len(dim) == 2):
+        return ivy.matrix_norm(input, ord=p, axis=dim, keepdims=keepdim, out=out)
+    else:
+        return ivy.vector_norm(
+            input, ord=p, axis=dim, keepdims=keepdim, dtype=dtype, out=out
+        )


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
--- a/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
+++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_reduction_ops.py
@@ -838,3 +838,69 @@ def test_torch_unique(
         return_counts=return_counts,
         dim=axis,
     )
+
+
+@st.composite
+def _get_axis_and_p(draw):
+    force_tuple_axis = True
+
+    p = draw(st.sampled_from(["fro", "nuc", 1, -1, 2, -2]))
+    if p == "fro" or p == "nuc":
+        force_tuple_axis = True
+        min_axes_size = 2
+
+    else:
+        force_tuple_axis = False
+        min_axes_size = 1
+
+    dtype_x_axis = draw(
+        helpers.dtype_values_axis(
+            num_arrays=1,
+            available_dtypes=helpers.get_dtypes("float"),
+            min_num_dims=2,
+            max_num_dims=3,
+            max_dim_size=2,
+            valid_axis=True,
+            min_axes_size=min_axes_size,
+            large_abs_safety_factor=2,
+            safety_factor_scale="log",
+            force_tuple_axis=force_tuple_axis,
+        )
+    )
+
+    return (p, dtype_x_axis)
+
+
+# norm
+@handle_frontend_test(
+    fn_tree="torch.norm",
+    p_dtype_x_axis=_get_axis_and_p(),
+    keepdim=st.booleans(),
+    dtype=helpers.get_dtypes("float", full=False),
+)
+def test_torch_norm(
+    *,
+    p_dtype_x_axis,
+    keepdim,
+    dtype,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    p, values = p_dtype_x_axis
+    input_dtype, x, axis = values
+
+    helpers.test_frontend_function(
+        input_dtypes=input_dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        rtol=1e-01,
+        atol=1e-08,
+        input=x[0],
+        p=p,
+        dim=axis,
+        keepdim=keepdim,
+    )