Skip to content

Commit

Permalink
adding min to jax frontend (ivy-llc#19462)
Browse files Browse the repository at this point in the history
  • Loading branch information
samthakur587 authored Jul 25, 2023
1 parent 5136fef commit 0d9e03b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ivy/functional/frontends/jax/devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ def __iter__(self):
def round(self, decimals=0):
return jax_frontend.numpy.round(self, decimals)

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

def var(
self, *, axis=None, dtype=None, out=None, ddof=False, keepdims=False, where=None
):
Expand Down
45 changes: 45 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_jax/test_devicearray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2162,13 +2162,15 @@ def test_jax_devicearray_var(
on_device,
frontend,
ddof,
backend_fw,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x, axis = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"object": x[0],
},
Expand All @@ -2186,3 +2188,46 @@ def test_jax_devicearray_var(
rtol_=1e-3,
atol_=1e-3,
)


# min
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="jax.numpy.array",
method_name="min",
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_min(
dtype_and_x,
keepdims,
on_device,
frontend,
backend_fw,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x, axis = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
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,
)

0 comments on commit 0d9e03b

Please sign in to comment.