Skip to content

Commit

Permalink
Adding cumsum_ (ivy-llc#10487)
Browse files Browse the repository at this point in the history
Co-authored-by: guillesanbri <[email protected]>
  • Loading branch information
soma2000-lang and guillesanbri authored Feb 16, 2023
1 parent 027db58 commit 51199ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ def flatten(self, start_dim, end_dim):
def cumsum(self, dim, dtype):
return torch_frontend.cumsum(self._ivy_array, dim, dtype=dtype)

@with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch")
def cumsum_(self, dim, *, dtype=None):
self._ivy_array = self.cumsum(dim, dtype).ivy_array
return self

def inverse(self):
return torch_frontend.inverse(self._ivy_array)

Expand Down
41 changes: 41 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,47 @@ def test_torch_instance_cumsum(
)


# cumsum_
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="cumsum_",
dtype_value=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("numeric"),
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=True,
force_int=True,
),
)
def test_torch_instance_cumsum_(
dtype_value,
dim,
frontend_method_data,
init_flags,
method_flags,
frontend,
):
input_dtype, x = dtype_value
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={
"dim": dim,
"dtype": input_dtype[0],
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
)


# sort
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 51199ed

Please sign in to comment.