Skip to content

Commit

Permalink
Added Cumsum instance method to Jax NUmpy Frontend (#16652)
Browse files Browse the repository at this point in the history
  • Loading branch information
RakshitKumar04 authored Jun 19, 2023
1 parent 6c7ecb3 commit 21c95cc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ivy/functional/frontends/jax/devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def cumprod(self, axis=None, dtype=None, out=None):
out=out,
)

def cumsum(self, axis=None, dtype=None, out=None):
return jax_frontend.numpy.cumsum(
self,
axis=axis,
dtype=dtype,
out=out,
)

def nonzero(self, *, size=None, fill_value=None):
return jax_frontend.numpy.nonzero(
self,
Expand Down
42 changes: 42 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,48 @@ def test_jax_devicearray_cumprod(
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="jax.numpy.array",
method_name="cumsum",
dtype_and_x=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("numeric"),
min_num_dims=1,
max_num_dims=5,
min_value=-100,
max_value=100,
valid_axis=True,
allow_neg_axes=False,
max_axes_size=1,
force_int_axis=True,
),
)
def test_jax_devicearray_cumsum(
dtype_and_x,
on_device,
frontend,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x, axis = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
init_all_as_kwargs_np={
"object": x[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={
"axis": axis,
},
frontend=frontend,
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
on_device=on_device,
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="jax.numpy.array",
Expand Down

0 comments on commit 21c95cc

Please sign in to comment.