Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshayVenkataraman committed Jun 22, 2023
2 parents 43b0038 + ce18a84 commit ce8daac
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ivy/functional/backends/tensorflow/statistical.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def __get_index(lst, indices=None, prefix=None):


@with_unsupported_dtypes(
{"2.12.0 and below": ("unsigned","int8", "int16")},
{"2.12.0 and below": ("unsigned", "int8", "int16")},
backend_version,
)
def einsum(
Expand Down
3 changes: 2 additions & 1 deletion ivy/functional/frontends/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def promote_types_of_numpy_inputs(
)

from ivy.functional.frontends.numpy.mathematical_functions.floating_point_routines import ( # noqa
_nextafter,
_nextafter, _spacing,
)

_frontend_array = array
Expand Down Expand Up @@ -712,6 +712,7 @@ def promote_types_of_numpy_inputs(
conjugate = ufunc("_conj")
lcm = ufunc("_lcm")
gcd = ufunc("_gcd")
spacing = ufunc("_spacing")
clip = ufunc("_clip")

# setting to specific version #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
handle_numpy_casting,
)


@handle_numpy_out
@handle_numpy_dtype
@to_ivy_arrays_and_back
Expand All @@ -29,3 +28,31 @@ def _nextafter(
subok=True,
):
return ivy.nextafter(x1, x2, out=out)




@handle_numpy_out
@handle_numpy_dtype
@to_ivy_arrays_and_back
@handle_numpy_casting
@from_zero_dim_arrays_to_scalar
def _spacing(
x,
/,
out=None,
*,
where=True,
casting="same_kind",
order="K",
dtype=None,
subok=True,
):
# Implement the frontend function using Ivy compositions
if dtype is None:
dtype = ivy.dtype(x)
y = ivy.floor(ivy.log2(ivy.abs(x + 1)))
spacing = ivy.multiply(ivy.finfo(dtype).eps, ivy.pow(2, y))
if dtype != "float16":
spacing = ivy.sign(x) * spacing
return spacing
4 changes: 3 additions & 1 deletion ivy/functional/frontends/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def exp(x, name=None):
return ivy.exp(x)


@with_unsupported_dtypes({"2.4.2 and below": ("float32", "float64", "int32", "int64")}, "paddle")
@with_unsupported_dtypes(
{"2.4.2 and below": ("float32", "float64", "int32", "int64")}, "paddle"
)
@to_ivy_arrays_and_back
def amax(x, axis=None, keepdim=False, name=None):
return ivy.amax(x, axis=axis, keepdims=keepdim)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ivy_tests.test_ivy.helpers import handle_frontend_test
import ivy_tests.test_ivy.test_frontends.test_numpy.helpers as np_frontend_helpers


# nextafter
@handle_frontend_test(
fn_tree="numpy.nextafter",
dtypes_values_casting=np_frontend_helpers.dtypes_values_casting_dtype(
Expand Down Expand Up @@ -49,3 +49,51 @@ def test_numpy_nextafter(
dtype=dtype,
subok=True,
)


# spacing
@handle_frontend_test(
fn_tree="numpy.spacing",
dtypes_values_casting=np_frontend_helpers.dtypes_values_casting_dtype(
arr_func=[
lambda: helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=1,
)
],
),
where=np_frontend_helpers.where(),
number_positional_args=np_frontend_helpers.get_num_positional_args_ufunc(
fn_name="spacing"
),
)
def test_numpy_spacing(
dtypes_values_casting,
where,
frontend,
test_flags,
fn_tree,
on_device,
):
input_dtypes, xs, casting, dtype = dtypes_values_casting
where, input_dtypes, test_flags = np_frontend_helpers.handle_where_and_array_bools(
where=where,
input_dtype=input_dtypes,
test_flags=test_flags,
)
np_frontend_helpers.test_frontend_function(
input_dtypes=input_dtypes,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
rtol=1e-03,
atol=1e-03,
x=xs[0],
out=None,
where=where,
casting=casting,
order="K",
dtype=dtype,
subok=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -830,4 +830,4 @@ def test_paddle_amax(
fn_tree=fn_tree,
on_device=on_device,
x=x[0],
)
)

0 comments on commit ce8daac

Please sign in to comment.