Repository: ivy-llc/ivy

Issue:
cummax



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/torch/miscellaneous_ops.py b/ivy/functional/frontends/torch/miscellaneous_ops.py
--- a/ivy/functional/frontends/torch/miscellaneous_ops.py
+++ b/ivy/functional/frontends/torch/miscellaneous_ops.py
@@ -122,8 +122,25 @@ def cross(input, other, dim=None, *, out=None):
 
 
 @to_ivy_arrays_and_back
+@with_unsupported_dtypes(
+    {
+        "2.0.1 and below": (
+            "uint16",
+            "uint32",
+            "uint64",
+            "bfloat16",
+            "float16",
+            "complex64",
+            "complex128",
+        )
+    },
+    "torch",
+)
 def cummax(input, dim, *, out=None):
-    return ivy.cummax(input, axis=dim, out=out)
+    input_dtype = input.dtype
+    result_values, result_indices = ivy.cummax(input, axis=dim, out=out)
+    result_values = result_values.astype(input_dtype)
+    return result_values, result_indices
 
 
 @to_ivy_arrays_and_back
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
@@ -1871,6 +1871,23 @@ def index_fill(self, dim, index, value):
         arr = torch_frontend.moveaxis(self, 0, dim)
         return arr
 
+    @with_unsupported_dtypes(
+        {
+            "2.0.1 and below": (
+                "uint16",
+                "uint32",
+                "uint64",
+                "bfloat16",
+                "float16",
+                "complex64",
+                "complex128",
+            )
+        },
+        "torch",
+    )
+    def cummax(self, dim):
+        return torch_frontend.cummax(self, dim)
+
 
 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
@@ -5446,6 +5446,48 @@ def test_torch_tensor_cross(
     )
 
 
+# cummax
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="torch.tensor",
+    method_name="cummax",
+    dtype_value=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("valid"),
+        shape=st.shared(helpers.get_shape(min_num_dims=1), key="shape"),
+    ),
+    dim=helpers.get_axis(
+        shape=st.shared(helpers.get_shape(), key="shape"),
+        allow_neg=False,
+        force_int=True,
+    ),
+)
+def test_torch_tensor_cummax(
+    dtype_value,
+    dim,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+    backend_fw,
+):
+    input_dtype, x = dtype_value
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        backend_to_test=backend_fw,
+        init_all_as_kwargs_np={
+            "data": x[0],
+        },
+        method_input_dtypes=input_dtype,
+        method_all_as_kwargs_np={"dim": dim},
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
+
+
 # cumprod
 @handle_frontend_method(
     class_tree=CLASS_TREE,