Skip to content

Commit

Permalink
Adden instance method Mean to Jax frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
RakshitKumar04 committed Apr 24, 2023
1 parent 0fbaaa4 commit 881a9dc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ivy/functional/frontends/jax/devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def argmax(
keepdims=keepdims,
)

def mean(self, /, *, axis=None, dtype=None, out=None, keepdims=False, where=None):
return jax_frontend.numpy.mean(self._ivy_array, axis=axis, dtype=dtype, out=out, keepdims=keepdims, where=where)

def __add__(self, other):
return jax_frontend.numpy.add(self, other)

Expand Down
40 changes: 40 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 @@ -128,6 +128,46 @@ def test_jax_devicearray_argmax(
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="jax.numpy.array",
method_name="mean",
dtype_and_x=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("float"),
force_int_axis=True,
min_num_dims=1,
valid_axis=True,
),
keepdims=st.booleans(),
)
def test_jax_devicearray_mean(
dtype_and_x,
keepdims,
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,
"keepdims": keepdims,
},
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 881a9dc

Please sign in to comment.