From a20fc6c93f4b76b09264043e760a8cb3ecc001d9 Mon Sep 17 00:00:00 2001 From: moezAhmad <89748992+moezAhmad@users.noreply.github.com> Date: Sun, 9 Jul 2023 21:20:10 +0500 Subject: [PATCH 01/24] Added mathematical function jax.numpy.imag (#18982) Co-authored-by: hmahmood24 --- .../jax/numpy/mathematical_functions.py | 5 +++ .../test_jax/test_jax_numpy/test_math.py | 34 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/ivy/functional/frontends/jax/numpy/mathematical_functions.py b/ivy/functional/frontends/jax/numpy/mathematical_functions.py index ff37565745cd0..62d588b079ea5 100644 --- a/ivy/functional/frontends/jax/numpy/mathematical_functions.py +++ b/ivy/functional/frontends/jax/numpy/mathematical_functions.py @@ -28,6 +28,11 @@ def add(x1, x2, /): return ivy.add(x1, x2) +@to_ivy_arrays_and_back +def imag(val, /): + return ivy.imag(val) + + @to_ivy_arrays_and_back def angle(z, deg=False): return ivy.angle(z, deg=deg) diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy/test_math.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy/test_math.py index bad3697419fa9..0b614963c55a7 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy/test_math.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy/test_math.py @@ -2515,6 +2515,37 @@ def test_jax_conj( ) +# imag +@handle_frontend_test( + fn_tree="jax.numpy.imag", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float_and_complex"), + min_value=-20, + max_value=20, + ), + test_with_out=st.just(False), +) +def test_jax_imag( + *, + dtype_and_x, + test_flags, + on_device, + fn_tree, + frontend, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + test_flags=test_flags, + frontend=frontend, + fn_tree=fn_tree, + on_device=on_device, + rtol=1e-5, + atol=1e-5, + val=x[0], + ) + + # subtract @handle_frontend_test( fn_tree="jax.numpy.subtract", @@ -2960,7 +2991,8 @@ def test_jax_signbit( # input_dtypes, x, axis, dtype, where = dtype_x_axis_dtype_where # if ivy.current_backend_str() == "torch": # assume(not test_flags.as_variable[0]) -# where, input_dtypes, test_flags = np_frontend_helpers.handle_where_and_array_bools( +# where, input_dtypes, test_flags = np_frontend_helpers. +# handle_where_and_array_bools( # where=where, # input_dtype=input_dtypes, # test_flags=test_flags, From 4816069b82fd1c811f0a2924a62518c22933404e Mon Sep 17 00:00:00 2001 From: Ishtiaq Hussain <53497039+Ishticode@users.noreply.github.com> Date: Sun, 9 Jul 2023 23:53:15 +0100 Subject: [PATCH 02/24] add safety factors to the helper for jax front device array __pow__ methods tests to handle overflows in paddle backend the overflow was leading to value mismatches like -83 != -84 --- .../test_frontends/test_jax/test_jax_devicearray.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py index feff5a0802964..aa9e8c75eb01a 100644 --- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py +++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_devicearray.py @@ -789,7 +789,12 @@ def test_jax_devicearray__abs_( @st.composite def _get_dtype_x_and_int(draw, *, dtype="numeric"): x_dtype, x = draw( - helpers.dtype_and_values(available_dtypes=helpers.get_dtypes(dtype)) + helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes(dtype), + large_abs_safety_factor=2, + small_abs_safety_factor=2, + safety_factor_scale="log", + ) ) pow_dtype, x_int = draw( helpers.dtype_and_values( @@ -798,6 +803,9 @@ def _get_dtype_x_and_int(draw, *, dtype="numeric"): max_value=10, max_num_dims=0, max_dim_size=1, + small_abs_safety_factor=2, + large_abs_safety_factor=2, + safety_factor_scale="log", ) ) x_dtype = x_dtype + pow_dtype From af371b8bee6c86ad2959c9a9982290c7f8c775ab Mon Sep 17 00:00:00 2001 From: "Boakye I. Ababio" Date: Sun, 9 Jul 2023 22:57:45 -0400 Subject: [PATCH 03/24] Add maximum to paddle frontend (#17847) --- .../frontends/paddle/tensor/math.py | 7 +++++ .../test_tensor/test_paddle_math.py | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/math.py b/ivy/functional/frontends/paddle/tensor/math.py index 0dbee7ea0eeed..af4cdbf797003 100644 --- a/ivy/functional/frontends/paddle/tensor/math.py +++ b/ivy/functional/frontends/paddle/tensor/math.py @@ -323,3 +323,10 @@ def trunc(x, name=None): @to_ivy_arrays_and_back def sgn(x, name=None): return ivy.sign(x, np_variant=True) + + +# maximum +@with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") +@to_ivy_arrays_and_back +def maximum(x, y, name=None): + return ivy.maximum(x, y) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_math.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_math.py index aa8e5645aa65a..d2a8cde301ae2 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_math.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_math.py @@ -1356,3 +1356,32 @@ def test_paddle_sgn( on_device=on_device, x=x[0], ) + + +# maximum +@handle_frontend_test( + fn_tree="paddle.maximum", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float"), + num_arrays=2, + shared_dtype=True, + ), +) +def test_paddle_maximum( + *, + dtype_and_x, + on_device, + fn_tree, + frontend, + test_flags, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + y=x[1], + ) From aa004b70711c150dfe9c82d5ba3d093d4d1226fd Mon Sep 17 00:00:00 2001 From: JG <67888047+juliagsy@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:24:57 +0800 Subject: [PATCH 04/24] update readme missing `self.` --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ad33e1604af94..a25b8492472c0 100644 --- a/README.rst +++ b/README.rst @@ -265,8 +265,8 @@ but this can easily be changed to your favorite framework, such as TensorFlow, o super().__init__() def _build(self, *args, **kwargs): - self.linear0 = ivy.Linear(input_dim, 128) - self.linear1 = ivy.Linear(128, output_dim) + self.linear0 = ivy.Linear(self.input_dim, 128) + self.linear1 = ivy.Linear(128, self.output_dim) def _forward(self, x): x = self.linear0(x) From 492318f26a041a81111ed4dfa4b3e2a7401867a0 Mon Sep 17 00:00:00 2001 From: Muhammad Ishaque Nizamani <49721249+MuhammadNizamani@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:34:08 +0500 Subject: [PATCH 05/24] EHN: adding function ifft in paddle fft.py file (#17858) --- ivy/functional/frontends/paddle/fft.py | 10 +++++ .../test_paddle/test_paddle_fft.py | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/ivy/functional/frontends/paddle/fft.py b/ivy/functional/frontends/paddle/fft.py index eb9d9dec4c825..da1d0e3f1c971 100644 --- a/ivy/functional/frontends/paddle/fft.py +++ b/ivy/functional/frontends/paddle/fft.py @@ -44,3 +44,13 @@ def fftshift(x, axes=None, name=None): roll = ivy.roll(x, shifts, axis=axes) return roll + + +@with_supported_dtypes( + {"2.5.0 and below": ("complex64", "complex128")}, + "paddle", +) +@to_ivy_arrays_and_back +def ifft(x, n=None, axis=-1.0, norm="backward", name=None): + ret = ivy.ifft(ivy.astype(x, "complex128"), axis, norm=norm, n=n) + return ivy.astype(ret, x.dtype) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_paddle_fft.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_paddle_fft.py index 0fa652f27d4f3..c03f57a31b88b 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_paddle_fft.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_paddle_fft.py @@ -67,3 +67,41 @@ def test_paddle_fttshift(dtype_x_axis, frontend, test_flags, fn_tree, on_device) x=x[0], axes=axes, ) + + +@handle_frontend_test( + fn_tree="paddle.fft.ifft", + dtype_x_axis=helpers.dtype_values_axis( + available_dtypes=helpers.get_dtypes("valid"), + min_value=-10, + max_value=10, + min_num_dims=1, + min_dim_size=2, + valid_axis=True, + force_int_axis=True, + ), + n=st.one_of( + st.integers(min_value=2, max_value=10), + st.just(None), + ), + norm=st.sampled_from(["backward", "ortho", "forward"]), +) +def test_paddle_ifft( + dtype_x_axis, + n, + norm, + frontend, + test_flags, + fn_tree, +): + input_dtypes, x, axis = dtype_x_axis + helpers.test_frontend_function( + input_dtypes=input_dtypes, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + x=x[0], + n=n, + axis=axis, + norm=norm, + ) From 9f0ee7d14e4879d5765c5395b26d79cc44cb26c1 Mon Sep 17 00:00:00 2001 From: Rakshit Sharma Date: Mon, 10 Jul 2023 11:11:27 +0530 Subject: [PATCH 06/24] add modf to the experimental API(#17629) --- .../array/experimental/elementwise.py | 30 ++++++ .../container/experimental/elementwise.py | 94 +++++++++++++++++++ .../backends/jax/experimental/elementwise.py | 6 ++ .../mxnet/experimental/elementwise.py | 9 ++ .../numpy/experimental/elementwise.py | 6 ++ .../paddle/experimental/elementwise.py | 8 ++ .../tensorflow/experimental/elementwise.py | 6 ++ .../torch/experimental/elementwise.py | 7 ++ .../ivy/experimental/elementwise.py | 36 +++++++ .../test_core/test_elementwise.py | 30 ++++++ 10 files changed, 232 insertions(+) diff --git a/ivy/data_classes/array/experimental/elementwise.py b/ivy/data_classes/array/experimental/elementwise.py index 484302e838fba..ee9af0a167b8f 100644 --- a/ivy/data_classes/array/experimental/elementwise.py +++ b/ivy/data_classes/array/experimental/elementwise.py @@ -919,3 +919,33 @@ def frexp( ivy.array([[0.5, 0.5, 0.75], [1, 2, 2]]) """ return ivy.frexp(self._data, out=out) + + def modf( + self: ivy.Array, /, *, out: Optional[Tuple[ivy.Array, ivy.Array]] = None + ) -> Tuple[ivy.Array, ivy.Array]: + """ + ivy.Array instance method variant of ivy.modf. This method simply wraps the + function, and so the docstring for ivy.modf also applies to this method with + minimal changes. + + Parameters + ---------- + self + Input array. + out + Alternate output arrays in which to place the result. + The default is None. + + Returns + ------- + ret + The fractional and integral parts of the input array. + + Examples + -------- + >>> x = ivy.array([1.5, 2.7, 3.9]) + >>> x.modf() + (ivy.array([0.5, 0.7, 0.9]), ivy.array([1, 2, 3])) + """ + return ivy.modf(self._data, out=out) + \ No newline at end of file diff --git a/ivy/data_classes/container/experimental/elementwise.py b/ivy/data_classes/container/experimental/elementwise.py index 5d3f384a309bb..1c0abb7f71007 100644 --- a/ivy/data_classes/container/experimental/elementwise.py +++ b/ivy/data_classes/container/experimental/elementwise.py @@ -2745,3 +2745,97 @@ def frexp( } """ return self.static_frexp(self, out=out) + + @staticmethod + def static_modf( + x: Union[ivy.Array, ivy.NativeArray, ivy.Container], + /, + *, + key_chains: Optional[Union[List[str], Dict[str, str]]] = None, + to_apply: bool = True, + prune_unapplied: bool = False, + map_sequences: bool = False, + out: Optional[ivy.Container] = None, + ) -> ivy.Container: + """ + ivy.Container static method variant of ivy.modf. This method simply wraps the + function, and so the docstring for ivy.modf also applies to this method with + minimal changes. + + Parameters + ---------- + x + The container whose arrays should be split into the fractional and integral parts. + key_chains + The key-chains to apply or not apply the method to. Default is ``None``. + to_apply + If True, the method will be applied to key_chains, otherwise key_chains + will be skipped. Default is ``True``. + prune_unapplied + Whether to prune key_chains for which the function was not applied. + Default is ``False``. + map_sequences + Whether to also map method to sequences (lists, tuples). + Default is ``False``. + out + optional output container, for writing the result to. + + Returns + ------- + ret + container including the fractional and integral parts of x. + + Examples + -------- + With one :class:`ivy.Container` input: + >>> x = ivy.Container(a=ivy.array([1.2, 2.7, 3.9]), b=ivy.array([-1.5, 5.3, -10.7])) + >>> ivy.Container.static_modf(x) + { + a: (ivy.array([0.2, 0.7, 0.9]), ivy.array([1.0, 2.0, 3.0])), + b: (ivy.array([-0.5, 0.3, -0.7]), ivy.array([-1.0, 5.0, -10.0])) + } + """ + return ContainerBase.cont_multi_map_in_function( + "modf", + x, + key_chains=key_chains, + to_apply=to_apply, + prune_unapplied=prune_unapplied, + map_sequences=map_sequences, + out=out, + ) + + def modf( + self: ivy.Container, + /, + *, + out: Optional[ivy.Container] = None, + ) -> ivy.Container: + """ + ivy.Container instance method variant of ivy.modf. This method simply wraps the + function, and so the docstring for ivy.modf also applies to this method with + minimal changes. + + Parameters + ---------- + self + The container whose arrays should be split into the fractional and integral parts. + out + optional output container, for writing the result to. + + Returns + ------- + ret + container including the fractional and integral parts of x. + + Examples + -------- + With one :class:`ivy.Container` input: + >>> x = ivy.Container(a=ivy.array([1.2, 2.7, 3.9]), b=ivy.array([-1.5, 5.3, -10.7])) + >>> x.modf() + { + a: (ivy.array([0.2, 0.7, 0.9]), ivy.array([1.0, 2.0, 3.0])), + b: (ivy.array([-0.5, 0.3, -0.7]), ivy.array([-1.0, 5.0, -10.0])) + } + """ + return self.static_modf(self, out=out) diff --git a/ivy/functional/backends/jax/experimental/elementwise.py b/ivy/functional/backends/jax/experimental/elementwise.py index 6bda9e89180c8..f53427def2609 100644 --- a/ivy/functional/backends/jax/experimental/elementwise.py +++ b/ivy/functional/backends/jax/experimental/elementwise.py @@ -434,3 +434,9 @@ def frexp( x: JaxArray, /, *, out: Optional[Tuple[JaxArray, JaxArray]] = None ) -> Tuple[JaxArray, JaxArray]: return jnp.frexp(x) + + +def modf( + x: JaxArray,/,*,out: Optional[JaxArray] = None, +) -> JaxArray: + return jnp.modf(x) diff --git a/ivy/functional/backends/mxnet/experimental/elementwise.py b/ivy/functional/backends/mxnet/experimental/elementwise.py index c52db13c00796..9abb037611711 100644 --- a/ivy/functional/backends/mxnet/experimental/elementwise.py +++ b/ivy/functional/backends/mxnet/experimental/elementwise.py @@ -216,3 +216,12 @@ def frexp( ] = None, ) -> Union[(Tuple[(None, None)], Tuple[(mx.ndarray.NDArray, mx.ndarray.NDArray)])]: raise IvyNotImplementedException() + + +def modf( + x: Union[(None, mx.ndarray.NDArray)], + /, + *, + out: Optional[Union[(None, mx.ndarray.NDArray)]] = None, +) -> Union[(None, mx.ndarray.NDArray)]: + raise IvyNotImplementedException() diff --git a/ivy/functional/backends/numpy/experimental/elementwise.py b/ivy/functional/backends/numpy/experimental/elementwise.py index ab4f7280857dd..e731b12f32642 100644 --- a/ivy/functional/backends/numpy/experimental/elementwise.py +++ b/ivy/functional/backends/numpy/experimental/elementwise.py @@ -287,3 +287,9 @@ def frexp( return np.frexp(x, out=(None, None)) else: return np.frexp(x, out=out) + + +def modf( + x: np.ndarray,/,*,out: Optional[np.ndarray] = None, +) -> np.ndarray: + return np.modf(x, out=out) diff --git a/ivy/functional/backends/paddle/experimental/elementwise.py b/ivy/functional/backends/paddle/experimental/elementwise.py index 5f62e6ec3abf7..cfb94cdd93ed9 100644 --- a/ivy/functional/backends/paddle/experimental/elementwise.py +++ b/ivy/functional/backends/paddle/experimental/elementwise.py @@ -609,3 +609,11 @@ def count_nonzero( ) def conj(x: paddle.Tensor, /, *, out: Optional[paddle.Tensor] = None) -> paddle.Tensor: return paddle.conj(x) + + +def modf( + x: paddle.Tensor,/,*,out: Optional[Tuple[paddle.Tensor, paddle.Tensor]] = None +) -> Tuple[paddle.Tensor, paddle.Tensor]: + with ivy.ArrayMode(False): + return paddle.modf(x, out=out) + \ No newline at end of file diff --git a/ivy/functional/backends/tensorflow/experimental/elementwise.py b/ivy/functional/backends/tensorflow/experimental/elementwise.py index 0e4cd25e32663..3ac733634dc80 100644 --- a/ivy/functional/backends/tensorflow/experimental/elementwise.py +++ b/ivy/functional/backends/tensorflow/experimental/elementwise.py @@ -485,3 +485,9 @@ def frexp( m = x / tf.math.pow(2, e) e = tf.cast(e, tf.int32) return m, e + + +def modf( + x: Union[tf.Tensor, tf.Variable],/,*,out: Optional[Union[tf.Tensor, tf.Variable]] = None, +) -> Union[tf.Tensor, tf.Variable]: + return tf.math.modf(x) diff --git a/ivy/functional/backends/torch/experimental/elementwise.py b/ivy/functional/backends/torch/experimental/elementwise.py index ebe2c95b09305..807dc8455052b 100644 --- a/ivy/functional/backends/torch/experimental/elementwise.py +++ b/ivy/functional/backends/torch/experimental/elementwise.py @@ -354,3 +354,10 @@ def frexp( ) -> Tuple[torch.Tensor, torch.Tensor]: mantissa, exponent = torch.frexp(x, out=out) return mantissa, exponent + + +def modf( + x: torch.Tensor,/,*,out: Optional[torch.Tensor] = None, +) -> torch.Tensor: + modf_x = torch.modf(x) + return torch.resolve_modf(input=modf_x) diff --git a/ivy/functional/ivy/experimental/elementwise.py b/ivy/functional/ivy/experimental/elementwise.py index dbc6afc72e77f..92afdbf914fbd 100644 --- a/ivy/functional/ivy/experimental/elementwise.py +++ b/ivy/functional/ivy/experimental/elementwise.py @@ -1138,3 +1138,39 @@ def frexp( (ivy.array([0.5, 0.5, 0.75]), ivy.array([1, 2, 2])) """ return ivy.current_backend(x).frexp(x, out=out) + + +@handle_exceptions +@handle_nestable +@handle_array_like_without_promotion +@handle_out_argument +@to_native_arrays_and_back +def modf( + x: Union[ivy.Array, ivy.NativeArray], + /, + *, + out: Optional[Tuple[ivy.Array, ivy.Array]] = None, +) -> Tuple[ivy.Array, ivy.Array]: + """ + Decompose the elements of x into fractional and integral parts. + + Parameters + ---------- + x + Input array. + out + Optional output array for writing the result to. + It must have a shape that the inputs broadcast to. + + Returns + ------- + ret + A tuple of two arrays, the fractional and integral parts. + + Examples + -------- + >>> x = ivy.array([1.5, 2.7, 3.9]) + >>> ivy.modf(x) + (ivy.array([0.5, 0.7, 0.9]), ivy.array([1, 2, 3])) + """ + return ivy.current_backend(x).modf(x, out=out) diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py index 3097bcb7575df..78b976a4a9e4e 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py @@ -845,3 +845,33 @@ def test_frexp( on_device=on_device, x=x[0], ) + + +# modf +@handle_test( + fn_tree="functional.ivy.experimental.modf", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("numeric"), + num_arrays=1, + min_value=0, + exclude_min=True, + ), + test_with_out=st.just(False), +) +def test_modf( + dtype_and_x, + frontend, + test_flags, + fn_tree, + on_device, +): + input_dtype, x = dtype_and_x + helpers.test_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + ) + \ No newline at end of file From b799660a2182217270b8045e94c2b85dda7dc903 Mon Sep 17 00:00:00 2001 From: Aarsh Chaube <65212523+Aarsh2001@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:25:32 +0530 Subject: [PATCH 07/24] hide ground_truth_backend parameter in test_flags object (#16458) Co-authored-by: Mostafa Hani <71686115+CatB1t@users.noreply.github.com> --- ivy_tests/test_ivy/conftest.py | 6 +- .../test_ivy/helpers/function_testing.py | 16 +- .../test_ivy/helpers/test_parameter_flags.py | 5 + ivy_tests/test_ivy/helpers/testing_helpers.py | 5 +- .../test_core/test_creation.py | 190 +---- .../test_functional/test_core/test_dtype.py | 172 +--- .../test_core/test_elementwise.py | 780 ++---------------- .../test_functional/test_core/test_general.py | 269 +----- .../test_core/test_gradients.py | 32 +- .../test_functional/test_core/test_linalg.py | 308 +------ .../test_core/test_manipulation.py | 163 +--- .../test_functional/test_core/test_random.py | 41 +- .../test_core/test_searching.py | 33 +- .../test_functional/test_core/test_set.py | 44 +- .../test_functional/test_core/test_sorting.py | 36 +- .../test_core/test_statistical.py | 161 ++-- .../test_functional/test_core/test_utility.py | 22 +- .../test_core/test_creation.py | 83 +- .../test_core/test_elementwise.py | 196 +---- .../test_core/test_general.py | 12 +- .../test_core/test_linalg.py | 206 +++-- .../test_core/test_manipulation.py | 246 +----- .../test_experimental/test_core/test_norms.py | 23 +- .../test_core/test_random.py | 35 +- .../test_core/test_searching.py | 11 +- .../test_core/test_sorting.py | 10 +- .../test_core/test_sparse_array.py | 2 +- .../test_core/test_statistical.py | 69 +- .../test_nn/test_activations.py | 77 +- .../test_experimental/test_nn/test_layers.py | 113 +-- .../test_experimental/test_nn/test_norms.py | 35 +- .../test_nn/test_activations.py | 92 +-- .../test_functional/test_nn/test_layers.py | 132 +-- .../test_functional/test_nn/test_losses.py | 7 - .../test_functional/test_nn/test_norms.py | 11 +- 35 files changed, 537 insertions(+), 3106 deletions(-) diff --git a/ivy_tests/test_ivy/conftest.py b/ivy_tests/test_ivy/conftest.py index d3e98d480470d..0eccb97a692cd 100644 --- a/ivy_tests/test_ivy/conftest.py +++ b/ivy_tests/test_ivy/conftest.py @@ -99,7 +99,11 @@ def run_around_tests(request, on_device, backend_fw, compile_graph, implicit): try: test_globals.setup_api_test( backend_fw.backend, - request.function.ground_truth_backend, + ( + request.function.ground_truth_backend + if hasattr(request.function, "ground_truth_backend") + else None + ), on_device, ( request.function.test_data diff --git a/ivy_tests/test_ivy/helpers/function_testing.py b/ivy_tests/test_ivy/helpers/function_testing.py index c40993f3ff61e..350ebaf9d373c 100644 --- a/ivy_tests/test_ivy/helpers/function_testing.py +++ b/ivy_tests/test_ivy/helpers/function_testing.py @@ -125,7 +125,6 @@ def test_function( test_values: bool = True, xs_grad_idxs=None, ret_grad_idxs=None, - ground_truth_backend: str, on_device: str, return_flat_np_arrays: bool = False, **all_as_kwargs_np, @@ -158,8 +157,6 @@ def test_function( ret_grad_idxs Indices of the returned arrays for which to return computed gradients. If None, gradients are returned for all returned arrays. (Default value = None) - ground_truth_backend - Ground Truth Backend to compare the result-values. on_device The device on which to create arrays return_flat_np_arrays @@ -354,8 +351,7 @@ def test_function( f" returned: {out}" ) # compute the return with a Ground Truth backend - - ivy.set_backend(ground_truth_backend) + ivy.set_backend(test_flags.ground_truth_backend) ivy.set_default_device(on_device) try: args, kwargs = create_args_kwargs( @@ -427,7 +423,7 @@ def test_function( atol_=atol_, xs_grad_idxs=xs_grad_idxs, ret_grad_idxs=ret_grad_idxs, - ground_truth_backend=ground_truth_backend, + ground_truth_backend=test_flags.ground_truth_backend, on_device=on_device, ) @@ -435,9 +431,9 @@ def test_function( ret_device = ivy.dev(ret_from_target) assert ret_device == ret_from_gt_device, ( - f"ground truth backend ({ground_truth_backend}) returned array on device" - f" {ret_from_gt_device} but target backend ({ivy.backend}) returned array" - f" on device {ret_device}" + f"ground truth backend ({test_flags.ground_truth_backend}) returned" + f" array on device {ret_from_gt_device} but target backend ({ivy.backend})" + f" returned array on device {ret_device}" ) assert ret_device == on_device, ( f"device is set to {on_device}, but ground truth " @@ -461,7 +457,7 @@ def test_function( ret_np_from_gt_flat=ret_np_from_gt_flat, rtol=rtol_, atol=atol_, - ground_truth_backend=ground_truth_backend, + ground_truth_backend=test_flags.ground_truth_backend, ) diff --git a/ivy_tests/test_ivy/helpers/test_parameter_flags.py b/ivy_tests/test_ivy/helpers/test_parameter_flags.py index b8114247f469c..0812a3cd082f6 100644 --- a/ivy_tests/test_ivy/helpers/test_parameter_flags.py +++ b/ivy_tests/test_ivy/helpers/test_parameter_flags.py @@ -85,6 +85,7 @@ def apply_flags(self, args_to_iterate, input_dtypes, on_device, offset): class FunctionTestFlags(TestFlags): def __init__( self, + ground_truth_backend, num_positional_args, with_out, instance_method, @@ -94,6 +95,7 @@ def __init__( test_gradients, test_compile, ): + self.ground_truth_backend = ground_truth_backend self.num_positional_args = num_positional_args self.with_out = with_out self.instance_method = instance_method @@ -118,6 +120,7 @@ def apply_flags(self, args_to_iterate, input_dtypes, on_device, offset): def __str__(self): return ( + f"ground_truth_backend={self.ground_truth_backend}" f"num_positional_args={self.num_positional_args}. " f"with_out={self.with_out}. " f"instance_method={self.instance_method}. " @@ -136,6 +139,7 @@ def __repr__(self): def function_flags( draw, *, + ground_truth_backend, num_positional_args, instance_method, with_out, @@ -148,6 +152,7 @@ def function_flags( return draw( st.builds( FunctionTestFlags, + ground_truth_backend=ground_truth_backend, num_positional_args=num_positional_args, with_out=with_out, instance_method=instance_method, diff --git a/ivy_tests/test_ivy/helpers/testing_helpers.py b/ivy_tests/test_ivy/helpers/testing_helpers.py index 67cbde45949c5..c1f32ad1d50bc 100644 --- a/ivy_tests/test_ivy/helpers/testing_helpers.py +++ b/ivy_tests/test_ivy/helpers/testing_helpers.py @@ -323,13 +323,14 @@ def handle_test( fn_tree = "ivy." + fn_tree is_hypothesis_test = len(_given_kwargs) != 0 - possible_arguments = {"ground_truth_backend": st.just(ground_truth_backend)} + possible_arguments = {} if is_hypothesis_test and is_fn_tree_provided: # Use the default strategy if number_positional_args is None: number_positional_args = num_positional_args(fn_name=fn_tree) # Generate the test flags strategy possible_arguments["test_flags"] = pf.function_flags( + ground_truth_backend=st.just(ground_truth_backend), num_positional_args=number_positional_args, instance_method=test_instance_method, with_out=test_with_out, @@ -375,8 +376,8 @@ def wrapped_test(*args, **kwargs): fn_name=fn_name, supported_device_dtypes=supported_device_dtypes, ) - wrapped_test.ground_truth_backend = ground_truth_backend wrapped_test._ivy_test = True + wrapped_test.ground_truth_backend = ground_truth_backend return wrapped_test diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_creation.py b/ivy_tests/test_ivy/test_functional/test_core/test_creation.py index a32d9db2157f9..ae60bc60206c4 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_creation.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_creation.py @@ -25,7 +25,6 @@ def test_native_array( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype, x, dtype = dtype_and_x_and_cast_dtype helpers.test_function( @@ -37,7 +36,6 @@ def test_native_array( x=x[0], dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -75,7 +73,6 @@ def test_linspace( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, start_stop, axis = dtype_and_start_stop_axis helpers.test_function( @@ -93,7 +90,6 @@ def test_linspace( endpoint=endpoint, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -133,7 +129,6 @@ def test_logspace( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, start_stop, axis = dtype_and_start_stop_axis helpers.test_function( @@ -152,7 +147,6 @@ def test_logspace( endpoint=endpoint, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -177,7 +171,6 @@ def test_arange( test_flags, backend_fw, fn_name, - ground_truth_backend, on_device, ): helpers.test_function( @@ -191,7 +184,6 @@ def test_arange( step=step, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -250,7 +242,6 @@ def test_asarray( backend_fw, fn_name, on_device, - ground_truth_backend, ): x_dtype, x, dtype = x_dtype_x_and_dtype if isinstance(x, list) and len(x) == 1: @@ -268,7 +259,6 @@ def test_asarray( object_in=x, dtype=dtype, device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -286,16 +276,7 @@ def test_asarray( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_empty( - *, - shape, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_empty(*, shape, dtype, test_flags, backend_fw, fn_name, on_device): ret = helpers.test_function( input_dtypes=dtype, test_flags=test_flags, @@ -306,7 +287,6 @@ def test_empty( dtype=dtype[0], device=on_device, test_values=False, - ground_truth_backend=ground_truth_backend, return_flat_np_arrays=True, ) helpers.assert_same_type_and_shape(ret) @@ -320,15 +300,7 @@ def test_empty( ), test_gradients=st.just(False), ) -def test_empty_like( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_empty_like(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x ret = helpers.test_function( input_dtypes=dtype, @@ -340,7 +312,6 @@ def test_empty_like( dtype=dtype[0], device=on_device, test_values=False, - ground_truth_backend=ground_truth_backend, return_flat_np_arrays=True, ) helpers.assert_same_type_and_shape(ret) @@ -360,17 +331,7 @@ def test_empty_like( test_gradients=st.just(False), ) def test_eye( - *, - n_rows, - n_cols, - k, - batch_shape, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, n_rows, n_cols, k, batch_shape, dtype, test_flags, backend_fw, fn_name, on_device ): helpers.test_function( input_dtypes=dtype, @@ -384,7 +345,6 @@ def test_eye( batch_shape=batch_shape, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -400,15 +360,7 @@ def test_eye( ), test_gradients=st.just(False), ) -def test_from_dlpack( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_from_dlpack(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, @@ -417,7 +369,6 @@ def test_from_dlpack( fw=backend_fw, fn_name=fn_name, x=x[0], - ground_truth_backend=ground_truth_backend, ) @@ -446,17 +397,7 @@ def _fill_value(draw): test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_full( - *, - shape, - fill_value, - dtypes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_full(*, shape, fill_value, dtypes, test_flags, backend_fw, fn_name, on_device): helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, @@ -467,7 +408,6 @@ def test_full( fill_value=fill_value, dtype=dtypes[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -491,14 +431,7 @@ def _dtype_and_values(draw): fill_value=_fill_value(), ) def test_full_like( - *, - dtype_and_x, - fill_value, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, fill_value, test_flags, backend_fw, fn_name, on_device ): dtype, x = dtype_and_x helpers.test_function( @@ -511,7 +444,6 @@ def test_full_like( fill_value=fill_value, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -530,15 +462,7 @@ def test_full_like( test_with_out=st.just(False), ) def test_meshgrid( - *, - dtype_and_arrays, - test_flags, - sparse, - indexing, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_arrays, test_flags, sparse, indexing, backend_fw, fn_name, on_device ): dtype, arrays = dtype_and_arrays kw = {} @@ -556,7 +480,6 @@ def test_meshgrid( **kw, sparse=sparse, indexing=indexing, - ground_truth_backend=ground_truth_backend, ) @@ -574,16 +497,7 @@ def test_meshgrid( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_ones( - *, - shape, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_ones(*, shape, dtype, test_flags, backend_fw, fn_name, on_device): helpers.test_function( input_dtypes=dtype, test_flags=test_flags, @@ -593,7 +507,6 @@ def test_ones( shape=shape, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -604,15 +517,7 @@ def test_ones( available_dtypes=helpers.get_dtypes("numeric"), ), ) -def test_ones_like( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_ones_like(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( input_dtypes=dtype, @@ -623,7 +528,6 @@ def test_ones_like( x=x[0], dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -639,16 +543,7 @@ def test_ones_like( ), k=helpers.ints(min_value=-10, max_value=10), ) -def test_tril( - *, - dtype_and_x, - k, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tril(*, dtype_and_x, k, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( @@ -659,7 +554,6 @@ def test_tril( fn_name=fn_name, x=x[0], k=k, - ground_truth_backend=ground_truth_backend, ) @@ -675,16 +569,7 @@ def test_tril( ), k=helpers.ints(min_value=-10, max_value=10), ) -def test_triu( - *, - dtype_and_x, - k, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_triu(*, dtype_and_x, k, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( @@ -695,7 +580,6 @@ def test_triu( fn_name=fn_name, x=x[0], k=k, - ground_truth_backend=ground_truth_backend, ) @@ -713,16 +597,7 @@ def test_triu( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_zeros( - *, - shape, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_zeros(*, shape, dtype, test_flags, backend_fw, fn_name, on_device): helpers.test_function( input_dtypes=dtype, test_flags=test_flags, @@ -732,7 +607,6 @@ def test_zeros( shape=shape, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -747,15 +621,7 @@ def test_zeros( max_dim_size=5, ), ) -def test_zeros_like( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_zeros_like(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( input_dtypes=dtype, @@ -766,7 +632,6 @@ def test_zeros_like( x=x[0], dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -854,13 +719,7 @@ def _on_off_dtype(draw): test_gradients=st.just(False), ) def test_one_hot( - dtype_indices_depth_axis, - on_off_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_indices_depth_axis, on_off_dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, indices, depth, axis = dtype_indices_depth_axis on_value, off_value, dtype = on_off_dtype @@ -876,7 +735,6 @@ def test_one_hot( off_value=off_value, axis=axis, dtype=dtype, - ground_truth_backend=ground_truth_backend, ) @@ -908,12 +766,7 @@ def _get_dtype_buffer_count_offset(draw): test_gradients=st.just(False), ) def test_frombuffer( - dtype_buffer_count_offset, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_buffer_count_offset, test_flags, backend_fw, fn_name, on_device ): input_dtype, buffer, count, offset = dtype_buffer_count_offset helpers.test_function( @@ -926,7 +779,6 @@ def test_frombuffer( dtype=input_dtype[0], count=count, offset=offset, - ground_truth_backend=ground_truth_backend, ) @@ -941,20 +793,10 @@ def test_frombuffer( test_instance_method=st.just(False), ) def test_triu_indices( - *, - n_rows, - n_cols, - k, - input_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, n_rows, n_cols, k, input_dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype = input_dtype helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_dtype.py b/ivy_tests/test_ivy/test_functional/test_core/test_dtype.py index e56b7214440cd..e27a831eea68f 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_dtype.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_dtype.py @@ -80,17 +80,10 @@ def astype_helper(draw): test_gradients=st.just(False), ) def test_astype( - *, - dtype_and_x_and_cast_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x_and_cast_dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, cast_dtype = dtype_and_x_and_cast_dtype helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -124,14 +117,7 @@ def broadcastable_arrays(draw, dtypes): test_gradients=st.just(False), ) def test_broadcast_arrays( - *, - arrays, - input_dtypes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, arrays, input_dtypes, test_flags, backend_fw, fn_name, on_device ): if backend_fw.current_backend_str() == "torch": for input_dtype in input_dtypes: @@ -147,7 +133,6 @@ def test_broadcast_arrays( kw["x{}".format(i)] = np.asarray(array, dtype=dtype) test_flags.num_positional_args = len(kw) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -164,18 +149,10 @@ def test_broadcast_arrays( test_gradients=st.just(False), ) def test_broadcast_to( - *, - array_and_shape, - input_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, array_and_shape, input_dtype, test_flags, backend_fw, fn_name, on_device ): array, to_shape = array_and_shape helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -196,19 +173,9 @@ def test_broadcast_to( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_can_cast( - *, - dtype_and_x, - to_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_can_cast(*, dtype_and_x, to_dtype, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -250,22 +217,13 @@ def _array_or_type(draw, float_or_int): test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_finfo( - *, - type, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_finfo(*, type, test_flags, backend_fw, fn_name, on_device): if isinstance(type, str): input_dtype = [type] else: input_dtype, x = type type = x[0] ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -294,22 +252,13 @@ def test_finfo( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_iinfo( - *, - type, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_iinfo(*, type, test_flags, backend_fw, fn_name, on_device): if isinstance(type, str): input_dtype = [type] else: input_dtype, x = type type = x[0] ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -338,22 +287,13 @@ def test_iinfo( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_result_type( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_result_type(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = helpers.as_lists(*dtype_and_x) kw = {} for i, (dtype_, x_) in enumerate(zip(dtype, x)): kw["x{}".format(i)] = x_ test_flags.num_positional_args = len(kw) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -484,15 +424,7 @@ def test_default_dtype( test_gradients=st.just(False), ) def test_dtype( - *, - array, - input_dtype, - as_native, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, array, input_dtype, as_native, test_flags, backend_fw, fn_name, on_device ): if backend_fw.current_backend_str() == "torch": if input_dtype == "bfloat16" or ( @@ -503,7 +435,6 @@ def test_dtype( return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -525,17 +456,8 @@ def test_dtype( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_dtype_bits( - *, - input_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_dtype_bits(*, input_dtype, test_flags, backend_fw, fn_name, on_device): ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -559,18 +481,9 @@ def test_dtype_bits( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_is_bool_dtype( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_bool_dtype(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -589,18 +502,9 @@ def test_is_bool_dtype( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_is_float_dtype( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_float_dtype(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -619,18 +523,9 @@ def test_is_float_dtype( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_is_int_dtype( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_int_dtype(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -649,18 +544,9 @@ def test_is_int_dtype( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_is_uint_dtype( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_uint_dtype(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -679,18 +565,9 @@ def test_is_uint_dtype( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_is_complex_dtype( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_complex_dtype(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -710,18 +587,8 @@ def test_is_complex_dtype( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_promote_types( - *, - type1, - type2, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_promote_types(*, type1, type2, test_flags, backend_fw, fn_name, on_device): helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[], test_flags=test_flags, fw=backend_fw, @@ -747,17 +614,10 @@ def test_promote_types( test_gradients=st.just(False), ) def test_type_promote_arrays( - *, - dtype_and_values, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_values, test_flags, backend_fw, fn_name, on_device ): types, arrays = dtype_and_values helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=types, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_elementwise.py b/ivy_tests/test_ivy/test_functional/test_core/test_elementwise.py index 6f40e8b35f4a0..1717f30e22164 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_elementwise.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_elementwise.py @@ -37,18 +37,9 @@ def _array_with_mask(draw): fn_tree="functional.ivy.abs", dtype_and_x_and_where=_array_with_mask(), ) -def test_abs( - *, - dtype_and_x_and_where, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_abs(*, dtype_and_x_and_where, test_flags, backend_fw, fn_name, on_device): input_dtype, x, where = dtype_and_x_and_where helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -69,18 +60,9 @@ def test_abs( small_abs_safety_factor=4, ), ) -def test_acosh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_acosh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -101,18 +83,9 @@ def test_acosh( small_abs_safety_factor=4, ), ) -def test_acos( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_acos(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -136,20 +109,10 @@ def test_acos( ), alpha=st.integers(min_value=1, max_value=5), ) -def test_add( - *, - dtype_and_x, - alpha, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_add(*, dtype_and_x, alpha, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -172,18 +135,9 @@ def test_add( small_abs_safety_factor=4, ), ) -def test_asin( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_asin(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -204,18 +158,9 @@ def test_asin( small_abs_safety_factor=4, ), ) -def test_asinh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_asinh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -232,18 +177,9 @@ def test_asinh( fn_tree="functional.ivy.atan", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_atan( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atan(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -267,19 +203,10 @@ def test_atan( max_dim_size=5, ), ) -def test_atan2( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atan2(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x assume(not (np.any(np.isclose(x[0], 0)) or np.any(np.isclose(x[1], 0)))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -297,18 +224,9 @@ def test_atan2( fn_tree="functional.ivy.atanh", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_atanh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atanh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -330,18 +248,9 @@ def test_atanh( ), test_gradients=st.just(False), ) -def test_bitwise_and( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bitwise_and(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -362,15 +271,7 @@ def test_bitwise_and( ), test_gradients=st.just(False), ) -def test_bitwise_left_shift( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bitwise_left_shift(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # negative shifts will throw an exception # shifts >= dtype witdth produce backend-defined behavior @@ -411,18 +312,9 @@ def test_bitwise_left_shift( ), test_gradients=st.just(False), ) -def test_bitwise_invert( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bitwise_invert(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -442,18 +334,9 @@ def test_bitwise_invert( ), test_gradients=st.just(False), ) -def test_bitwise_or( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bitwise_or(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -475,13 +358,7 @@ def test_bitwise_or( test_gradients=st.just(False), ) def test_bitwise_right_shift( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x @@ -492,7 +369,6 @@ def test_bitwise_right_shift( ) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -513,18 +389,9 @@ def test_bitwise_right_shift( ), test_gradients=st.just(False), ) -def test_bitwise_xor( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bitwise_xor(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -544,18 +411,9 @@ def test_bitwise_xor( safety_factor_scale="linear", ), ) -def test_ceil( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_ceil(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -570,18 +428,9 @@ def test_ceil( fn_tree="functional.ivy.cos", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_cos( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_cos(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -596,18 +445,9 @@ def test_cos( fn_tree="functional.ivy.cosh", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_cosh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_cosh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -628,21 +468,12 @@ def test_cosh( safety_factor_scale="log", ), ) -def test_divide( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_divide(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # prevent too close to zero assume(not np.any(np.isclose(x[1], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -661,18 +492,9 @@ def test_divide( ), test_gradients=st.just(False), ) -def test_equal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_equal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -688,18 +510,9 @@ def test_equal( fn_tree="functional.ivy.exp", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_exp( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_exp(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -723,20 +536,12 @@ def test_exp( ), test_gradients=st.just(False), ) -def test_exp2( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_exp2(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, x=np.asarray(x[0], dtype=input_dtype[0]), @@ -748,18 +553,9 @@ def test_exp2( fn_tree="functional.ivy.expm1", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_expm1( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_expm1(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -778,19 +574,10 @@ def test_expm1( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_floor( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_floor(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -811,22 +598,13 @@ def test_floor( shared_dtype=True, ), ) -def test_floor_divide( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_floor_divide(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # Make sure it's not dividing value too close to zero assume(not np.any(np.isclose(x[1], 0))) # Absolute tolerance is 1, # due to flooring can cause absolute error of 1 due to precision helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -855,21 +633,13 @@ def test_floor_divide( ), test_gradients=st.just(False), ) -def test_fmin( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fmin(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, fw=backend_fw, - ground_truth_backend=ground_truth_backend, fn_name=fn_name, x1=x[0], x2=x[1], @@ -884,20 +654,11 @@ def test_fmin( ), test_gradients=st.just(False), ) -def test_greater( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_greater(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # bfloat16 is not supported assume(not ("bfloat16" in input_dtype)) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -916,22 +677,13 @@ def test_greater( ), test_gradients=st.just(False), ) -def test_greater_equal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_greater_equal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # bfloat16 is not supported by numpy assume(not ("bfloat16" in input_dtype)) # make sure they're not too close together assume(not (np.any(np.isclose(x[0], x[1])) or np.any(np.isclose(x[1], x[0])))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -950,18 +702,9 @@ def test_greater_equal( ), test_gradients=st.just(False), ) -def test_isfinite( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_isfinite(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -990,11 +733,9 @@ def test_isinf( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1014,18 +755,9 @@ def test_isinf( ), test_gradients=st.just(False), ) -def test_isnan( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_isnan(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1045,22 +777,13 @@ def test_isnan( ), test_gradients=st.just(False), ) -def test_less( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_less(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # bfloat16 is not supported by numpy assume(not ("bfloat16" in input_dtype)) # make sure they're not too close together assume(not (np.any(np.isclose(x[0], x[1])) or np.any(np.isclose(x[1], x[0])))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1079,22 +802,13 @@ def test_less( ), test_gradients=st.just(False), ) -def test_less_equal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_less_equal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # bfloat16 is not supported by numpy assume(not ("bfloat16" in input_dtype)) # make sure they're not too close together assume(not (np.any(np.isclose(x[0], x[1])) or np.any(np.isclose(x[1], x[0])))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1110,20 +824,11 @@ def test_less_equal( fn_tree="functional.ivy.log", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_log( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_log(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # avoid logging values too close to zero assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1142,20 +847,11 @@ def test_log( safety_factor_scale="log", ), ) -def test_log1p( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_log1p(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # avoid logging values too close to zero assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1170,20 +866,11 @@ def test_log1p( fn_tree="functional.ivy.log2", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_log2( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_log2(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # avoid logging values too close to zero assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1199,20 +886,11 @@ def test_log2( fn_tree="functional.ivy.log10", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_log10( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_log10(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # avoid logging values too close to zero assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1235,18 +913,9 @@ def test_log10( max_value=80, ), ) -def test_logaddexp( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logaddexp(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1274,19 +943,10 @@ def test_logaddexp( ), test_gradients=st.just(False), ) -def test_logaddexp2( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logaddexp2(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, - ground_truth_backend=ground_truth_backend, test_flags=test_flags, fw=backend_fw, fn_name=fn_name, @@ -1306,19 +966,10 @@ def test_logaddexp2( ), test_gradients=st.just(False), ) -def test_logical_and( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logical_and(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1335,18 +986,9 @@ def test_logical_and( dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("valid")), test_gradients=st.just(False), ) -def test_logical_not( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logical_not(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1364,19 +1006,10 @@ def test_logical_not( ), test_gradients=st.just(False), ) -def test_logical_or( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logical_or(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1395,19 +1028,10 @@ def test_logical_or( ), test_gradients=st.just(False), ) -def test_logical_xor( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logical_xor(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1425,19 +1049,10 @@ def test_logical_xor( available_dtypes=helpers.get_dtypes("numeric"), num_arrays=2 ), ) -def test_multiply( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_multiply(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1455,18 +1070,9 @@ def test_multiply( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_negative( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_negative(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1505,12 +1111,10 @@ def test_nan_to_num( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, - ground_truth_backend=ground_truth_backend, test_flags=test_flags, fw=backend_fw, fn_name=fn_name, @@ -1531,19 +1135,10 @@ def test_nan_to_num( ), test_gradients=st.just(False), ) -def test_not_equal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_not_equal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1561,18 +1156,9 @@ def test_not_equal( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_positive( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_positive(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1640,15 +1226,7 @@ def cast_filter(dtype1_x1_dtype2): fn_tree="functional.ivy.pow", dtype_and_x=pow_helper(), ) -def test_pow( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_pow(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # bfloat16 is not supported by numpy @@ -1666,7 +1244,6 @@ def test_pow( x[0] = not_too_close_to_zero(x[0]) x[1] = not_too_close_to_zero(x[1]) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1686,18 +1263,9 @@ def test_pow( available_dtypes=helpers.get_dtypes("real_and_complex") ), ) -def test_real( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_real(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1719,16 +1287,7 @@ def test_real( ), modulus=st.booleans(), ) -def test_remainder( - *, - dtype_and_x, - modulus, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_remainder(*, dtype_and_x, modulus, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # Make sure values is not too close to zero assume(not np.any(np.isclose(x[0], 0))) @@ -1738,7 +1297,6 @@ def test_remainder( test_flags.test_gradients = False test_flags.as_variable = [test_flags.as_variable, False] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1760,16 +1318,7 @@ def test_remainder( ), decimals=st.integers(min_value=0, max_value=5), ) -def test_round( - *, - dtype_and_x, - decimals, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_round(*, dtype_and_x, decimals, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( ground_truth_backend="numpy", @@ -1794,20 +1343,10 @@ def test_round( ), np_variant=st.booleans(), ) -def test_sign( - *, - dtype_and_x, - np_variant, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sign(*, dtype_and_x, np_variant, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x assume(not np.any(np.isclose(x[0], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1823,18 +1362,9 @@ def test_sign( fn_tree="functional.ivy.sin", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_sin( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sin(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1849,18 +1379,9 @@ def test_sin( fn_tree="functional.ivy.sinh", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_sinh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sinh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1879,18 +1400,9 @@ def test_sinh( safety_factor_scale="log", ), ) -def test_square( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_square(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1907,18 +1419,9 @@ def test_square( available_dtypes=helpers.get_dtypes("float"), allow_inf=False ), ) -def test_sqrt( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sqrt(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1942,19 +1445,9 @@ def test_sqrt( ), alpha=st.integers(min_value=1, max_value=5), ) -def test_subtract( - *, - dtype_and_x, - alpha, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_subtract(*, dtype_and_x, alpha, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -1973,18 +1466,9 @@ def test_subtract( fn_tree="functional.ivy.tan", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_tan( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tan(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2001,18 +1485,9 @@ def test_tan( fn_tree="functional.ivy.tanh", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_tanh( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tanh(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2068,13 +1543,7 @@ def _either_x_dx(draw): test_gradients=st.just(False), ) def test_trapz( - dtype_values_axis, - rand_either, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_values_axis, rand_either, test_flags, backend_fw, fn_name, on_device ): input_dtype, y, axis = dtype_values_axis rand, either_x_dx = rand_either @@ -2090,7 +1559,6 @@ def test_trapz( test_flags=test_flags, on_device=on_device, fw=backend_fw, - ground_truth_backend=ground_truth_backend, fn_name=fn_name, rtol_=1e-1, atol_=1e-1, @@ -2108,18 +1576,9 @@ def test_trapz( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_trunc( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_trunc(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2138,18 +1597,9 @@ def test_trunc( fn_tree="functional.ivy.erf", dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("float")), ) -def test_erf( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_erf(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2193,17 +1643,10 @@ def min_max_helper(draw): dtype_and_x_and_use_where=min_max_helper(), ) def test_minimum( - *, - dtype_and_x_and_use_where, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x_and_use_where, test_flags, backend_fw, fn_name, on_device ): (input_dtype, x), use_where = dtype_and_x_and_use_where helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2223,17 +1666,10 @@ def test_minimum( dtype_and_x_and_use_where=min_max_helper(), ) def test_maximum( - *, - dtype_and_x_and_use_where, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x_and_use_where, test_flags, backend_fw, fn_name, on_device ): (input_dtype, x), use_where = dtype_and_x_and_use_where helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2258,18 +1694,9 @@ def test_maximum( num_arrays=1, ), ) -def test_reciprocal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_reciprocal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2287,18 +1714,9 @@ def test_reciprocal( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_deg2rad( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_deg2rad(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2314,18 +1732,9 @@ def test_deg2rad( available_dtypes=helpers.get_dtypes("numeric") ), ) -def test_rad2deg( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_rad2deg(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2346,20 +1755,11 @@ def test_rad2deg( safety_factor_scale="log", ), ) -def test_trunc_divide( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_trunc_divide(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # prevent too close to zero assume(not np.any(np.isclose(x[1], 0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2380,18 +1780,9 @@ def test_trunc_divide( ), test_gradients=st.just(False), ) -def test_isreal( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_isreal(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -2414,14 +1805,7 @@ def test_isreal( ), test_gradients=st.just(False), ) -def test_fmod( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fmod(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x # Make sure values is not too close to zero assume(not np.any(np.isclose(x[0], 0))) @@ -2434,7 +1818,6 @@ def test_fmod( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, x1=x[0], @@ -2457,20 +1840,12 @@ def test_fmod( ), test_gradients=st.just(False), ) -def test_lcm( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_lcm(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, x1=x[0], @@ -2493,19 +1868,10 @@ def test_lcm( ), test_gradients=st.just(False), ) -def test_gcd( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_gcd(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, - ground_truth_backend=ground_truth_backend, test_flags=test_flags, fw=backend_fw, fn_name=fn_name, @@ -2535,7 +1901,6 @@ def test_imag( *, dtype_and_x, test_flags, - ground_truth_backend, backend_fw, fn_name, on_device, @@ -2544,7 +1909,6 @@ def test_imag( helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, on_device=on_device, @@ -2574,7 +1938,6 @@ def test_angle( dtype_and_x, deg, test_flags, - ground_truth_backend, backend_fw, fn_name, on_device, @@ -2583,7 +1946,6 @@ def test_angle( helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_general.py b/ivy_tests/test_ivy/test_functional/test_core/test_general.py index 6ba70cf120a15..c4483229b6714 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_general.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_general.py @@ -154,19 +154,11 @@ def __init__(self): test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_array_equal( - dtypes_and_xs, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_array_equal(dtypes_and_xs, test_flags, backend_fw, fn_name, on_device): dtypes, arrays = dtypes_and_xs helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -196,13 +188,11 @@ def test_get_item( backend_fw, fn_name, on_device, - ground_truth_backend, ): dtypes, x, query = dtypes_x_query helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -260,16 +250,7 @@ def test_set_item( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_to_numpy( - *, - dtype_x, - copy, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_to_numpy(*, dtype_x, copy, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x # torch throws an exception if ivy.current_backend_str() == "torch" and not copy: @@ -277,7 +258,6 @@ def test_to_numpy( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -300,19 +280,11 @@ def test_to_numpy( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_to_scalar( - x0_n_x1_n_res, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_to_scalar(x0_n_x1_n_res, test_flags, backend_fw, fn_name, on_device): dtype, x = x0_n_x1_n_res helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -330,19 +302,11 @@ def test_to_scalar( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_to_list( - x0_n_x1_n_res, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_to_list(x0_n_x1_n_res, test_flags, backend_fw, fn_name, on_device): dtype, x = x0_n_x1_n_res helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -362,21 +326,12 @@ def test_to_list( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_shape( - x0_n_x1_n_res, - as_array, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_shape(x0_n_x1_n_res, as_array, test_flags, backend_fw, fn_name, on_device): dtype, x = x0_n_x1_n_res # instance_method=False because the shape property would overwrite the shape method helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -396,19 +351,12 @@ def test_shape( test_gradients=st.just(False), ) def test_get_num_dims( - x0_n_x1_n_res, - as_array, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + x0_n_x1_n_res, as_array, test_flags, backend_fw, fn_name, on_device ): dtype, x = x0_n_x1_n_res helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -457,19 +405,12 @@ def _vector_norm_helper(draw): dtype_x_max_norm_p=_vector_norm_helper(), ) def test_clip_vector_norm( - *, - dtype_x_max_norm_p, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_max_norm_p, test_flags, backend_fw, fn_name, on_device ): dtype, x, max_norm, p = dtype_x_max_norm_p helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -630,15 +571,7 @@ def values_and_ndindices( reduction=st.sampled_from(["sum", "min", "max", "replace"]), ground_truth_backend="tensorflow", ) -def test_scatter_flat( - x, - reduction, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_scatter_flat(x, reduction, test_flags, backend_fw, fn_name, on_device): # scatter_flat throws an error while computing gradients for tensorflow # this has been fixed in the newer versions of tensorflow (2.10.0 onwards) if "tensorflow" in backend_fw.__name__: @@ -655,7 +588,6 @@ def test_scatter_flat( input_dtypes=ind_dtype + val_dtype, test_flags=test_flags, xs_grad_idxs=[[0, 1]], - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -681,21 +613,12 @@ def test_scatter_flat( reduction=st.sampled_from(["sum", "min", "max", "replace"]), test_gradients=st.just(False), ) -def test_scatter_nd( - x, - reduction, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_scatter_nd(x, reduction, test_flags, backend_fw, fn_name, on_device): (val_dtype, ind_dtype, update_dtype), vals, ind, updates = x shape = vals.shape helpers.test_function( input_dtypes=[ind_dtype, update_dtype], test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -718,19 +641,11 @@ def test_scatter_nd( max_dim_size=10, ), ) -def test_gather( - params_indices_others, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_gather(params_indices_others, test_flags, backend_fw, fn_name, on_device): dtypes, params, indices, axis, batch_dims = params_indices_others helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -834,18 +749,12 @@ def ndindices_with_bounds( ), ) def test_gather_nd( - params_n_ndindices_batch_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + params_n_ndindices_batch_dims, test_flags, backend_fw, fn_name, on_device ): dtypes, params, ndindices, batch_dims = params_n_ndindices_batch_dims helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1154,20 +1063,13 @@ def test_explicit_ivy_framework_handles(): ), ) def test_einops_rearrange( - dtype_x, - pattern_and_axes_lengths, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_x, pattern_and_axes_lengths, test_flags, backend_fw, fn_name, on_device ): pattern, axes_lengths = pattern_and_axes_lengths dtype, x = dtype_x helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1212,7 +1114,6 @@ def test_einops_reduce( backend_fw, fn_name, on_device, - ground_truth_backend, ): pattern, axes_lengths = pattern_and_axes_lengths dtype, x = dtype_x @@ -1224,7 +1125,6 @@ def test_einops_reduce( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1258,14 +1158,7 @@ def test_einops_reduce( ), ) def test_einops_repeat( - *, - dtype_x, - pattern_and_axes_lengths, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x, pattern_and_axes_lengths, test_flags, backend_fw, fn_name, on_device ): pattern, axes_lengths = pattern_and_axes_lengths dtype, x = dtype_x @@ -1273,7 +1166,6 @@ def test_einops_repeat( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1421,14 +1313,7 @@ def test_inplace_increment(x_val_and_dtypes, test_flags, on_device): test_gradients=st.just(False), ) def test_is_ivy_array( - *, - x_val_and_dtypes, - exclusive, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, x_val_and_dtypes, exclusive, test_flags, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes # as_variable=False as the result can't be consistent across backends @@ -1438,7 +1323,6 @@ def test_is_ivy_array( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1460,14 +1344,7 @@ def test_is_ivy_array( test_gradients=st.just(False), ) def test_is_native_array( - *, - x_val_and_dtypes, - test_flags, - exclusive, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, x_val_and_dtypes, test_flags, exclusive, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes # as_variable=False as the result can't be consistent across backends @@ -1477,7 +1354,6 @@ def test_is_native_array( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1499,13 +1375,7 @@ def test_is_native_array( test_gradients=st.just(False), ) def test_is_array( - x_val_and_dtypes, - exclusive, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + x_val_and_dtypes, exclusive, test_flags, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes # as_variable=False as the result can't be consistent across backends @@ -1515,7 +1385,6 @@ def test_is_array( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1534,19 +1403,11 @@ def test_is_array( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_is_ivy_container( - x_val_and_dtypes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_is_ivy_container(x_val_and_dtypes, test_flags, backend_fw, fn_name, on_device): dtype, x = x_val_and_dtypes helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1567,13 +1428,7 @@ def test_is_ivy_container( test_gradients=st.just(False), ) def test_all_equal( - dtypes_and_xs, - equality_matrix, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtypes_and_xs, equality_matrix, test_flags, backend_fw, fn_name, on_device ): dtypes, arrays = dtypes_and_xs kw = {} @@ -1585,7 +1440,6 @@ def test_all_equal( helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1611,20 +1465,12 @@ def test_all_equal( p=st.sampled_from([1, 2, float("inf"), "fro", "nuc"]), ) def test_clip_matrix_norm( - dtype_x, - max_norm, - p, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_x, max_norm, p, test_flags, backend_fw, fn_name, on_device ): dtype, x = dtype_x helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1651,20 +1497,12 @@ def test_clip_matrix_norm( test_gradients=st.just(False), ) def test_value_is_nan( - *, - val_dtype, - include_infs, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, val_dtype, include_infs, test_flags, backend_fw, fn_name, on_device ): dtype, val = val_dtype helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1686,20 +1524,12 @@ def test_value_is_nan( test_gradients=st.just(False), ) def test_has_nans( - *, - x_val_and_dtypes, - include_infs, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, x_val_and_dtypes, include_infs, test_flags, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1895,20 +1725,11 @@ def test_set_min_base(x): ), test_with_out=st.just(False), ) -def test_stable_divide( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_stable_divide(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -1937,21 +1758,13 @@ def _get_valid_numeric_no_unsigned(draw): test_with_out=st.just(False), ) def test_stable_pow( - *, - dtypes_and_xs, - min_base, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtypes_and_xs, min_base, test_flags, backend_fw, fn_name, on_device ): dtypes, xs = dtypes_and_xs assume(all(["bfloat16" not in x for x in dtypes])) helpers.test_function( input_dtypes=dtypes, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -2017,18 +1830,12 @@ def test_set_tmp_dir(): test_gradients=st.just(False), ) def test_supports_inplace_updates( - x_val_and_dtypes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + x_val_and_dtypes, test_flags, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -2047,12 +1854,7 @@ def test_supports_inplace_updates( test_gradients=st.just(False), ) def test_assert_supports_inplace( - x_val_and_dtypes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + x_val_and_dtypes, test_flags, backend_fw, fn_name, on_device ): dtype, x = x_val_and_dtypes if ivy.current_backend_str() in ["tensorflow", "jax", "paddle"]: @@ -2061,7 +1863,6 @@ def test_assert_supports_inplace( helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -2206,19 +2007,11 @@ def test_isin( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_itemsize( - x_and_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_itemsize(x_and_dtype, test_flags, backend_fw, fn_name, on_device): dtype, x = x_and_dtype helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -2233,19 +2026,11 @@ def test_itemsize( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_strides( - x_and_dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_strides(x_and_dtype, test_flags, backend_fw, fn_name, on_device): dtype, x = x_and_dtype helpers.test_function( input_dtypes=dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_gradients.py b/ivy_tests/test_ivy/test_functional/test_core/test_gradients.py index 3d2017ad0727a..a5f6bd513e056 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_gradients.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_gradients.py @@ -81,18 +81,10 @@ def get_gradient_arguments_with_lr( test_gradients=st.just(False), ) def test_stop_gradient( - *, - dtype_and_x, - preserve_type, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, preserve_type, test_flags, backend_fw, fn_name, on_device ): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -119,14 +111,7 @@ def test_stop_gradient( test_gradients=st.just(False), ) def test_execute_with_gradients( - *, - dtype_and_xs, - retain_grads, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_xs, retain_grads, test_flags, backend_fw, fn_name, on_device ): def func(xs): if isinstance(xs, ivy.Container): @@ -143,7 +128,6 @@ def func(xs): dtype, xs = dtype_and_xs helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -307,7 +291,6 @@ def test_adam_step( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [dcdw, mw, vw] = dtype_n_dcdw_n_mw_n_vw ( @@ -316,7 +299,6 @@ def test_adam_step( epsilon, ) = beta1_n_beta2_n_epsilon helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -348,11 +330,9 @@ def test_optimizer_update( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [w, effective_grad], lr = dtype_n_ws_n_effgrad_n_lr helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, fw=backend_fw, test_flags=test_flags, @@ -381,11 +361,9 @@ def test_gradient_descent_update( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [w, dcdw], lr = dtype_n_ws_n_dcdw_n_lr helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -418,14 +396,12 @@ def test_lars_update( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [w, dcdw], lr = dtype_n_ws_n_dcdw_n_lr # ToDo: Add testing for bfloat16 back when it returns consistent gradients for jax if "bfloat16" in input_dtypes: return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -468,13 +444,11 @@ def test_adam_update( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [w, dcdw, mw_tm1, vw_tm1], lr = dtype_n_ws_n_dcdw_n_mwtm1_n_vwtm1_n_lr beta1, beta2, epsilon = beta1_n_beta2_n_epsilon stop_gradients = stopgrad helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -528,7 +502,6 @@ def test_lamb_update( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtypes, [w, dcdw, mw_tm1, vw_tm1], lr = dtype_n_ws_n_dcdw_n_mwtm1_n_vwtm1_n_lr ( @@ -542,7 +515,6 @@ def test_lamb_update( if "jax" in backend_fw.__name__: test_flags.test_gradients = False helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_linalg.py b/ivy_tests/test_ivy/test_functional/test_core/test_linalg.py index cbfe79b811043..6a4978653ef5c 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_linalg.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_linalg.py @@ -268,17 +268,10 @@ def _get_dtype_and_vector(draw): dtype_x=_get_dtype_and_vector(), ) def test_vector_to_skew_symmetric_matrix( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -299,20 +292,10 @@ def test_vector_to_skew_symmetric_matrix( ), n=helpers.ints(min_value=-6, max_value=6), ) -def test_matrix_power( - *, - dtype_x, - n, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_matrix_power(*, dtype_x, n, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x assume(matrix_is_stable(x[0])) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -331,20 +314,10 @@ def test_matrix_power( x=_get_first_matrix_and_dtype(transpose=True), y=_get_second_matrix_and_dtype(transpose=True), ) -def test_matmul( - *, - x, - y, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_matmul(*, x, y, test_flags, backend_fw, fn_name, on_device): input_dtype1, x_1, transpose_a, adjoint_a = x input_dtype2, y_1, transpose_b, adjoint_b = y helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype1 + input_dtype2, test_flags=test_flags, fw=backend_fw, @@ -381,19 +354,10 @@ def _det_helper(draw): fn_tree="functional.ivy.det", dtype_x=_det_helper(), ) -def test_det( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_det(*, dtype_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x assume(matrix_is_stable(x[0])) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -412,19 +376,9 @@ def test_det( UPLO=st.sampled_from(("L", "U")), test_gradients=st.just(False), ) -def test_eigh( - *, - dtype_x, - UPLO, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_eigh(*, dtype_x, UPLO, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x results = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -477,19 +431,9 @@ def test_eigh( UPLO=st.sampled_from(("L", "U")), test_gradients=st.just(False), ) -def test_eigvalsh( - *, - dtype_x, - UPLO, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_eigvalsh(*, dtype_x, UPLO, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -515,18 +459,9 @@ def test_eigvalsh( max_num_dims=1, ), ) -def test_inner( - *, - dtype_xy, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_inner(*, dtype_xy, test_flags, backend_fw, fn_name, on_device): types, arrays = dtype_xy helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=types, test_flags=test_flags, fw=backend_fw, @@ -551,19 +486,9 @@ def test_inner( ).filter(lambda x: np.linalg.cond(x[1][0].tolist()) < 1 / sys.float_info.epsilon), adjoint=st.booleans(), ) -def test_inv( - *, - dtype_x, - adjoint, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_inv(*, dtype_x, adjoint, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -581,18 +506,9 @@ def test_inv( fn_tree="functional.ivy.matrix_transpose", dtype_x=_get_first_matrix_and_dtype(conjugate=True), ) -def test_matrix_transpose( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_matrix_transpose(*, dtype_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x, conjugate = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -615,18 +531,9 @@ def test_matrix_transpose( max_num_dims=1, ), ) -def test_outer( - *, - dtype_xy, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_outer(*, dtype_xy, test_flags, backend_fw, fn_name, on_device): types, arrays = dtype_xy helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=types, test_flags=test_flags, fw=backend_fw, @@ -645,22 +552,13 @@ def test_outer( dtype_x=_det_helper(), test_with_out=st.just(False), ) -def test_slogdet( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_slogdet(*, dtype_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x assume(matrix_is_stable(x[0])) ret_grad_idxs = ( [[1, "a"], [1, "b", "c"], [1, "b", "d"]] if test_flags.container[0] else [[1]] ) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -678,20 +576,10 @@ def test_slogdet( x=helpers.get_first_solve_matrix(adjoint=True), y=helpers.get_second_solve_matrix(), ) -def test_solve( - *, - x, - y, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_solve(*, x, y, test_flags, backend_fw, fn_name, on_device): input_dtype1, x1, adjoint = x input_dtype2, x2 = y helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[input_dtype1, input_dtype2], test_flags=test_flags, fw=backend_fw, @@ -716,18 +604,9 @@ def test_solve( ), test_gradients=st.just(False), ) -def test_svdvals( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_svdvals(*, dtype_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -750,15 +629,7 @@ def test_svdvals( max_dim_size=10, ), ) -def test_tensordot( - *, - dtype_x1_x2_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tensordot(*, dtype_x1_x2_axis, test_flags, backend_fw, fn_name, on_device): ( dtype, x1, @@ -767,7 +638,6 @@ def test_tensordot( ) = dtype_x1_x2_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -797,20 +667,10 @@ def test_tensordot( # TODO: test for more offsets offset=st.integers(min_value=-3, max_value=3), ) -def test_trace( - *, - dtype_x_axes, - offset, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_trace(*, dtype_x_axes, offset, test_flags, backend_fw, fn_name, on_device): dtype, x, axes = dtype_x_axes axis1, axis2 = axes helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -839,18 +699,9 @@ def test_trace( max_dim_size=4, ), ) -def test_vecdot( - *, - dtype_x1_x2_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_vecdot(*, dtype_x1_x2_axis, test_flags, backend_fw, fn_name, on_device): dtype, x1, x2, axis = dtype_x1_x2_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -885,16 +736,7 @@ def test_vecdot( dtype=helpers.get_dtypes("numeric", full=False, none=True), ) def test_vector_norm( - *, - dtype_values_axis, - kd, - ord, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_values_axis, kd, ord, dtype, test_flags, backend_fw, fn_name, on_device ): x_dtype, x, axis = dtype_values_axis # to avoid tuple axis with only one axis as force_int_axis can't generate @@ -902,7 +744,6 @@ def test_vector_norm( if isinstance(axis, tuple) and len(axis) == 1: axis = axis[0] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=x_dtype, test_flags=test_flags, fw=backend_fw, @@ -943,19 +784,9 @@ def test_vector_norm( ), rtol=st.floats(1e-5, 1e-3), ) -def test_pinv( - *, - dtype_x, - rtol, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_pinv(*, dtype_x, rtol, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -976,19 +807,9 @@ def test_pinv( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_qr( - *, - dtype_x, - mode, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_qr(*, dtype_x, mode, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x results = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1035,21 +856,10 @@ def test_qr( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_svd( - *, - dtype_x, - uv, - fm, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_svd(*, dtype_x, uv, fm, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x results = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1121,20 +931,11 @@ def test_svd( ord=st.sampled_from((-2, -1, 1, 2, -float("inf"), float("inf"), "fro", "nuc")), ) def test_matrix_norm( - *, - dtype_value_axis, - kd, - ord, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_value_axis, kd, ord, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_value_axis assume(matrix_is_stable(x[0], cond_limit=10)) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1196,18 +997,11 @@ def _matrix_rank_helper(draw): ground_truth_backend="numpy", ) def test_matrix_rank( - *, - dtype_x_hermitian_atol_rtol, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_hermitian_atol_rtol, test_flags, backend_fw, fn_name, on_device ): dtype, x, hermitian, atol, rtol = dtype_x_hermitian_atol_rtol assume(matrix_is_stable(x, cond_limit=10)) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1232,22 +1026,12 @@ def test_matrix_rank( ), upper=st.booleans(), ) -def test_cholesky( - *, - dtype_x, - upper, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_cholesky(*, dtype_x, upper, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x x = x[0] x = np.matmul(x.T, x) + np.identity(x.shape[0]) # make symmetric positive-definite helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1275,18 +1059,9 @@ def test_cholesky( safety_factor_scale="log", ), ) -def test_cross( - *, - dtype_x1_x2_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_cross(*, dtype_x1_x2_axis, test_flags, backend_fw, fn_name, on_device): dtype, x1, x2, axis = dtype_x1_x2_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1315,20 +1090,9 @@ def test_cross( helpers.ints(min_value=-2, max_value=1), min_size=2, max_size=2, unique=True ).filter(lambda axes: axes[0] % 2 != axes[1] % 2), ) -def test_diagonal( - *, - dtype_x, - offset, - axes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_diagonal(*, dtype_x, offset, axes, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1368,18 +1132,9 @@ def _diag_helper(draw): fn_tree="functional.ivy.diag", dtype_x_k=_diag_helper(), ) -def test_diag( - *, - dtype_x_k, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_diag(*, dtype_x_k, test_flags, backend_fw, fn_name, on_device): dtype, x, k = dtype_x_k helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1406,19 +1161,10 @@ def test_diag( increasing=st.booleans(), ) def test_vander( - *, - dtype_and_x, - N, - increasing, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, N, increasing, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_manipulation.py b/ivy_tests/test_ivy/test_functional/test_core/test_manipulation.py index 0e7649c538827..31b3ca1a5c45a 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_manipulation.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_manipulation.py @@ -52,17 +52,10 @@ def _arrays_idx_n_dtypes(draw): xs_n_input_dtypes_n_unique_idx=_arrays_idx_n_dtypes(), ) def test_concat( - *, - xs_n_input_dtypes_n_unique_idx, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, xs_n_input_dtypes_n_unique_idx, test_flags, backend_fw, fn_name, on_device ): xs, input_dtypes, unique_idx = xs_n_input_dtypes_n_unique_idx helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -84,20 +77,10 @@ def test_concat( shape=st.shared(helpers.get_shape(), key="value_shape"), ), ) -def test_expand_dims( - *, - dtype_value, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_expand_dims(*, dtype_value, axis, test_flags, backend_fw, fn_name, on_device): dtype, value = dtype_value try: helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -127,20 +110,10 @@ def test_expand_dims( force_int=True, ), ) -def test_flip( - *, - dtype_value, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_flip(*, dtype_value, axis, test_flags, backend_fw, fn_name, on_device): dtype, value = dtype_value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -169,19 +142,11 @@ def _permute_dims_helper(draw): permutation=_permute_dims_helper(), ) def test_permute_dims( - *, - dtype_value, - permutation, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_value, permutation, test_flags, backend_fw, fn_name, on_device ): dtype, value = dtype_value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -213,13 +178,11 @@ def test_reshape( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): dtype, value = dtype_value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -269,17 +232,7 @@ def test_reshape( ), # test_gradients=st.just(False), ) -def test_roll( - *, - dtype_value, - shift, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_roll(*, dtype_value, shift, axis, test_flags, backend_fw, fn_name, on_device): value_dtype, value = dtype_value shift_dtype, shift_val = shift @@ -291,7 +244,6 @@ def test_roll( shift_val = tuple(shift_val[0].tolist()) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=value_dtype + shift_dtype, test_flags=test_flags, fw=backend_fw, @@ -324,20 +276,10 @@ def _squeeze_helper(draw): ), axis=_squeeze_helper(), ) -def test_squeeze( - *, - dtype_value, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_squeeze(*, dtype_value, axis, test_flags, backend_fw, fn_name, on_device): dtype, value = dtype_value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -373,20 +315,10 @@ def _stack_helper(draw): force_int=True, ), ) -def test_stack( - *, - dtypes_arrays, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_stack(*, dtypes_arrays, axis, test_flags, backend_fw, fn_name, on_device): dtypes, arrays = dtypes_arrays helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, fw=backend_fw, @@ -420,18 +352,9 @@ def _basic_min_x_max(draw): fn_tree="functional.ivy.clip", dtype_x_min_max=_basic_min_x_max(), ) -def test_clip( - *, - dtype_x_min_max, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_clip(*, dtype_x_min_max, test_flags, backend_fw, fn_name, on_device): dtypes, (x_list, min_val, max_val) = dtype_x_min_max helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes[0], test_flags=test_flags, fw=backend_fw, @@ -471,18 +394,11 @@ def _constant_pad_helper(draw): dtype_value_pad_width_constant=_constant_pad_helper(), ) def test_constant_pad( - *, - dtype_value_pad_width_constant, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_value_pad_width_constant, test_flags, backend_fw, fn_name, on_device ): dtype, value, pad_width = dtype_value_pad_width_constant constant = float(value[0].flat[0]) # just use the first value as fill value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -542,15 +458,7 @@ def _repeat_helper(draw): repeat=st.one_of(st.integers(1, 10), _repeat_helper()), ) def test_repeat( - *, - dtype_value, - axis, - repeat, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_value, axis, repeat, test_flags, backend_fw, fn_name, on_device ): value_dtype, value = dtype_value @@ -563,7 +471,6 @@ def test_repeat( axis = axis[0] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=value_dtype, test_flags=test_flags, fw=backend_fw, @@ -669,8 +576,7 @@ def test_split( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): dtype, value = dtype_value if ( @@ -680,7 +586,6 @@ def test_split( ): dtype = [*dtype, num_or_size_splits.dtype] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -708,20 +613,11 @@ def test_split( ), ) def test_swapaxes( - *, - dtype_value, - axis0, - axis1, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_value, axis0, axis1, test_flags, backend_fw, fn_name, on_device ): dtype, value = dtype_value helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -748,20 +644,10 @@ def test_swapaxes( max_value=10, ), ) -def test_tile( - *, - dtype_value, - repeat, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tile(*, dtype_value, repeat, test_flags, backend_fw, fn_name, on_device): dtype, value = dtype_value repeat_dtype, repeat_list = repeat helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype + repeat_dtype, test_flags=test_flags, fw=backend_fw, @@ -780,18 +666,9 @@ def test_tile( fn_tree="functional.ivy.zero_pad", dtype_value_pad_width=_constant_pad_helper(), ) -def test_zero_pad( - *, - dtype_value_pad_width, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_zero_pad(*, dtype_value_pad_width, test_flags, backend_fw, fn_name, on_device): dtype, value, pad_width = dtype_value_pad_width helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -815,21 +692,13 @@ def test_zero_pad( test_with_out=st.just(False), ) def test_unstack( - *, - x_n_dtype_axis, - keepdims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, x_n_dtype_axis, keepdims, test_flags, backend_fw, fn_name, on_device ): # smoke test dtype, x, axis = x_n_dtype_axis if axis >= len(x[0].shape): axis = len(x[0].shape) - 1 helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_random.py b/ivy_tests/test_ivy/test_functional/test_core/test_random.py index 47551a439fc1d..59f55db79381d 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_random.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_random.py @@ -41,15 +41,13 @@ def test_random_uniform( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): low_dtype, low = dtype_and_low high_dtype, high = dtype_and_high def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=low_dtype + high_dtype, test_flags=test_flags, on_device=on_device, @@ -106,14 +104,12 @@ def test_random_normal( backend_fw, fn_name, on_device, - ground_truth_backend, ): mean_dtype, mean = dtype_and_mean std_dtype, std = dtype_and_std def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=mean_dtype + std_dtype, test_flags=test_flags, on_device=on_device, @@ -169,21 +165,11 @@ def _pop_size_num_samples_replace_n_probs(draw): test_gradients=st.just(False), test_instance_method=st.just(False), ) -def test_multinomial( - *, - everything, - seed, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_multinomial(*, everything, seed, test_flags, backend_fw, fn_name, on_device): prob_dtype, batch_size, population_size, num_samples, replace, probs = everything def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=prob_dtype, test_flags=test_flags, on_device=on_device, @@ -247,21 +233,11 @@ def _gen_randint_data(draw): seed=helpers.ints(min_value=0, max_value=100), test_gradients=st.just(False), ) -def test_randint( - *, - dtype_low_high, - seed, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_randint(*, dtype_low_high, seed, test_flags, backend_fw, fn_name, on_device): dtype, low, high = dtype_low_high def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -310,21 +286,12 @@ def test_seed(seed_val): test_gradients=st.just(False), ) def test_shuffle( - *, - dtype_and_x, - seed, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, seed, axis, test_flags, backend_fw, fn_name, on_device ): dtype, x = dtype_and_x def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_searching.py b/ivy_tests/test_ivy/test_functional/test_core/test_searching.py index 25ebcd0b2fc32..31e30c2c53a55 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_searching.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_searching.py @@ -67,12 +67,10 @@ def test_argmax( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): input_dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -102,12 +100,10 @@ def test_argmin( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): input_dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -142,12 +138,10 @@ def test_nonzero( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -164,19 +158,10 @@ def test_nonzero( fn_tree="functional.ivy.where", broadcastables=_broadcastable_trio(), ) -def test_where( - *, - broadcastables, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_where(*, broadcastables, test_flags, backend_fw, fn_name, on_device): cond, xs, dtypes = broadcastables helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=["bool"] + dtypes, test_flags=test_flags, fw=backend_fw, @@ -193,15 +178,7 @@ def test_where( fn_tree="functional.ivy.argwhere", dtype_and_x=helpers.dtype_and_values(available_dtypes=("bool",)), ) -def test_argwhere( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_argwhere(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( ground_truth_backend="torch", diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_set.py b/ivy_tests/test_ivy/test_functional/test_core/test_set.py index 8614910cc2156..b819c2cc7fcbf 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_set.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_set.py @@ -18,20 +18,11 @@ ), test_gradients=st.just(False), ) -def test_unique_values( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_unique_values(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x assume(not np.any(np.isclose(x, 0.0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -58,21 +49,12 @@ def test_unique_values( ground_truth_backend="numpy", ) def test_unique_all( - *, - dtype_x_axis, - none_axis, - by_value, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, none_axis, by_value, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_x_axis if none_axis: axis = None helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -95,20 +77,11 @@ def test_unique_all( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_unique_counts( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_unique_counts(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x assume(not np.any(np.isclose(x, 0.0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -129,20 +102,11 @@ def test_unique_counts( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_unique_inverse( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_unique_inverse(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x assume(not np.any(np.isclose(x, 0.0))) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_sorting.py b/ivy_tests/test_ivy/test_functional/test_core/test_sorting.py index 49b80bd7e0b44..3dc3e7dadca49 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_sorting.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_sorting.py @@ -24,19 +24,10 @@ test_gradients=st.just(False), ) def test_argsort( - *, - dtype_x_axis, - descending, - stable, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, descending, stable, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -64,19 +55,10 @@ def test_argsort( test_gradients=st.just(False), ) def test_sort( - *, - dtype_x_axis, - descending, - stable, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, descending, stable, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -103,17 +85,9 @@ def test_sort( ), test_gradients=st.just(False), ) -def test_msort( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_msort(dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -185,8 +159,7 @@ def test_searchsorted( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): dtypes, xs = dtypes_and_xs if use_sorter: @@ -197,7 +170,6 @@ def test_searchsorted( sorter = None xs[0] = np.sort(xs[0]) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py b/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py index f5dc35e1df9c6..9fc9ab75c1017 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py @@ -82,19 +82,9 @@ def _get_castable_dtype(draw, min_value=None, max_value=None): dtype_and_x=_statistical_dtype_values(function="min"), keep_dims=st.booleans(), ) -def test_min( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_min(*, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -112,19 +102,9 @@ def test_min( dtype_and_x=_statistical_dtype_values(function="max"), keep_dims=st.booleans(), ) -def test_max( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_max(*, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -142,19 +122,9 @@ def test_max( dtype_and_x=_statistical_dtype_values(function="mean"), keep_dims=st.booleans(), ) -def test_mean( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_mean(*, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -174,19 +144,9 @@ def test_mean( dtype_and_x=_statistical_dtype_values(function="var"), keep_dims=st.booleans(), ) -def test_var( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_var(*, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis, correction = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -208,14 +168,7 @@ def test_var( keep_dims=st.booleans(), ) def test_prod( - *, - dtype_x_axis_castable, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis_castable, keep_dims, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, axis, castable_dtype = dtype_x_axis_castable # ToDo: set as_variable_flags as the parameter generated by test_prod once @@ -224,7 +177,6 @@ def test_prod( assume(not test_flags.as_variable[0]) assume(not test_flags.test_gradients) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[input_dtype], test_flags=test_flags, fw=backend_fw, @@ -246,14 +198,7 @@ def test_prod( keep_dims=st.booleans(), ) def test_sum( - *, - dtype_x_axis_castable, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis_castable, keep_dims, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, axis, castable_dtype = dtype_x_axis_castable # ToDo: set as_variable_flags as the parameter generated by test_sum once @@ -262,7 +207,6 @@ def test_sum( assume(not test_flags.as_variable[0]) assume(not test_flags.test_gradients) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[input_dtype], test_flags=test_flags, fw=backend_fw, @@ -283,19 +227,9 @@ def test_sum( dtype_and_x=_statistical_dtype_values(function="std"), keep_dims=st.booleans(), ) -def test_std( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_std(*, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis, correction = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -325,7 +259,6 @@ def test_cumsum( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype, x, axis, castable_dtype = dtype_x_axis_castable # ToDo: set as_variable_flags as the parameter generated by test_cumsum once @@ -334,7 +267,6 @@ def test_cumsum( assume(not test_flags.as_variable[0]) assume(not test_flags.test_gradients) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[input_dtype], test_flags=test_flags, fw=backend_fw, @@ -350,6 +282,52 @@ def test_cumsum( ) +@handle_test( + fn_tree="functional.ivy.cummax", + dtype_x_axis_castable=helpers.dtype_values_axis( + available_dtypes=helpers.get_dtypes("valid"), + min_num_dims=1, + max_num_dims=6, + min_value=-100, + max_value=100, + valid_axis=True, + allow_neg_axes=False, + max_axes_size=1, + force_int_axis=True, + ), + exclusive=st.booleans(), + reverse=st.booleans(), +) +def test_cummax( + *, + dtype_x_axis_castable, + exclusive, + reverse, + test_flags, + backend_fw, + fn_name, + on_device, +): + input_dtype, x, axis = dtype_x_axis_castable + if "torch" in backend_fw.__name__: + assume(not test_flags.as_variable[0]) + assume(not test_flags.test_gradients) + + helpers.test_function( + input_dtypes=input_dtype, + test_flags=test_flags, + fw=backend_fw, + fn_name=fn_name, + on_device=on_device, + x=x[0], + axis=axis, + exclusive=exclusive, + reverse=reverse, + rtol_=1e-1, + atol_=1e-1, + ) + + # cumprod @handle_test( fn_tree="functional.ivy.cumprod", @@ -366,7 +344,6 @@ def test_cumprod( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype, x, axis, castable_dtype = dtype_x_axis_castable # ToDo: set as_variable_flags as the parameter generated by test_cumprod once @@ -382,7 +359,6 @@ def test_cumprod( if np.abs(np.min(np.abs(x[0])) - 0) < 1e-4: assume(not test_flags.test_gradients) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=[input_dtype], test_flags=test_flags, fw=backend_fw, @@ -398,6 +374,36 @@ def test_cumprod( ) +# cummin +@handle_test( + fn_tree="functional.ivy.cummin", + dtype_x_axis_castable=_get_castable_dtype(), + reverse=st.booleans(), +) +def test_cummin( + *, dtype_x_axis_castable, reverse, test_flags, backend_fw, fn_name, on_device +): + input_dtype, x, axis, castable_dtype = dtype_x_axis_castable + # ToDo: set as_variable_flags as the parameter generated by test_cummin once + # this issue is marked as completed https://github.com/pytorch/pytorch/issues/75733 + if "torch" in backend_fw.__name__: + assume(not test_flags.as_variable[0]) + assume(not test_flags.test_gradients) + helpers.test_function( + input_dtypes=[input_dtype], + test_flags=test_flags, + fw=backend_fw, + fn_name=fn_name, + on_device=on_device, + x=x[0], + axis=axis, + reverse=reverse, + dtype=castable_dtype, + rtol_=1e-4, + atol_=1e-4, + ) + + # TODO: add more general tests and fix get instance method testing passing # einsum @handle_test( @@ -426,7 +432,6 @@ def test_einsum( # len(operands) + 1 because of the equation test_flags.num_positional_args = len(operands) + 1 helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_utility.py b/ivy_tests/test_ivy/test_functional/test_core/test_utility.py index 379accfc5fd62..6a900716c3a6c 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_utility.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_utility.py @@ -19,19 +19,10 @@ keepdims=st.booleans(), test_gradients=st.just(False), ) -def test_all( - dtype_x_axis, - keepdims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_all(dtype_x_axis, keepdims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_x_axis axis = axis if axis is None or isinstance(axis, int) else axis[0] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -54,19 +45,10 @@ def test_all( keepdims=st.booleans(), test_gradients=st.just(False), ) -def test_any( - dtype_x_axis, - keepdims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_any(dtype_x_axis, keepdims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_x_axis axis = axis if axis is None or isinstance(axis, int) else axis[0] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_creation.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_creation.py index 770bc05eb08c2..2bff0ffb953c1 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_creation.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_creation.py @@ -21,18 +21,10 @@ test_instance_method=st.just(False), ) def test_vorbis_window( - *, - dtype_and_x, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, atol_=1e-02, @@ -60,19 +52,10 @@ def test_vorbis_window( test_instance_method=st.just(False), ) def test_hann_window( - *, - dtype_and_x, - periodic, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, periodic, dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, atol_=0.005, @@ -101,20 +84,10 @@ def test_hann_window( test_instance_method=st.just(False), ) def test_kaiser_window( - *, - dtype_and_x, - periodic, - beta, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, periodic, beta, dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -142,19 +115,10 @@ def test_kaiser_window( test_instance_method=st.just(False), ) def test_kaiser_bessel_derived_window( - *, - dtype_and_x, - beta, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, beta, dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -197,12 +161,10 @@ def test_hamming_window( backend_fw, fn_name, on_device, - ground_truth_backend, ): input_dtype1, x = dtype_and_x input_dtype2, f = dtype_and_f helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype1 + input_dtype2, test_flags=test_flags, fw=backend_fw, @@ -230,20 +192,10 @@ def test_hamming_window( test_gradients=st.just(False), test_instance_method=st.just(False), ) -def test_tril_indices( - *, - dtype_and_n, - k, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_tril_indices(*, dtype_and_n, k, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_n helpers.test_function( input_dtypes=input_dtype, - ground_truth_backend=ground_truth_backend, test_flags=test_flags, fw=backend_fw, on_device=on_device, @@ -268,16 +220,7 @@ def test_tril_indices( test_gradients=st.just(False), number_positional_args=st.just(1), ) -def test_eye_like( - *, - dtype_and_x, - k, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_eye_like(*, dtype_and_x, k, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( input_dtypes=dtype, @@ -289,7 +232,6 @@ def test_eye_like( k=k, dtype=dtype[0], device=on_device, - ground_truth_backend=ground_truth_backend, ) @@ -336,21 +278,10 @@ def test_ndindex(dtype_x_shape): test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_indices( - *, - shape, - dtype, - sparse, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_indices(*, shape, dtype, sparse, test_flags, backend_fw, fn_name, on_device): helpers.test_function( input_dtypes=[], test_flags=test_flags, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py index 78b976a4a9e4e..a937fad229196 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py @@ -21,21 +21,12 @@ ), test_gradients=st.just(False), ) -def test_sinc( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sinc(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, atol_=1e-02, - ground_truth_backend=ground_truth_backend, on_device=on_device, fw=backend_fw, fn_name=fn_name, @@ -55,21 +46,13 @@ def test_sinc( ), test_gradients=st.just(False), ) -def test_fmax( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fmax(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, fw=backend_fw, - ground_truth_backend=ground_truth_backend, fn_name=fn_name, x1=x[0], x2=x[1], @@ -110,20 +93,12 @@ def _float_power_helper(draw, *, available_dtypes=None): dtype_and_x=_float_power_helper(), test_gradients=st.just(False), ) -def test_float_power( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_float_power(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtypes, x = dtype_and_x helpers.test_function( input_dtypes=input_dtypes, test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, x1=x[0], @@ -145,20 +120,12 @@ def test_float_power( ), test_gradients=st.just(False), ) -def test_copysign( - dtype_x1_x2, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_copysign(dtype_x1_x2, test_flags, backend_fw, fn_name, on_device): (x1_dtype, x2_dtype), (x1, x2) = dtype_x1_x2 helpers.test_function( input_dtypes=[x1_dtype, x2_dtype], test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, x1=x1, @@ -207,14 +174,7 @@ def _get_dtype_values_axis_for_count_nonzero( test_gradients=st.just(False), ) def test_count_nonzero( - *, - dtype_values_axis, - keepdims, - test_flags, - on_device, - fn_name, - backend_fw, - ground_truth_backend, + *, dtype_values_axis, keepdims, test_flags, on_device, fn_name, backend_fw ): i_o_dtype, a, axis = dtype_values_axis helpers.test_function( @@ -222,7 +182,6 @@ def test_count_nonzero( test_flags=test_flags, on_device=on_device, fw=backend_fw, - ground_truth_backend=ground_truth_backend, fn_name=fn_name, a=a[0], axis=axis, @@ -264,20 +223,12 @@ def _get_castable_dtypes_values(draw, *, allow_nan=False): test_gradients=st.just(False), ) def test_nansum( - *, - dtype_x_axis_dtype, - keep_dims, - test_flags, - on_device, - fn_name, - backend_fw, - ground_truth_backend, + *, dtype_x_axis_dtype, keep_dims, test_flags, on_device, fn_name, backend_fw ): input_dtype, x, axis, dtype = dtype_x_axis_dtype helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, fw=backend_fw, on_device=on_device, fn_name=fn_name, @@ -310,23 +261,13 @@ def test_nansum( test_gradients=st.just(False), ) def test_isclose( - *, - dtype_and_x, - rtol, - atol, - equal_nan, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, rtol, atol, equal_nan, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, a=x[0], @@ -360,20 +301,11 @@ def test_isclose( test_with_out=st.just(False), ) def test_allclose( - dtype_and_x, - rtol, - atol, - equal_nan, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_and_x, rtol, atol, equal_nan, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, - ground_truth_backend=ground_truth_backend, test_flags=test_flags, fw=backend_fw, fn_name=fn_name, @@ -398,17 +330,9 @@ def test_allclose( ), test_gradients=st.just(False), ) -def test_fix( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fix(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -432,18 +356,9 @@ def test_fix( ), test_gradients=st.just(False), ) -def test_nextafter( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_nextafter(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -485,14 +400,12 @@ def test_diff( test_flags, backend_fw, fn_name, - on_device, - ground_truth_backend, + on_device ): input_dtype, x, axis = dtype_n_x_n_axis _, prepend = dtype_prepend _, append = dtype_append helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -525,12 +438,10 @@ def test_zeta( test_flags, fn_name, on_device, - ground_truth_backend, backend_fw, ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -563,18 +474,10 @@ def test_zeta( test_gradients=st.just(False), ) def test_gradient( - *, - dtype_n_x_n_axis, - spacing, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_n_x_n_axis, spacing, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, axis = dtype_n_x_n_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -599,18 +502,9 @@ def test_gradient( ), test_gradients=st.just(False), ) -def test_xlogy( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_xlogy(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -635,14 +529,7 @@ def test_xlogy( ), test_gradients=st.just(False), ) -def test_hypot( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_hypot(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( input_dtypes=input_dtype, @@ -651,7 +538,6 @@ def test_hypot( fn_name=fn_name, on_device=on_device, atol_=1e-2, - ground_truth_backend=ground_truth_backend, x1=x[0], x2=x[1], ) @@ -666,18 +552,10 @@ def test_hypot( container_flags=st.just([False]), ) def test_binarizer( - *, - dtype_and_x, - threshold, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, threshold, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -696,18 +574,9 @@ def test_binarizer( ), test_with_out=st.just(False), ) -def test_conj( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conj(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -750,18 +619,9 @@ def ldexp_args(draw): dtype_and_x=ldexp_args(), test_gradients=st.just(False), ) -def test_ldexp( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_ldexp(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -787,15 +647,7 @@ def test_ldexp( ), test_gradients=st.just(False), ) -def test_lerp( - *, - dtype_and_input, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_lerp(*, dtype_and_input, test_flags, backend_fw, fn_name, on_device): input_dtype, inputs = dtype_and_input start, end, weight = inputs helpers.test_function( @@ -804,7 +656,6 @@ def test_lerp( fw=backend_fw, fn_name=fn_name, atol_=1e-01, - ground_truth_backend=ground_truth_backend, on_device=on_device, input=start, end=end, @@ -826,18 +677,9 @@ def test_lerp( ), test_gradients=st.just(False), ) -def test_frexp( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_frexp(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_general.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_general.py index e341ed965bd31..780696d5947af 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_general.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_general.py @@ -43,19 +43,9 @@ def _reduce_helper(draw): test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_reduce( - *, - args, - keepdims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_reduce(*, args, keepdims, test_flags, backend_fw, fn_name, on_device): dtype, operand, init_value, func, axes = args helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_linalg.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_linalg.py index 161318fdb38af..480e0190d55f8 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_linalg.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_linalg.py @@ -255,15 +255,7 @@ def test_eigh_tridiagonal( args_packet=_generate_diag_args(), test_gradients=st.just(False), ) -def test_diagflat( - *, - test_flags, - backend_fw, - fn_name, - args_packet, - on_device, - ground_truth_backend, -): +def test_diagflat(*, test_flags, backend_fw, fn_name, args_packet, on_device): dtype_x, offset, dtype_padding_value, align, num_rows, num_cols = args_packet x_dtype, x = dtype_x @@ -271,7 +263,6 @@ def test_diagflat( padding_value = padding_value[0][0] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=x_dtype + ["int64"] + padding_value_dtype, test_flags=test_flags, fw=backend_fw, @@ -301,18 +292,9 @@ def test_diagflat( ), test_gradients=st.just(False), ) -def test_kron( - *, - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_kron(*, dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -339,17 +321,9 @@ def test_kron( ), test_gradients=st.just(False), ) -def test_matrix_exp( - dtype_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_matrix_exp(dtype_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, @@ -381,16 +355,9 @@ def test_matrix_exp( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_eig( - dtype_x, - test_flags, - backend_fw, - fn_name, - ground_truth_backend, -): +def test_eig(dtype_x, test_flags, backend_fw, fn_name): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -422,16 +389,9 @@ def test_eig( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_eigvals( - dtype_x, - test_flags, - backend_fw, - fn_name, - ground_truth_backend, -): +def test_eigvals(dtype_x, test_flags, backend_fw, fn_name): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -461,16 +421,9 @@ def test_eigvals( shared_dtype=True, ), ) -def test_adjoint( - dtype_x, - test_flags, - backend_fw, - fn_name, - ground_truth_backend, -): +def test_adjoint(dtype_x, test_flags, backend_fw, fn_name): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -523,16 +476,9 @@ def _generate_multi_dot_dtype_and_arrays(draw): dtype_x=_generate_multi_dot_dtype_and_arrays(), test_gradients=st.just(False), ) -def test_multi_dot( - dtype_x, - test_flags, - backend_fw, - fn_name, - ground_truth_backend, -): +def test_multi_dot(dtype_x, test_flags, backend_fw, fn_name): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -550,17 +496,9 @@ def test_multi_dot( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_cond( - dtype_x, - test_flags, - backend_fw, - on_device, - fn_name, - ground_truth_backend, -): +def test_cond(dtype_x, test_flags, backend_fw, on_device, fn_name): dtype, x = dtype_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -571,3 +509,131 @@ def test_cond( x=x[0], p=x[1], ) + + +@st.composite +def _get_dtype_value1_value2_cov( + draw, + available_dtypes, + min_num_dims, + max_num_dims, + min_dim_size, + max_dim_size, + abs_smallest_val=None, + min_value=None, + max_value=None, + allow_inf=False, + exclude_min=False, + exclude_max=False, + large_abs_safety_factor=4, + small_abs_safety_factor=4, + safety_factor_scale="log", +): + shape = draw( + helpers.get_shape( + allow_none=False, + min_num_dims=min_num_dims, + max_num_dims=max_num_dims, + min_dim_size=min_dim_size, + max_dim_size=max_dim_size, + ) + ) + + dtype = draw(st.sampled_from(draw(available_dtypes))) + + values = [] + for i in range(2): + values.append( + draw( + helpers.array_values( + dtype=dtype, + shape=shape, + abs_smallest_val=abs_smallest_val, + min_value=min_value, + max_value=max_value, + allow_inf=allow_inf, + exclude_min=exclude_min, + exclude_max=exclude_max, + large_abs_safety_factor=large_abs_safety_factor, + small_abs_safety_factor=small_abs_safety_factor, + safety_factor_scale=safety_factor_scale, + ) + ) + ) + + value1, value2 = values[0], values[1] + + # modifiers: rowVar, bias, ddof + rowVar = draw(st.booleans()) + bias = draw(st.booleans()) + ddof = draw(helpers.ints(min_value=0, max_value=1)) + + numVals = None + if rowVar is False: + numVals = -1 if numVals == 0 else 0 + else: + numVals = 0 if len(shape) == 1 else -1 + + fweights = draw( + helpers.array_values( + dtype="int64", + shape=shape[numVals], + abs_smallest_val=1, + min_value=1, + max_value=10, + allow_inf=False, + ) + ) + + aweights = draw( + helpers.array_values( + dtype="float64", + shape=shape[numVals], + abs_smallest_val=1, + min_value=1, + max_value=10, + allow_inf=False, + small_abs_safety_factor=1, + ) + ) + + return [dtype], value1, value2, rowVar, bias, ddof, fweights, aweights + + +# cov +@handle_test( + fn_tree="functional.ivy.experimental.cov", + dtype_x1_x2_cov=_get_dtype_value1_value2_cov( + available_dtypes=helpers.get_dtypes("float"), + min_num_dims=1, + max_num_dims=2, + min_dim_size=2, + max_dim_size=5, + min_value=1, + max_value=1e10, + abs_smallest_val=0.01, + large_abs_safety_factor=2, + safety_factor_scale="log", + ), + test_gradients=st.just(False), + test_with_out=st.just(False), +) +def test_cov(*, dtype_x1_x2_cov, test_flags, backend_fw, fn_name, on_device): + dtype, x1, x2, rowVar, bias, ddof, fweights, aweights = dtype_x1_x2_cov + helpers.test_function( + input_dtypes=[dtype[0], dtype[0], "int64", "float64"], + test_flags=test_flags, + fw=backend_fw, + fn_name=fn_name, + on_device=on_device, + x1=x1, + x2=x2, + rowVar=rowVar, + bias=bias, + ddof=ddof, + fweights=fweights, + aweights=aweights, + return_flat_np_arrays=True, + rtol_=1e-2, + atol_=1e-2, + ) diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py index 36cd199c5ce5d..bb91f34f070fc 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_manipulation.py @@ -65,19 +65,10 @@ test_gradients=st.just(False), ) def test_moveaxis( - *, - dtype_and_a, - source, - destination, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_a, source, destination, test_flags, backend_fw, fn_name, on_device ): input_dtype, a = dtype_and_a helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -105,18 +96,9 @@ def test_moveaxis( ), test_gradients=st.just(False), ) -def test_heaviside( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_heaviside(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -141,18 +123,9 @@ def test_heaviside( ), test_gradients=st.just(False), ) -def test_flipud( - *, - dtype_and_m, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_flipud(*, dtype_and_m, test_flags, backend_fw, fn_name, on_device): input_dtype, m = dtype_and_m helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -175,18 +148,9 @@ def test_flipud( ), test_gradients=st.just(False), ) -def test_vstack( - *, - dtype_and_m, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_vstack(*, dtype_and_m, test_flags, backend_fw, fn_name, on_device): input_dtype, m = dtype_and_m helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -209,17 +173,9 @@ def test_vstack( ), test_gradients=st.just(False), ) -def test_hstack( - dtype_and_m, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_hstack(dtype_and_m, test_flags, backend_fw, fn_name, on_device): input_dtype, m = dtype_and_m helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -291,17 +247,9 @@ def _get_dtype_values_k_axes_for_rot90( ), test_gradients=st.just(False), ) -def test_rot90( - dtype_m_k_axes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_rot90(dtype_m_k_axes, test_flags, backend_fw, fn_name, on_device): input_dtype, m, k, axes = dtype_m_k_axes helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -328,20 +276,10 @@ def test_rot90( test_gradients=st.just(False), ) def test_top_k( - *, - dtype_x_axis, - k, - largest, - sorted, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, k, largest, sorted, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -364,18 +302,9 @@ def test_top_k( ), test_gradients=st.just(False), ) -def test_fliplr( - *, - dtype_and_m, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fliplr(*, dtype_and_m, test_flags, backend_fw, fn_name, on_device): input_dtype, m = dtype_and_m helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -399,18 +328,9 @@ def test_fliplr( ), test_gradients=st.just(False), ) -def test_i0( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_i0(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -439,19 +359,10 @@ def test_i0( number_positional_args=st.just(1), ) def test_flatten( - *, - dtype_and_x, - axes, - order, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, axes, order, test_flags, backend_fw, fn_name, on_device ): input_dtypes, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -564,7 +475,6 @@ def test_pad( backend_fw, fn_name, on_device, - ground_truth_backend, ): ( dtype, @@ -576,7 +486,6 @@ def test_pad( mode, ) = dtype_and_input_and_other helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -604,17 +513,10 @@ def test_pad( test_with_out=st.just(False), ) def test_vsplit( - dtype_and_x, - indices_or_sections, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_and_x, indices_or_sections, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, on_device=on_device, test_flags=test_flags, @@ -637,17 +539,10 @@ def test_vsplit( test_with_out=st.just(False), ) def test_dsplit( - dtype_and_x, - indices_or_sections, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_and_x, indices_or_sections, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -668,21 +563,13 @@ def test_dsplit( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_atleast_1d( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atleast_1d(dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtypes, arrays = dtype_and_x kw = {} for i, (array, idtype) in enumerate(zip(arrays, input_dtypes)): kw["x{}".format(i)] = np.asarray(array, dtype=idtype) test_flags.num_positional_args = len(kw) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -705,18 +592,9 @@ def test_atleast_1d( ), test_gradients=st.just(False), ) -def test_dstack( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_dstack(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -736,22 +614,13 @@ def test_dstack( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_atleast_2d( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atleast_2d(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtypes, arrays = dtype_and_x kw = {} for i, (array, idtype) in enumerate(zip(arrays, input_dtypes)): kw["x{}".format(i)] = np.asarray(array, dtype=idtype) test_flags.num_positional_args = len(kw) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -771,22 +640,13 @@ def test_atleast_2d( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_atleast_3d( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_atleast_3d(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtypes, arrays = dtype_and_x arrys = {} for i, (array, idtype) in enumerate(zip(arrays, input_dtypes)): arrys["x{}".format(i)] = np.asarray(array, dtype=idtype) test_flags.num_positional_args = len(arrys) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtypes, test_flags=test_flags, fw=backend_fw, @@ -850,13 +710,7 @@ def test_take_along_axis( test_with_out=st.just(False), ) def test_hsplit( - dtype_and_x, - indices_or_sections, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_and_x, indices_or_sections, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x if ( @@ -866,7 +720,6 @@ def test_hsplit( ): input_dtype = [*input_dtype, indices_or_sections.dtype] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -887,20 +740,11 @@ def test_hsplit( test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_broadcast_shapes( - *, - shapes, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_broadcast_shapes(*, shapes, test_flags, backend_fw, fn_name, on_device): shape, _ = shapes shapes = {f"shape{i}": shape[i] for i in range(len(shape))} test_flags.num_positional_args = len(shapes) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=["int64"], test_flags=test_flags, fw=backend_fw, @@ -939,19 +783,9 @@ def test_broadcast_shapes( test_instance_method=st.just(False), test_gradients=st.just(False), ) -def test_expand( - *, - dtype_and_x, - shape, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_expand(*, dtype_and_x, shape, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -987,18 +821,9 @@ def _as_strided_helper(draw): test_gradients=st.just(False), ground_truth_backend="numpy", ) -def test_as_strided( - *, - all_args, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_as_strided(*, all_args, test_flags, backend_fw, fn_name, on_device): dtype, x, shape, strides = all_args helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1040,19 +865,11 @@ def _concat_from_sequence_helper(draw): test_instance_method=st.just(False), ) def test_concat_from_sequence( - *, - dtypes_arrays_axis, - new_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtypes_arrays_axis, new_axis, test_flags, backend_fw, fn_name, on_device ): dtypes, arrays, axis = dtypes_arrays_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, fw=backend_fw, @@ -1107,15 +924,7 @@ def _associative_scan_helper(draw): ground_truth_backend="jax", ) def test_associative_scan( - *, - dtype_elems_axis, - fn, - reverse, - fn_name, - test_flags, - backend_fw, - on_device, - ground_truth_backend, + *, dtype_elems_axis, fn, reverse, fn_name, test_flags, backend_fw, on_device ): dtype, elems, axis = dtype_elems_axis helpers.test_function( @@ -1123,7 +932,6 @@ def test_associative_scan( test_flags=test_flags, fw=backend_fw, on_device=on_device, - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, elems=elems, fn=fn, @@ -1148,20 +956,12 @@ def test_associative_scan( ground_truth_backend="torch", ) def test_unique_consecutive( - *, - dtype_x_axis, - none_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, none_axis, test_flags, backend_fw, fn_name, on_device ): dtype, x, axis = dtype_x_axis if none_axis: axis = None helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_norms.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_norms.py index d08a0bfeb604a..7150c643b3de1 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_norms.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_norms.py @@ -16,18 +16,9 @@ ), test_gradients=st.just(False), ) -def test_l2_normalize( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_l2_normalize(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -51,19 +42,9 @@ def test_l2_normalize( p=st.floats(min_value=0.1, max_value=2), test_gradients=st.just(False), ) -def test_lp_normalize( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, - p, -): +def test_lp_normalize(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device, p): input_dtype, x, axis = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_random.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_random.py index 2cb01ef146bb2..47aa462a6025a 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_random.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_random.py @@ -30,22 +30,13 @@ test_gradients=st.just(False), ) def test_dirichlet( - *, - dtype_and_alpha, - size, - seed, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_alpha, size, seed, test_flags, backend_fw, fn_name, on_device ): dtype, alpha = dtype_and_alpha assume("bfloat16" not in dtype) def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -91,14 +82,12 @@ def test_beta( backend_fw, fn_name, on_device, - ground_truth_backend, test_flags, ): dtype, alpha_beta = dtype_and_alpha_beta if "float16" in dtype: return ret, ret_gt = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -133,20 +122,12 @@ def test_beta( test_gradients=st.just(False), ) def test_gamma( - *, - dtype_and_alpha_beta, - seed, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_alpha_beta, seed, test_flags, backend_fw, fn_name, on_device ): dtype, alpha_beta = dtype_and_alpha_beta if "float16" in dtype: return ret, ret_gt = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -192,13 +173,11 @@ def test_poisson( backend_fw, fn_name, on_device, - ground_truth_backend, ): lam_dtype, lam = dtype_and_lam def call(): return helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=lam_dtype, test_flags=test_flags, on_device=on_device, @@ -235,14 +214,7 @@ def call(): test_gradients=st.just(False), ) def test_bernoulli( - *, - dtype_and_probs, - seed, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_probs, seed, test_flags, backend_fw, fn_name, on_device ): dtype, probs = dtype_and_probs # torch doesn't support half precision on CPU @@ -250,7 +222,6 @@ def test_bernoulli( not ("torch" in str(backend_fw) and "float16" in dtype and on_device == "cpu") ) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_searching.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_searching.py index 696a0ca747301..2f02feec5d7a5 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_searching.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_searching.py @@ -34,19 +34,10 @@ def max_value_as_shape_prod(draw): dtype_x_shape=max_value_as_shape_prod(), test_gradients=st.just(False), ) -def test_unravel_index( - *, - dtype_x_shape, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_unravel_index(*, dtype_x_shape, test_flags, backend_fw, fn_name, on_device): dtype_and_x, shape = dtype_x_shape input_dtype, x = dtype_and_x[0], dtype_and_x[1] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sorting.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sorting.py index a6129f2992adc..cabc2b08a32d7 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sorting.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sorting.py @@ -28,17 +28,9 @@ def _invert_permutation_helper(draw): test_with_out=st.just(False), test_gradients=st.just(False), ) -def test_invert_permutation( - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_invert_permutation(dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sparse_array.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sparse_array.py index 2f58d40e64179..f76b43f65335a 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sparse_array.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_sparse_array.py @@ -184,10 +184,10 @@ def test_sparse_coo( sparse_data, class_name, method_name, - ground_truth_backend, init_flags, method_flags, on_device, + ground_truth_backend, ): coo_ind, val_dtype, val, shp = sparse_data helpers.test_method( diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_statistical.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_statistical.py index 78e1140a1e678..b20f71793e377 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_statistical.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_statistical.py @@ -147,7 +147,6 @@ def test_histogram( test_flags, backend_fw, fn_name, - ground_truth_backend, on_device, ): ( @@ -176,7 +175,6 @@ def test_histogram( test_flags=test_flags, fw=backend_fw, fn_name=fn_name, - ground_truth_backend=ground_truth_backend, on_device=on_device, ) @@ -188,19 +186,9 @@ def test_histogram( test_gradients=st.just(False), test_with_out=st.just(False), ) -def test_median( - *, - dtype_x_axis, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_median(*, dtype_x_axis, keep_dims, test_flags, backend_fw, fn_name, on_device): input_dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, @@ -221,19 +209,10 @@ def test_median( test_gradients=st.just(False), ) def test_nanmean( - *, - dtype_x_axis, - keep_dims, - dtype, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_x_axis, keep_dims, dtype, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, axis = dtype_x_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, atol_=1e-02, @@ -296,20 +275,12 @@ def _quantile_helper(draw): test_with_out=st.just(False), ) def test_quantile( - *, - dtype_and_x, - keep_dims, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, keep_dims, test_flags, backend_fw, fn_name, on_device ): input_dtype, x, axis, interpolation, q = dtype_and_x helpers.test_function( input_dtypes=input_dtype, test_flags=test_flags, - ground_truth_backend=ground_truth_backend, fw=backend_fw, fn_name=fn_name, on_device=on_device, @@ -340,19 +311,9 @@ def test_quantile( rowvar=st.booleans(), test_gradients=st.just(False), ) -def test_corrcoef( - *, - dtype_and_x, - rowvar, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_corrcoef(*, dtype_and_x, rowvar, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -394,19 +355,10 @@ def bincount_dtype_and_values(draw): dtype_and_x=bincount_dtype_and_values(), test_gradients=st.just(False), ) -def test_bincount( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_bincount(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype_and_x, min_length = dtype_and_x input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -437,18 +389,9 @@ def test_bincount( test_gradients=st.just(False), test_with_out=st.just(False), ) -def test_igamma( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_igamma(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, on_device=on_device, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py index 2d3ec248033ee..d7398b321678e 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py @@ -16,18 +16,9 @@ safety_factor_scale="log", ), ) -def test_logit( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logit(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -51,18 +42,10 @@ def test_logit( ), ) def test_thresholded_relu( - *, - dtype_and_x, - threshold, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, threshold, test_flags, backend_fw, fn_name, on_device ): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -88,19 +71,9 @@ def test_thresholded_relu( shape=st.shared(helpers.get_shape(), key="prelu"), ), ) -def test_prelu( - *, - dtype_and_x, - slope, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_prelu(*, dtype_and_x, slope, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -121,18 +94,9 @@ def test_prelu( safety_factor_scale="log", ), ) -def test_relu6( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_relu6(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -152,19 +116,10 @@ def test_relu6( ), test_with_out=st.just(False), ) -def test_logsigmoid( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_logsigmoid(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): input_dtype, x = dtype_and_x test_flags.num_positional_args = len(x) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -184,19 +139,10 @@ def test_logsigmoid( ), test_with_out=st.just(False), ) -def test_selu( - *, - dtype_and_input, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_selu(*, dtype_and_input, test_flags, backend_fw, fn_name, on_device): input_dtype, input = dtype_and_input test_flags.num_positional_args = len(input) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, fw=backend_fw, test_flags=test_flags, @@ -217,18 +163,9 @@ def test_selu( safety_factor_scale="log", ), ) -def test_silu( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_silu(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_layers.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_layers.py index 854fc8e6ba8eb..afc45f7efce83 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_layers.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_layers.py @@ -61,7 +61,6 @@ def test_max_pool2d( test_flags, backend_fw, fn_name, - ground_truth_backend, on_device, ): dtype, x, kernel, stride, pad, dilation = x_k_s_p @@ -78,7 +77,6 @@ def test_max_pool2d( ) ) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -281,18 +279,9 @@ def valid_dct(draw): dtype_x_and_args=valid_dct(), test_gradients=st.just(False), ) -def test_dct( - *, - dtype_x_and_args, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_dct(*, dtype_x_and_args, test_flags, backend_fw, fn_name, on_device): input_dtype, x, type, n, axis, norm = dtype_x_and_args helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -313,17 +302,9 @@ def test_dct( dtype_x_and_args=valid_dct(), test_gradients=st.just(False), ) -def test_idct( - dtype_x_and_args, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_idct(dtype_x_and_args, test_flags, backend_fw, fn_name, on_device): input_dtype, x, type, n, axis, norm = dtype_x_and_args helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -434,13 +415,7 @@ def _interp_args(draw, mode=None, mode_list=None): number_positional_args=st.just(2), ) def test_interpolate( - dtype_x_mode, - antialias, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + dtype_x_mode, antialias, test_flags, backend_fw, fn_name, on_device ): ( input_dtype, @@ -452,7 +427,6 @@ def test_interpolate( recompute_scale_factor, ) = dtype_x_mode helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -503,18 +477,9 @@ def x_and_fft(draw): ground_truth_backend="jax", test_gradients=st.just(False), ) -def test_fft( - *, - d_x_d_n_n, - test_flags, - backend_fw, - on_device, - fn_name, - ground_truth_backend, -): +def test_fft(*, d_x_d_n_n, test_flags, backend_fw, on_device, fn_name): dtype, x, dim, norm, n = d_x_d_n_n helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -558,11 +523,9 @@ def test_dropout1d( backend_fw, on_device, fn_name, - ground_truth_backend, ): dtype, x = dtype_and_x ret, gt_ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -610,11 +573,9 @@ def test_dropout2d( backend_fw, on_device, fn_name, - ground_truth_backend, ): dtype, x = dtype_and_x ret, gt_ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -663,11 +624,9 @@ def test_dropout3d( backend_fw, on_device, fn_name, - ground_truth_backend, ): dtype, x = dtype_and_x ret, gt_ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, test_values=False, @@ -715,18 +674,10 @@ def x_and_ifft(draw): d_x_d_n_n=x_and_ifft(), test_gradients=st.just(False), ) -def test_ifft( - *, - d_x_d_n_n, - test_flags, - backend_fw, - fn_name, - ground_truth_backend, -): +def test_ifft(*, d_x_d_n_n, test_flags, backend_fw, fn_name): dtype, x, dim, norm, n = d_x_d_n_n helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -748,20 +699,12 @@ def test_ifft( number_positional_args=st.just(2), ) def test_embedding( - *, - dtypes_indices_weights, - max_norm, - test_flags, - backend_fw, - on_device, - fn_name, - ground_truth_backend, + *, dtypes_indices_weights, max_norm, test_flags, backend_fw, on_device, fn_name ): dtypes, indices, weights, _ = dtypes_indices_weights dtypes = [dtypes[1], dtypes[0]] helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, xs_grad_idxs=[[0, 0]], @@ -791,7 +734,6 @@ def test_dft( backend_fw, fn_name, on_device, - ground_truth_backend, ): if inverse: dtype, x, axis, norm, dft_length = d_xifft_axis_n_length @@ -799,7 +741,6 @@ def test_dft( dtype, x, axis, norm, dft_length = d_xfft_axis_n_length helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -829,18 +770,10 @@ def test_dft( ground_truth_backend="torch", ) def test_adaptive_avg_pool1d( - *, - dtype_and_x, - output_size, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, output_size, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -872,18 +805,10 @@ def test_adaptive_avg_pool1d( ground_truth_backend="torch", ) def test_adaptive_avg_pool2d( - *, - dtype_and_x, - output_size, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, output_size, test_flags, backend_fw, fn_name, on_device ): input_dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=input_dtype, test_flags=test_flags, fw=backend_fw, @@ -958,18 +883,9 @@ def _get_reduce_func(dtype): test_with_out=st.just(False), ground_truth_backend="jax", ) -def test_reduce_window( - *, - all_args, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_reduce_window(*, all_args, test_flags, backend_fw, fn_name, on_device): dtypes, operand, init_value, computation, others, padding = all_args helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtypes, test_flags=test_flags, fw=backend_fw, @@ -1023,18 +939,9 @@ def x_and_fft2(draw): container_flags=st.just([False]), test_gradients=st.just(False), ) -def test_fft2( - *, - d_x_d_s_n, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_fft2(*, d_x_d_s_n, test_flags, backend_fw, fn_name, on_device): dtype, x, s, dim, norm = d_x_d_s_n helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_norms.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_norms.py index 1d98aded642a3..20b1849ac04a5 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_norms.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_norms.py @@ -12,18 +12,9 @@ available_dtypes=helpers.get_dtypes("valid"), valid_axis=True ), ) -def test_l1_normalize( - *, - dtype_values_axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_l1_normalize(*, dtype_values_axis, test_flags, backend_fw, fn_name, on_device): x_dtype, x, axis = dtype_values_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, fw=backend_fw, test_flags=test_flags, fn_name=fn_name, @@ -129,19 +120,9 @@ def _instance_and_batch_norm_helper(draw, *, min_dims=1, test_function="instance data=_instance_and_batch_norm_helper(min_dims=3), training=st.booleans(), ) -def test_instance_norm( - *, - data, - training, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_instance_norm(*, data, training, test_flags, backend_fw, fn_name, on_device): x_dtype, x, mean, variance, offset, scale, eps, momentum, data_format = data helpers.test_function( - ground_truth_backend=ground_truth_backend, fw=backend_fw, test_flags=test_flags, fn_name=fn_name, @@ -168,19 +149,9 @@ def test_instance_norm( data=_instance_and_batch_norm_helper(min_dims=2, test_function="batch_norm"), training=st.booleans(), ) -def test_batch_norm( - *, - data, - training, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_batch_norm(*, data, training, test_flags, backend_fw, fn_name, on_device): x_dtype, x, mean, variance, offset, scale, eps, momentum, data_format = data helpers.test_function( - ground_truth_backend=ground_truth_backend, fw=backend_fw, test_flags=test_flags, fn_name=fn_name, diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py index 76aca4278b061..76746c024f264 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py @@ -18,18 +18,9 @@ safety_factor_scale="log", ), ) -def test_relu( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_relu(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -50,19 +41,9 @@ def test_relu( ), alpha=st.floats(min_value=-1e-4, max_value=1e-4), ) -def test_leaky_relu( - *, - dtype_and_x, - alpha, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_leaky_relu(*, dtype_and_x, alpha, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -86,19 +67,9 @@ def test_leaky_relu( ), approximate=st.booleans(), ) -def test_gelu( - *, - dtype_and_x, - approximate, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_gelu(*, dtype_and_x, approximate, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -121,18 +92,9 @@ def test_gelu( safety_factor_scale="log", ), ) -def test_sigmoid( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_sigmoid(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -159,19 +121,9 @@ def test_sigmoid( st.none(), ), ) -def test_softmax( - *, - dtype_and_x, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_softmax(*, dtype_and_x, axis, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -198,21 +150,12 @@ def test_softmax( threshold=st.one_of(helpers.number(min_value=0.1, max_value=30), st.none()), ) def test_softplus( - *, - dtype_and_x, - beta, - threshold, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_and_x, beta, threshold, test_flags, backend_fw, fn_name, on_device ): assume(beta != 0) assume(threshold != 0) dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -238,19 +181,9 @@ def test_softplus( ), axis=st.one_of(helpers.ints(min_value=-1, max_value=0), st.none()), ) -def test_log_softmax( - *, - dtype_and_x, - axis, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_log_softmax(*, dtype_and_x, axis, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, @@ -273,18 +206,9 @@ def test_log_softmax( safety_factor_scale="log", ), ) -def test_mish( - *, - dtype_and_x, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_mish(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): dtype, x = dtype_and_x helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, fw=backend_fw, test_flags=test_flags, diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_layers.py b/ivy_tests/test_ivy/test_functional/test_nn/test_layers.py index b5812b884664d..e86060419bab4 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_layers.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_layers.py @@ -52,18 +52,9 @@ def x_and_linear(draw, dtypes): dtypes=helpers.get_dtypes("numeric", full=False), ), ) -def test_linear( - *, - dtype_x_weight_bias, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_linear(*, dtype_x_weight_bias, test_flags, backend_fw, fn_name, on_device): dtype, x, weight, bias = dtype_x_weight_bias helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -126,11 +117,9 @@ def test_dropout( backend_fw, fn_name, on_device, - ground_truth_backend, ): (x_dtype, x), noise_shape = dtype_x_noiseshape ret, gt_ret = helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=x_dtype, test_flags=test_flags, fw=backend_fw, @@ -200,17 +189,10 @@ def x_and_scaled_attention(draw, dtypes): ground_truth_backend="jax", ) def test_scaled_dot_product_attention( - *, - dtype_q_k_v_mask_scale, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dtype_q_k_v_mask_scale, test_flags, backend_fw, fn_name, on_device ): dtype, q, k, v, mask, scale = dtype_q_k_v_mask_scale helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -421,7 +403,6 @@ def test_multi_head_attention( backend_fw, fn_name, on_device, - ground_truth_backend, ): ( dtype, @@ -439,7 +420,6 @@ def test_multi_head_attention( out_proj_bias, ) = dtype_mha helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -653,20 +633,11 @@ def _assume_tf_dilation_gt_1(backend_fw, on_device, dilations): x_f_d_df=x_and_filters(dim=1), ground_truth_backend="jax", ) -def test_conv1d( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv1d(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, fc = x_f_d_df # ToDo: Enable gradient tests for dilations > 1 when tensorflow supports it. _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -689,19 +660,10 @@ def test_conv1d( x_f_d_df=x_and_filters(dim=1, transpose=True), ground_truth_backend="jax", ) -def test_conv1d_transpose( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv1d_transpose(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, output_shape, fc = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -726,20 +688,11 @@ def test_conv1d_transpose( x_f_d_df=x_and_filters(dim=2), ground_truth_backend="jax", ) -def test_conv2d( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv2d(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, fc = x_f_d_df # ToDo: Enable gradient tests for dilations > 1 when tensorflow supports it. _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -766,19 +719,10 @@ def test_conv2d( # tensorflow does not work with dilations > 1 on cpu ground_truth_backend="jax", ) -def test_conv2d_transpose( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv2d_transpose(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, output_shape, fc = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -806,15 +750,7 @@ def test_conv2d_transpose( # tensorflow does not support dilations > 1 and stride > 1 ground_truth_backend="jax", ) -def test_depthwise_conv2d( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_depthwise_conv2d(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, fc = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) # tensorflow only supports equal length strides in row and column @@ -825,7 +761,6 @@ def test_depthwise_conv2d( ): assume(stride[0] == stride[1]) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -848,19 +783,10 @@ def test_depthwise_conv2d( x_f_d_df=x_and_filters(dim=3), ground_truth_backend="jax", ) -def test_conv3d( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv3d(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, fc = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -886,19 +812,10 @@ def test_conv3d( ), ground_truth_backend="jax", ) -def test_conv3d_transpose( - *, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_conv3d_transpose(*, x_f_d_df, test_flags, backend_fw, fn_name, on_device): dtype, x, filters, dilations, data_format, stride, pad, output_shape, fc = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -929,14 +846,7 @@ def test_conv3d_transpose( ground_truth_backend="jax", ) def test_conv_general_dilated( - *, - dims, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dims, x_f_d_df, test_flags, backend_fw, fn_name, on_device ): ( dtype, @@ -952,7 +862,6 @@ def test_conv_general_dilated( ) = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations[0]) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -986,14 +895,7 @@ def test_conv_general_dilated( ground_truth_backend="jax", ) def test_conv_general_transpose( - *, - dims, - x_f_d_df, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, dims, x_f_d_df, test_flags, backend_fw, fn_name, on_device ): ( dtype, @@ -1009,7 +911,6 @@ def test_conv_general_transpose( ) = x_f_d_df _assume_tf_dilation_gt_1(backend_fw, on_device, dilations) helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, @@ -1104,15 +1005,7 @@ def x_and_lstm(draw, dtypes): ), test_with_out=st.just(False), ) -def test_lstm_update( - *, - dtype_lstm, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, -): +def test_lstm_update(*, dtype_lstm, test_flags, backend_fw, fn_name, on_device): ( dtype, x_lstm, @@ -1124,7 +1017,6 @@ def test_lstm_update( recurrent_bias, ) = dtype_lstm helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_losses.py b/ivy_tests/test_ivy/test_functional/test_nn/test_losses.py index 8f3fc03eb01e0..4ecaad605b510 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_losses.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_losses.py @@ -36,13 +36,11 @@ def test_cross_entropy( backend_fw, fn_name, on_device, - ground_truth_backend, ): pred_dtype, pred = dtype_and_pred true_dtype, true, axis = dtype_true_axis helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=true_dtype + pred_dtype, test_flags=test_flags, fw=backend_fw, @@ -112,7 +110,6 @@ def test_binary_cross_entropy( backend_fw, fn_name, on_device, - ground_truth_backend, ): dtype_true, true = dtype_and_true dtype_pred, pred = dtype_and_pred @@ -120,7 +117,6 @@ def test_binary_cross_entropy( if from_logits: helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype_true + dtype_pred + dtype_pos_weight, test_flags=test_flags, fw=backend_fw, @@ -138,7 +134,6 @@ def test_binary_cross_entropy( ) else: helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype_true + dtype_pred, test_flags=test_flags, fw=backend_fw, @@ -193,12 +188,10 @@ def test_sparse_cross_entropy( backend_fw, fn_name, on_device, - ground_truth_backend, ): true_dtype, true = dtype_and_true pred_dtype, pred = dtype_and_pred helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=true_dtype + pred_dtype, test_flags=test_flags, fw=backend_fw, diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_norms.py b/ivy_tests/test_ivy/test_functional/test_nn/test_norms.py index 9377c7e7a7d93..f92c9b4141825 100644 --- a/ivy_tests/test_ivy/test_functional/test_nn/test_norms.py +++ b/ivy_tests/test_ivy/test_functional/test_nn/test_norms.py @@ -93,19 +93,10 @@ def _generate_data_layer_norm( eps=st.floats(min_value=0.01, max_value=0.1), ) def test_layer_norm( - *, - values_tuple, - new_std, - eps, - test_flags, - backend_fw, - fn_name, - on_device, - ground_truth_backend, + *, values_tuple, new_std, eps, test_flags, backend_fw, fn_name, on_device ): dtype, x, normalized_idxs, scale, offset = values_tuple helpers.test_function( - ground_truth_backend=ground_truth_backend, input_dtypes=dtype, test_flags=test_flags, fw=backend_fw, From 999d15865caa86037c447ae60d0a081c5fb83ecf Mon Sep 17 00:00:00 2001 From: ivy-branch Date: Mon, 10 Jul 2023 08:06:35 +0000 Subject: [PATCH 08/24] =?UTF-8?q?=F0=9F=A4=96=20Lint=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../array/experimental/elementwise.py | 1 - .../container/experimental/elementwise.py | 24 +++++++++---------- .../backends/jax/experimental/elementwise.py | 5 +++- .../mxnet/experimental/elementwise.py | 8 +++---- .../numpy/experimental/elementwise.py | 5 +++- .../paddle/experimental/elementwise.py | 3 +-- .../tensorflow/experimental/elementwise.py | 5 +++- .../torch/experimental/elementwise.py | 5 +++- .../test_core/test_elementwise.py | 11 ++++----- 9 files changed, 38 insertions(+), 29 deletions(-) diff --git a/ivy/data_classes/array/experimental/elementwise.py b/ivy/data_classes/array/experimental/elementwise.py index ee9af0a167b8f..ae3b6dec23fa2 100644 --- a/ivy/data_classes/array/experimental/elementwise.py +++ b/ivy/data_classes/array/experimental/elementwise.py @@ -948,4 +948,3 @@ def modf( (ivy.array([0.5, 0.7, 0.9]), ivy.array([1, 2, 3])) """ return ivy.modf(self._data, out=out) - \ No newline at end of file diff --git a/ivy/data_classes/container/experimental/elementwise.py b/ivy/data_classes/container/experimental/elementwise.py index 1c0abb7f71007..cfc93e6cfb946 100644 --- a/ivy/data_classes/container/experimental/elementwise.py +++ b/ivy/data_classes/container/experimental/elementwise.py @@ -2748,14 +2748,14 @@ def frexp( @staticmethod def static_modf( - x: Union[ivy.Array, ivy.NativeArray, ivy.Container], - /, - *, - key_chains: Optional[Union[List[str], Dict[str, str]]] = None, - to_apply: bool = True, - prune_unapplied: bool = False, - map_sequences: bool = False, - out: Optional[ivy.Container] = None, + x: Union[ivy.Array, ivy.NativeArray, ivy.Container], + /, + *, + key_chains: Optional[Union[List[str], Dict[str, str]]] = None, + to_apply: bool = True, + prune_unapplied: bool = False, + map_sequences: bool = False, + out: Optional[ivy.Container] = None, ) -> ivy.Container: """ ivy.Container static method variant of ivy.modf. This method simply wraps the @@ -2806,10 +2806,10 @@ def static_modf( ) def modf( - self: ivy.Container, - /, - *, - out: Optional[ivy.Container] = None, + self: ivy.Container, + /, + *, + out: Optional[ivy.Container] = None, ) -> ivy.Container: """ ivy.Container instance method variant of ivy.modf. This method simply wraps the diff --git a/ivy/functional/backends/jax/experimental/elementwise.py b/ivy/functional/backends/jax/experimental/elementwise.py index f53427def2609..2d3503ee02215 100644 --- a/ivy/functional/backends/jax/experimental/elementwise.py +++ b/ivy/functional/backends/jax/experimental/elementwise.py @@ -437,6 +437,9 @@ def frexp( def modf( - x: JaxArray,/,*,out: Optional[JaxArray] = None, + x: JaxArray, + /, + *, + out: Optional[JaxArray] = None, ) -> JaxArray: return jnp.modf(x) diff --git a/ivy/functional/backends/mxnet/experimental/elementwise.py b/ivy/functional/backends/mxnet/experimental/elementwise.py index 9abb037611711..f00d6aec6f29d 100644 --- a/ivy/functional/backends/mxnet/experimental/elementwise.py +++ b/ivy/functional/backends/mxnet/experimental/elementwise.py @@ -219,9 +219,9 @@ def frexp( def modf( - x: Union[(None, mx.ndarray.NDArray)], - /, - *, - out: Optional[Union[(None, mx.ndarray.NDArray)]] = None, + x: Union[(None, mx.ndarray.NDArray)], + /, + *, + out: Optional[Union[(None, mx.ndarray.NDArray)]] = None, ) -> Union[(None, mx.ndarray.NDArray)]: raise IvyNotImplementedException() diff --git a/ivy/functional/backends/numpy/experimental/elementwise.py b/ivy/functional/backends/numpy/experimental/elementwise.py index e731b12f32642..3d31adb278746 100644 --- a/ivy/functional/backends/numpy/experimental/elementwise.py +++ b/ivy/functional/backends/numpy/experimental/elementwise.py @@ -290,6 +290,9 @@ def frexp( def modf( - x: np.ndarray,/,*,out: Optional[np.ndarray] = None, + x: np.ndarray, + /, + *, + out: Optional[np.ndarray] = None, ) -> np.ndarray: return np.modf(x, out=out) diff --git a/ivy/functional/backends/paddle/experimental/elementwise.py b/ivy/functional/backends/paddle/experimental/elementwise.py index cfb94cdd93ed9..528b9cf406257 100644 --- a/ivy/functional/backends/paddle/experimental/elementwise.py +++ b/ivy/functional/backends/paddle/experimental/elementwise.py @@ -612,8 +612,7 @@ def conj(x: paddle.Tensor, /, *, out: Optional[paddle.Tensor] = None) -> paddle. def modf( - x: paddle.Tensor,/,*,out: Optional[Tuple[paddle.Tensor, paddle.Tensor]] = None + x: paddle.Tensor, /, *, out: Optional[Tuple[paddle.Tensor, paddle.Tensor]] = None ) -> Tuple[paddle.Tensor, paddle.Tensor]: with ivy.ArrayMode(False): return paddle.modf(x, out=out) - \ No newline at end of file diff --git a/ivy/functional/backends/tensorflow/experimental/elementwise.py b/ivy/functional/backends/tensorflow/experimental/elementwise.py index 3ac733634dc80..7dee858858b6a 100644 --- a/ivy/functional/backends/tensorflow/experimental/elementwise.py +++ b/ivy/functional/backends/tensorflow/experimental/elementwise.py @@ -488,6 +488,9 @@ def frexp( def modf( - x: Union[tf.Tensor, tf.Variable],/,*,out: Optional[Union[tf.Tensor, tf.Variable]] = None, + x: Union[tf.Tensor, tf.Variable], + /, + *, + out: Optional[Union[tf.Tensor, tf.Variable]] = None, ) -> Union[tf.Tensor, tf.Variable]: return tf.math.modf(x) diff --git a/ivy/functional/backends/torch/experimental/elementwise.py b/ivy/functional/backends/torch/experimental/elementwise.py index 807dc8455052b..d8e3f05d7ee52 100644 --- a/ivy/functional/backends/torch/experimental/elementwise.py +++ b/ivy/functional/backends/torch/experimental/elementwise.py @@ -357,7 +357,10 @@ def frexp( def modf( - x: torch.Tensor,/,*,out: Optional[torch.Tensor] = None, + x: torch.Tensor, + /, + *, + out: Optional[torch.Tensor] = None, ) -> torch.Tensor: modf_x = torch.modf(x) return torch.resolve_modf(input=modf_x) diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py index a937fad229196..b675736aeca93 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_elementwise.py @@ -701,11 +701,11 @@ def test_frexp(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): test_with_out=st.just(False), ) def test_modf( - dtype_and_x, - frontend, - test_flags, - fn_tree, - on_device, + dtype_and_x, + frontend, + test_flags, + fn_tree, + on_device, ): input_dtype, x = dtype_and_x helpers.test_function( @@ -716,4 +716,3 @@ def test_modf( on_device=on_device, x=x[0], ) - \ No newline at end of file From 661de15a3ae12531b4dc41b205bc862b823282b1 Mon Sep 17 00:00:00 2001 From: Debaditya Pal Date: Mon, 10 Jul 2023 13:55:15 +0530 Subject: [PATCH 09/24] Sign_ for torch frontend instance method (#17512) Co-authored-by: @AnnaTz --- ivy/functional/frontends/torch/tensor.py | 5 +++ .../test_frontends/test_torch/test_tensor.py | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py index e169967fdef76..6342756170c62 100644 --- a/ivy/functional/frontends/torch/tensor.py +++ b/ivy/functional/frontends/torch/tensor.py @@ -1308,6 +1308,11 @@ def addcmul_(self, tensor1, tensor2, *, value=1): def sign(self): return torch_frontend.sign(self._ivy_array) + @with_unsupported_dtypes({"2.0.1 and below": sign_decorator_dtypes}, "torch") + def sign_(self): + self.ivy_array = self.sign().ivy_array + return self + @numpy_to_torch_style_args def std(self, dim=None, unbiased=True, keepdim=False, *, out=None): return torch_frontend.std( diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py index f1ac432c36dd7..056e70c7211e6 100644 --- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py @@ -8329,6 +8329,37 @@ def test_torch_instance_sign( ) +# sign_ +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="torch.tensor", + method_name="sign_", + dtype_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + ), +) +def test_torch_instance_sign_( + dtype_x, + frontend, + frontend_method_data, + init_flags, + method_flags, + on_device, +): + input_dtype, x = dtype_x + 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={}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + on_device=on_device, + frontend=frontend, + ) + + # std @handle_frontend_method( class_tree=CLASS_TREE, From b3ecb72932bbf363173d2d984902935e737fae4e Mon Sep 17 00:00:00 2001 From: akshatvishu <33392262+akshatvishu@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:03:19 +0530 Subject: [PATCH 10/24] refactor `inv` adjoint=True to work for `N-D` input. (#18961) --- ivy/functional/backends/jax/linear_algebra.py | 9 +++-- .../backends/numpy/linear_algebra.py | 18 ++++----- .../backends/tensorflow/linear_algebra.py | 21 +++++----- .../backends/torch/linear_algebra.py | 24 ++++++------ ivy/functional/frontends/tensorflow/linalg.py | 16 ++++++++ .../test_tensorflow/test_linalg.py | 39 +++++++++++++++++++ 6 files changed, 90 insertions(+), 37 deletions(-) diff --git a/ivy/functional/backends/jax/linear_algebra.py b/ivy/functional/backends/jax/linear_algebra.py index 660f000464d94..1afb74e390888 100644 --- a/ivy/functional/backends/jax/linear_algebra.py +++ b/ivy/functional/backends/jax/linear_algebra.py @@ -144,10 +144,13 @@ def inv( adjoint: bool = False, out: Optional[JaxArray] = None, ) -> JaxArray: - if jnp.any(jnp.linalg.det(x.astype("float64")) == 0): - return x if adjoint: - x = jnp.transpose(x) + if x.ndim < 2: + raise ValueError("Input must be at least 2D") + permutation = list(range(x.ndim)) + permutation[-2], permutation[-1] = permutation[-1], permutation[-2] + x_adj = jnp.transpose(x, permutation).conj() + return jnp.linalg.inv(x_adj) return jnp.linalg.inv(x) diff --git a/ivy/functional/backends/numpy/linear_algebra.py b/ivy/functional/backends/numpy/linear_algebra.py index e1334a89012cc..b2236a1a15377 100644 --- a/ivy/functional/backends/numpy/linear_algebra.py +++ b/ivy/functional/backends/numpy/linear_algebra.py @@ -101,16 +101,14 @@ def inv( adjoint: bool = False, out: Optional[np.ndarray] = None, ) -> np.ndarray: - if np.any(np.linalg.det(x.astype("float64")) == 0): - return x - else: - if adjoint is False: - ret = np.linalg.inv(x) - return ret - else: - x = np.transpose(x) - ret = np.linalg.inv(x) - return ret + if adjoint: + if x.ndim < 2: + raise ValueError("Input must be at least 2D") + permutation = list(range(x.ndim)) + permutation[-2], permutation[-1] = permutation[-1], permutation[-2] + x_adj = np.transpose(x, permutation).conj() + return np.linalg.inv(x_adj) + return np.linalg.inv(x) @with_unsupported_dtypes({"1.25.0 and below": ("float16", "bfloat16")}, backend_version) diff --git a/ivy/functional/backends/tensorflow/linear_algebra.py b/ivy/functional/backends/tensorflow/linear_algebra.py index 76078b394d526..73e22d9ea1e89 100644 --- a/ivy/functional/backends/tensorflow/linear_algebra.py +++ b/ivy/functional/backends/tensorflow/linear_algebra.py @@ -182,7 +182,15 @@ def inner( return tf.experimental.numpy.inner(x1, x2) -@with_unsupported_dtypes({"2.13.0 and below": ("float16", "bfloat16")}, backend_version) +@with_unsupported_dtypes( + { + "2.13.0 and below": ( + "float16", + "bfloat16", + ) + }, + backend_version, +) def inv( x: Union[tf.Tensor, tf.Variable], /, @@ -190,16 +198,7 @@ def inv( adjoint: bool = False, out: Optional[Union[tf.Tensor, tf.Variable]] = None, ) -> Union[tf.Tensor, tf.Variable]: - if tf.math.reduce_any(tf.linalg.det(tf.cast(x, dtype="float64")) == 0): - return x - else: - if adjoint is False: - ret = tf.linalg.inv(x) - return ret - else: - x = tf.linalg.adjoint(x) - ret = tf.linalg.inv(x) - return ret + return tf.linalg.inv(x, adjoint=adjoint) @with_unsupported_dtypes( diff --git a/ivy/functional/backends/torch/linear_algebra.py b/ivy/functional/backends/torch/linear_algebra.py index 017b58d939179..9dab993a31b7e 100644 --- a/ivy/functional/backends/torch/linear_algebra.py +++ b/ivy/functional/backends/torch/linear_algebra.py @@ -143,20 +143,18 @@ def inv( adjoint: bool = False, out: Optional[torch.Tensor] = None, ) -> torch.Tensor: - if torch.linalg.det == 0: - ret = x - if ivy.exists(out): - return ivy.inplace_update(out, ret) + if adjoint: + if x.dim() < 2: + raise ValueError("Input must be at least 2D") + x_adj = x.transpose(-2, -1).conj() + ret = torch.linalg.inv(x_adj) else: - if adjoint is False: - ret = torch.inverse(x, out=out) - return ret - else: - x = torch.t(x) - ret = torch.inverse(x, out=out) - if ivy.exists(out): - return ivy.inplace_update(out, ret) - return ret + ret = torch.linalg.inv(x) + + if ivy.exists(out): + return ivy.inplace_update(out, ret) + + return ret inv.support_native_out = True diff --git a/ivy/functional/frontends/tensorflow/linalg.py b/ivy/functional/frontends/tensorflow/linalg.py index 607e958984964..1f53f6b4b5d2e 100644 --- a/ivy/functional/frontends/tensorflow/linalg.py +++ b/ivy/functional/frontends/tensorflow/linalg.py @@ -308,3 +308,19 @@ def band_part(input, num_lower, num_upper, name=None): (num_upper < 0) | ((n - m) <= num_upper) ) return ivy.where(mask, input, ivy.zeros_like(input)) + + +@to_ivy_arrays_and_back +@with_supported_dtypes( + { + "2.13.0 and below": ( + "float32", + "float64", + "complex64", + "complex128", + ) + }, + "tensorflow", +) +def inv(input, adjoint=False, name=None): + return ivy.inv(input, adjoint=adjoint) diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_linalg.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_linalg.py index 402355d7dda6b..86f460e4dae9c 100644 --- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_linalg.py +++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_linalg.py @@ -916,3 +916,42 @@ def test_tensorflow_band_part( num_lower=num_lower, num_upper=num_upper, ) + + +# inv +@handle_frontend_test( + fn_tree="tensorflow.linalg.inv", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + min_value=-100, + max_value=100, + shape=helpers.ints(min_value=1, max_value=20).map(lambda x: tuple([x, x])), + ).filter( + lambda x: "bfloat16" not in x[0] + and np.linalg.cond(x[1][0]) < 1 / sys.float_info.epsilon + and np.linalg.det(np.asarray(x[1][0])) != 0 + ), + adjoint=st.booleans(), + test_with_out=st.just(False), +) +def test_tensorflow_inv( + *, + dtype_and_x, + on_device, + fn_tree, + frontend, + test_flags, + adjoint, +): + dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=dtype, + rtol=1e-01, + atol=1e-01, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + input=x[0], + adjoint=adjoint, + ) From 9caddfd197fddfd2f7fb9f5ebc4fa930f159d971 Mon Sep 17 00:00:00 2001 From: Yoseph Date: Mon, 10 Jul 2023 13:38:13 +0500 Subject: [PATCH 11/24] tensorflow frontend atanh #18992 (#19030) Co-authored-by: JG <67888047+juliagsy@users.noreply.github.com> --- ivy/functional/frontends/tensorflow/math.py | 5 ++++ .../test_tensorflow/test_math.py | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ivy/functional/frontends/tensorflow/math.py b/ivy/functional/frontends/tensorflow/math.py index 4fb53a9b22856..8ad8accb4cfa9 100644 --- a/ivy/functional/frontends/tensorflow/math.py +++ b/ivy/functional/frontends/tensorflow/math.py @@ -706,3 +706,8 @@ def top_k(input, k=1, sorted=True, name=None): @to_ivy_arrays_and_back def real(input, name=None): return ivy.real(input) + + +@to_ivy_arrays_and_back +def atanh(x, name="atanh"): + return ivy.atanh(x) diff --git a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py index 40bcb8d988f2e..a5f3a58bb674d 100644 --- a/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py +++ b/ivy_tests/test_ivy/test_frontends/test_tensorflow/test_math.py @@ -2642,3 +2642,30 @@ def test_tensorflow_real( on_device=on_device, input=x[0], ) + + +# atanh +@handle_frontend_test( + fn_tree="tensorflow.math.atanh", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float_and_complex"), + ), + test_with_out=st.just(False), +) +def test_tensorflow_atanh( + *, + dtype_and_x, + on_device, + fn_tree, + frontend, + test_flags, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + ) From aee8d95e0e5a089ccc0c4758948b431cfb742f89 Mon Sep 17 00:00:00 2001 From: Felix Hirwa Nshuti Date: Mon, 10 Jul 2023 10:46:59 +0200 Subject: [PATCH 12/24] numpy version update to 1.25.1 (#19136) --- ivy/functional/backends/numpy/__init__.py | 24 ++++++------ ivy/functional/backends/numpy/data_type.py | 4 +- ivy/functional/backends/numpy/elementwise.py | 32 ++++++++-------- .../numpy/experimental/activations.py | 2 +- .../numpy/experimental/elementwise.py | 2 +- .../backends/numpy/experimental/general.py | 2 +- .../backends/numpy/experimental/layers.py | 4 +- .../numpy/experimental/linear_algebra.py | 2 +- .../backends/numpy/experimental/norms.py | 2 +- .../backends/numpy/experimental/searching.py | 2 +- .../numpy/experimental/statistical.py | 4 +- ivy/functional/backends/numpy/general.py | 2 +- .../backends/numpy/linear_algebra.py | 38 +++++++++---------- ivy/functional/backends/numpy/manipulation.py | 2 +- ivy/functional/backends/numpy/random.py | 2 +- ivy/functional/backends/numpy/sorting.py | 2 +- ivy/functional/backends/numpy/statistical.py | 2 +- ivy/functional/frontends/__init__.py | 2 +- .../numpy/fft/discrete_fourier_transform.py | 10 ++--- .../numpy/linalg/norms_and_other_numbers.py | 4 +- ...olving_equations_and_inverting_matrices.py | 10 ++--- .../mathematical_functions/miscellaneous.py | 2 +- .../frontends/numpy/statistics/histograms.py | 2 +- 23 files changed, 79 insertions(+), 79 deletions(-) diff --git a/ivy/functional/backends/numpy/__init__.py b/ivy/functional/backends/numpy/__init__.py index 4804323039c3e..c39d0045f14b6 100644 --- a/ivy/functional/backends/numpy/__init__.py +++ b/ivy/functional/backends/numpy/__init__.py @@ -51,7 +51,7 @@ # update these to add new dtypes valid_dtypes = { - "1.25.0 and below": ( + "1.25.1 and below": ( ivy.int8, ivy.int16, ivy.int32, @@ -69,7 +69,7 @@ ) } valid_numeric_dtypes = { - "1.25.0 and below": ( + "1.25.1 and below": ( ivy.int8, ivy.int16, ivy.int32, @@ -86,7 +86,7 @@ ) } valid_int_dtypes = { - "1.25.0 and below": ( + "1.25.1 and below": ( ivy.int8, ivy.int16, ivy.int32, @@ -97,11 +97,11 @@ ivy.uint64, ) } -valid_float_dtypes = {"1.25.0 and below": (ivy.float16, ivy.float32, ivy.float64)} +valid_float_dtypes = {"1.25.1 and below": (ivy.float16, ivy.float32, ivy.float64)} valid_uint_dtypes = { - "1.25.0 and below": (ivy.uint8, ivy.uint16, ivy.uint32, ivy.uint64) + "1.25.1 and below": (ivy.uint8, ivy.uint16, ivy.uint32, ivy.uint64) } -valid_complex_dtypes = {"1.25.0 and below": (ivy.complex64, ivy.complex128)} +valid_complex_dtypes = {"1.25.1 and below": (ivy.complex64, ivy.complex128)} # leave these untouched valid_dtypes = _dtype_from_version(valid_dtypes, backend_version) @@ -113,12 +113,12 @@ # invalid data types # update these to add new dtypes -invalid_dtypes = {"1.25.0 and below": (ivy.bfloat16,)} -invalid_numeric_dtypes = {"1.25.0 and below": (ivy.bfloat16,)} -invalid_int_dtypes = {"1.25.0 and below": ()} -invalid_float_dtypes = {"1.25.0 and below": (ivy.bfloat16,)} -invalid_uint_dtypes = {"1.25.0 and below": ()} -invalid_complex_dtypes = {"1.25.0 and below": ()} +invalid_dtypes = {"1.25.1 and below": (ivy.bfloat16,)} +invalid_numeric_dtypes = {"1.25.1 and below": (ivy.bfloat16,)} +invalid_int_dtypes = {"1.25.1 and below": ()} +invalid_float_dtypes = {"1.25.1 and below": (ivy.bfloat16,)} +invalid_uint_dtypes = {"1.25.1 and below": ()} +invalid_complex_dtypes = {"1.25.1 and below": ()} # leave these untouched diff --git a/ivy/functional/backends/numpy/data_type.py b/ivy/functional/backends/numpy/data_type.py index b219642ecaed8..98f432a1480c6 100644 --- a/ivy/functional/backends/numpy/data_type.py +++ b/ivy/functional/backends/numpy/data_type.py @@ -133,7 +133,7 @@ def broadcast_arrays(*arrays: np.ndarray) -> List[np.ndarray]: raise ivy.utils.exceptions.IvyBroadcastShapeError(e) -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def broadcast_to( x: np.ndarray, /, @@ -216,7 +216,7 @@ def as_ivy_dtype( ) -@with_unsupported_dtypes({"1.25.0 and below": ("bfloat16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("bfloat16",)}, backend_version) def as_native_dtype(dtype_in: Union[np.dtype, str, bool, int, float], /) -> np.dtype: if dtype_in is int: return ivy.default_int_dtype(as_native=True) diff --git a/ivy/functional/backends/numpy/elementwise.py b/ivy/functional/backends/numpy/elementwise.py index 6cf970944f2e7..1432fb63505f1 100644 --- a/ivy/functional/backends/numpy/elementwise.py +++ b/ivy/functional/backends/numpy/elementwise.py @@ -87,7 +87,7 @@ def atan(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def atan2( x1: np.ndarray, x2: np.ndarray, /, *, out: Optional[np.ndarray] = None ) -> np.ndarray: @@ -107,7 +107,7 @@ def atanh(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_and( x1: Union[int, bool, np.ndarray], x2: Union[int, bool, np.ndarray], @@ -123,7 +123,7 @@ def bitwise_and( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_invert( x: Union[int, bool, np.ndarray], /, *, out: Optional[np.ndarray] = None ) -> np.ndarray: @@ -134,7 +134,7 @@ def bitwise_invert( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_left_shift( x1: Union[int, bool, np.ndarray], x2: Union[int, bool, np.ndarray], @@ -150,7 +150,7 @@ def bitwise_left_shift( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_or( x1: Union[int, bool, np.ndarray], x2: Union[int, bool, np.ndarray], @@ -166,7 +166,7 @@ def bitwise_or( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_right_shift( x1: Union[int, bool, np.ndarray], x2: Union[int, bool, np.ndarray], @@ -182,7 +182,7 @@ def bitwise_right_shift( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def bitwise_xor( x1: Union[int, bool, np.ndarray], x2: Union[int, bool, np.ndarray], @@ -197,7 +197,7 @@ def bitwise_xor( bitwise_xor.support_native_out = True -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) @_scalar_output_to_0d_array def ceil(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: if "int" in str(x.dtype): @@ -220,7 +220,7 @@ def cos(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: cos.support_native_out = True -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) @_scalar_output_to_0d_array def cosh(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.cosh(x, out=out) @@ -293,7 +293,7 @@ def expm1(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def floor(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: if "int" in str(x.dtype): ret = np.copy(x) @@ -308,7 +308,7 @@ def floor(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def floor_divide( x1: Union[float, np.ndarray], x2: Union[float, np.ndarray], @@ -490,7 +490,7 @@ def log2(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def logaddexp( x1: np.ndarray, x2: np.ndarray, /, *, out: Optional[np.ndarray] = None ) -> np.ndarray: @@ -622,7 +622,7 @@ def pow( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def remainder( x1: Union[float, np.ndarray], x2: Union[float, np.ndarray], @@ -862,7 +862,7 @@ def reciprocal( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def deg2rad(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.deg2rad(x, out=out) @@ -871,7 +871,7 @@ def deg2rad(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def rad2deg(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.rad2deg(x, out=out) @@ -888,7 +888,7 @@ def isreal(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def fmod( x1: np.ndarray, x2: np.ndarray, diff --git a/ivy/functional/backends/numpy/experimental/activations.py b/ivy/functional/backends/numpy/experimental/activations.py index c57ff0d373776..2f837f0dd6a44 100644 --- a/ivy/functional/backends/numpy/experimental/activations.py +++ b/ivy/functional/backends/numpy/experimental/activations.py @@ -50,7 +50,7 @@ def relu6(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: relu6.support_native_out = True -@with_unsupported_dtypes({"1.25.0 and below": ("bool",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("bool",)}, backend_version) @_scalar_output_to_0d_array def logsigmoid(input: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return -(np.log1p(np.exp(-(input)))) diff --git a/ivy/functional/backends/numpy/experimental/elementwise.py b/ivy/functional/backends/numpy/experimental/elementwise.py index 3d31adb278746..81157f7d51439 100644 --- a/ivy/functional/backends/numpy/experimental/elementwise.py +++ b/ivy/functional/backends/numpy/experimental/elementwise.py @@ -10,7 +10,7 @@ @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("bfloat16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("bfloat16",)}, backend_version) def sinc(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.sinc(x).astype(x.dtype) diff --git a/ivy/functional/backends/numpy/experimental/general.py b/ivy/functional/backends/numpy/experimental/general.py index fc37461f2a5fb..5f0f974764c78 100644 --- a/ivy/functional/backends/numpy/experimental/general.py +++ b/ivy/functional/backends/numpy/experimental/general.py @@ -7,7 +7,7 @@ from ivy import with_unsupported_dtypes -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def reduce( operand: np.ndarray, init_value: Union[int, float], diff --git a/ivy/functional/backends/numpy/experimental/layers.py b/ivy/functional/backends/numpy/experimental/layers.py index 24666fea02f7a..b8b5b9a6deab9 100644 --- a/ivy/functional/backends/numpy/experimental/layers.py +++ b/ivy/functional/backends/numpy/experimental/layers.py @@ -641,7 +641,7 @@ def fft( return np.fft.fft(x, n, dim, norm).astype(out_dtype) -@with_supported_dtypes({"1.25.0 and below": ("float32", "float64")}, backend_version) +@with_supported_dtypes({"1.25.1 and below": ("float32", "float64")}, backend_version) def dct( x: np.ndarray, /, @@ -903,7 +903,7 @@ def ifftn( return np.fft.ifftn(x, s, axes, norm).astype(x.dtype) -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def embedding( weights: np.ndarray, indices: np.ndarray, diff --git a/ivy/functional/backends/numpy/experimental/linear_algebra.py b/ivy/functional/backends/numpy/experimental/linear_algebra.py index 2c1b704ecaae5..b87e88f2cd1ea 100644 --- a/ivy/functional/backends/numpy/experimental/linear_algebra.py +++ b/ivy/functional/backends/numpy/experimental/linear_algebra.py @@ -97,7 +97,7 @@ def kron( @with_supported_dtypes( - {"1.25.0 and below": ("float32", "float64", "complex64", "complex128")}, + {"1.25.1 and below": ("float32", "float64", "complex64", "complex128")}, backend_version, ) def matrix_exp( diff --git a/ivy/functional/backends/numpy/experimental/norms.py b/ivy/functional/backends/numpy/experimental/norms.py index 294bd14d7556f..644e8e400241d 100644 --- a/ivy/functional/backends/numpy/experimental/norms.py +++ b/ivy/functional/backends/numpy/experimental/norms.py @@ -4,7 +4,7 @@ from . import backend_version -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def l1_normalize( x: np.ndarray, /, diff --git a/ivy/functional/backends/numpy/experimental/searching.py b/ivy/functional/backends/numpy/experimental/searching.py index 73959cbc8ea97..9982659627ebf 100644 --- a/ivy/functional/backends/numpy/experimental/searching.py +++ b/ivy/functional/backends/numpy/experimental/searching.py @@ -7,7 +7,7 @@ from . import backend_version -@with_supported_dtypes({"1.25.0 and below": ("int32", "int64")}, backend_version) +@with_supported_dtypes({"1.25.1 and below": ("int32", "int64")}, backend_version) def unravel_index( indices: np.ndarray, shape: Tuple[int], diff --git a/ivy/functional/backends/numpy/experimental/statistical.py b/ivy/functional/backends/numpy/experimental/statistical.py index a67623780ebe7..9195d0320be2d 100644 --- a/ivy/functional/backends/numpy/experimental/statistical.py +++ b/ivy/functional/backends/numpy/experimental/statistical.py @@ -8,7 +8,7 @@ @with_unsupported_dtypes( - {"1.25.0 and below": ("bfloat16",)}, + {"1.25.1 and below": ("bfloat16",)}, backend_version, ) def histogram( @@ -361,7 +361,7 @@ def __get_index(lst, indices=None, prefix=None): return indices -@with_unsupported_dtypes({"1.25.0 and below": "bfloat16"}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": "bfloat16"}, backend_version) def cummin( x: np.ndarray, /, diff --git a/ivy/functional/backends/numpy/general.py b/ivy/functional/backends/numpy/general.py index 30af0d3586ea2..f42fcfe023a90 100644 --- a/ivy/functional/backends/numpy/general.py +++ b/ivy/functional/backends/numpy/general.py @@ -433,7 +433,7 @@ def _vmap(*args): return _vmap -@with_unsupported_dtypes({"1.25.0 and below": ("bfloat16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("bfloat16",)}, backend_version) def isin( elements: np.ndarray, test_elements: np.ndarray, diff --git a/ivy/functional/backends/numpy/linear_algebra.py b/ivy/functional/backends/numpy/linear_algebra.py index b2236a1a15377..f858b575d9865 100644 --- a/ivy/functional/backends/numpy/linear_algebra.py +++ b/ivy/functional/backends/numpy/linear_algebra.py @@ -19,7 +19,7 @@ # -------------------# -@with_unsupported_dtypes({"1.25.0 and below": ("float16", "complex")}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16", "complex")}, backend_version) def cholesky( x: np.ndarray, /, *, upper: bool = False, out: Optional[np.ndarray] = None ) -> np.ndarray: @@ -31,7 +31,7 @@ def cholesky( return ret -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def cross( x1: np.ndarray, x2: np.ndarray, @@ -47,7 +47,7 @@ def cross( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def det(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.linalg.det(x) @@ -64,7 +64,7 @@ def diagonal( return np.diagonal(x, offset=offset, axis1=axis1, axis2=axis2) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def eigh( x: np.ndarray, /, *, UPLO: str = "L", out: Optional[np.ndarray] = None ) -> Tuple[np.ndarray]: @@ -75,7 +75,7 @@ def eigh( return result_tuple(eigenvalues, eigenvectors) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def eigvalsh( x: np.ndarray, /, *, UPLO: str = "L", out: Optional[np.ndarray] = None ) -> np.ndarray: @@ -91,7 +91,7 @@ def inner( @with_unsupported_dtypes( - {"1.25.0 and below": ("bfloat16", "float16", "complex")}, + {"1.25.1 and below": ("bfloat16", "float16", "complex")}, backend_version, ) def inv( @@ -111,7 +111,7 @@ def inv( return np.linalg.inv(x) -@with_unsupported_dtypes({"1.25.0 and below": ("float16", "bfloat16")}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16", "bfloat16")}, backend_version) def matmul( x1: np.ndarray, x2: np.ndarray, @@ -141,7 +141,7 @@ def matmul( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("float16", "bfloat16")}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16", "bfloat16")}, backend_version) def matrix_norm( x: np.ndarray, /, @@ -163,7 +163,7 @@ def matrix_power( @with_unsupported_dtypes( - {"1.25.0 and below": ("float16", "bfloat16", "complex")}, + {"1.25.1 and below": ("float16", "bfloat16", "complex")}, backend_version, ) @_scalar_output_to_0d_array @@ -202,7 +202,7 @@ def matrix_transpose( return np.swapaxes(x, -1, -2) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def outer( x1: np.ndarray, x2: np.ndarray, @@ -217,7 +217,7 @@ def outer( outer.support_native_out = True -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def pinv( x: np.ndarray, /, @@ -231,7 +231,7 @@ def pinv( return np.linalg.pinv(x, rtol) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def qr( x: np.ndarray, /, @@ -244,7 +244,7 @@ def qr( return res(q, r) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def slogdet( x: np.ndarray, /, @@ -259,7 +259,7 @@ def slogdet( return results(sign, logabsdet) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def solve( x1: np.ndarray, x2: np.ndarray, @@ -284,7 +284,7 @@ def solve( return ret -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def svd( x: np.ndarray, /, *, compute_uv: bool = True, full_matrices: bool = True ) -> Union[np.ndarray, Tuple[np.ndarray, ...]]: @@ -298,7 +298,7 @@ def svd( return results(D) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def svdvals(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> np.ndarray: return np.linalg.svd(x, compute_uv=False) @@ -327,7 +327,7 @@ def tensordot( @_scalar_output_to_0d_array -@with_unsupported_dtypes({"1.25.0 and below": ("float16", "bfloat16")}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16", "bfloat16")}, backend_version) def trace( x: np.ndarray, /, @@ -355,7 +355,7 @@ def vecdot( return np.tensordot(x1, x2, axes=(axis, axis)) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, backend_version) def eig(x: np.ndarray, /, *, out: Optional[np.ndarray] = None) -> Tuple[np.ndarray]: result_tuple = NamedTuple( "eig", [("eigenvalues", np.ndarray), ("eigenvectors", np.ndarray)] @@ -421,7 +421,7 @@ def vander( @with_unsupported_dtypes( { - "1.25.0 and below": ( + "1.25.1 and below": ( "complex", "unsigned", ) diff --git a/ivy/functional/backends/numpy/manipulation.py b/ivy/functional/backends/numpy/manipulation.py index 7d31098bf90ac..f1b0a2b044969 100644 --- a/ivy/functional/backends/numpy/manipulation.py +++ b/ivy/functional/backends/numpy/manipulation.py @@ -209,7 +209,7 @@ def split( return np.split(x, num_or_size_splits, axis) -@with_unsupported_dtypes({"1.25.0 and below": ("uint64",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("uint64",)}, backend_version) def repeat( x: np.ndarray, /, diff --git a/ivy/functional/backends/numpy/random.py b/ivy/functional/backends/numpy/random.py index 21b07cc070c45..96757afb02979 100644 --- a/ivy/functional/backends/numpy/random.py +++ b/ivy/functional/backends/numpy/random.py @@ -51,7 +51,7 @@ def random_normal( return np.asarray(np.random.normal(mean, std, shape), dtype=dtype) -@with_unsupported_dtypes({"1.25.0 and below": ("bfloat16",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("bfloat16",)}, backend_version) def multinomial( population_size: int, num_samples: int, diff --git a/ivy/functional/backends/numpy/sorting.py b/ivy/functional/backends/numpy/sorting.py index 38843daee5d5e..9a5807fa595b4 100644 --- a/ivy/functional/backends/numpy/sorting.py +++ b/ivy/functional/backends/numpy/sorting.py @@ -42,7 +42,7 @@ def sort( # msort -@with_unsupported_dtypes({"1.25.0 and below": ("complex",)}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": ("complex",)}, backend_version) def msort( a: Union[np.ndarray, list, tuple], /, *, out: Optional[np.ndarray] = None ) -> np.ndarray: diff --git a/ivy/functional/backends/numpy/statistical.py b/ivy/functional/backends/numpy/statistical.py index 1bbd72dad4a4e..a946fb6797d51 100644 --- a/ivy/functional/backends/numpy/statistical.py +++ b/ivy/functional/backends/numpy/statistical.py @@ -170,7 +170,7 @@ def var( # ------# -@with_unsupported_dtypes({"1.25.0 and below": "bfloat16"}, backend_version) +@with_unsupported_dtypes({"1.25.1 and below": "bfloat16"}, backend_version) def cumprod( x: np.ndarray, /, diff --git a/ivy/functional/frontends/__init__.py b/ivy/functional/frontends/__init__.py index ba71d9bce8153..1bba32b34ee62 100644 --- a/ivy/functional/frontends/__init__.py +++ b/ivy/functional/frontends/__init__.py @@ -4,7 +4,7 @@ versions = { "torch": "2.0.1", "tensorflow": "2.13.0", - "numpy": "1.25.0", + "numpy": "1.25.1", "jax": "0.4.13", "scipy": "1.10.1", "paddle": "2.5.0", diff --git a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py index 3d3d1bc70b519..0a92c93f4dcd7 100644 --- a/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py +++ b/ivy/functional/frontends/numpy/fft/discrete_fourier_transform.py @@ -29,7 +29,7 @@ def ifft(a, n=None, axis=-1, norm=None): @to_ivy_arrays_and_back -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") def ifftshift(x, axes=None): x = ivy.asarray(x) @@ -55,7 +55,7 @@ def fft(a, n=None, axis=-1, norm=None): @to_ivy_arrays_and_back -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") def fftshift(x, axes=None): x = ivy.asarray(x) @@ -75,7 +75,7 @@ def fftshift(x, axes=None): return roll -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back def rfft(a, n=None, axis=-1, norm=None): if norm is None: @@ -84,7 +84,7 @@ def rfft(a, n=None, axis=-1, norm=None): return ivy.dft(a, axis=axis, inverse=False, onesided=True, dft_length=n, norm=norm) -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back def ihfft(a, n=None, axis=-1, norm=None): if n is None: @@ -94,7 +94,7 @@ def ihfft(a, n=None, axis=-1, norm=None): return output -@with_unsupported_dtypes({"1.25.0 and below": ("int",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("int",)}, "numpy") @to_ivy_arrays_and_back def fftfreq(n, d=1.0): if not isinstance( diff --git a/ivy/functional/frontends/numpy/linalg/norms_and_other_numbers.py b/ivy/functional/frontends/numpy/linalg/norms_and_other_numbers.py index 0937d5c6e1612..fb5ab639f5499 100644 --- a/ivy/functional/frontends/numpy/linalg/norms_and_other_numbers.py +++ b/ivy/functional/frontends/numpy/linalg/norms_and_other_numbers.py @@ -9,7 +9,7 @@ # solve -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back @from_zero_dim_arrays_to_scalar def norm(x, ord=None, axis=None, keepdims=False): @@ -46,7 +46,7 @@ def det(a): # slogdet -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back @from_zero_dim_arrays_to_scalar def slogdet(a): diff --git a/ivy/functional/frontends/numpy/linalg/solving_equations_and_inverting_matrices.py b/ivy/functional/frontends/numpy/linalg/solving_equations_and_inverting_matrices.py index 3db295fe4cc0c..4e4ddaa499dca 100644 --- a/ivy/functional/frontends/numpy/linalg/solving_equations_and_inverting_matrices.py +++ b/ivy/functional/frontends/numpy/linalg/solving_equations_and_inverting_matrices.py @@ -10,7 +10,7 @@ # solve -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back def solve(a, b): a, b = promote_types_of_numpy_inputs(a, b) @@ -18,7 +18,7 @@ def solve(a, b): # inv -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back def inv(a): return ivy.inv(a) @@ -26,14 +26,14 @@ def inv(a): # pinv # TODO: add hermitian functionality -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") @to_ivy_arrays_and_back def pinv(a, rcond=1e-15, hermitian=False): return ivy.pinv(a, rtol=rcond) @to_ivy_arrays_and_back -@with_unsupported_dtypes({"1.25.0 and below": ("float16", "blfloat16")}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16", "blfloat16")}, "numpy") def tensorinv(a, ind=2): old_shape = ivy.shape(a) prod = 1 @@ -52,7 +52,7 @@ def tensorinv(a, ind=2): # TODO: replace this with function from API # As the compositon provides unstable results @to_ivy_arrays_and_back -@with_unsupported_dtypes({"1.25.0 and below": ("float16",)}, "numpy") +@with_unsupported_dtypes({"1.25.1 and below": ("float16",)}, "numpy") def lstsq(a, b, rcond="warn"): solution = ivy.matmul( ivy.pinv(a, rtol=1e-15).astype(ivy.float64), b.astype(ivy.float64) diff --git a/ivy/functional/frontends/numpy/mathematical_functions/miscellaneous.py b/ivy/functional/frontends/numpy/mathematical_functions/miscellaneous.py index c60122f1c0929..c725ce2941ca2 100644 --- a/ivy/functional/frontends/numpy/mathematical_functions/miscellaneous.py +++ b/ivy/functional/frontends/numpy/mathematical_functions/miscellaneous.py @@ -334,7 +334,7 @@ def _lcm( @to_ivy_arrays_and_back @from_zero_dim_arrays_to_scalar @with_supported_dtypes( - {"1.25.0 and below": ("int8", "int16", "int32", "int64")}, "numpy" + {"1.25.1 and below": ("int8", "int16", "int32", "int64")}, "numpy" ) # Add def _gcd( x1, diff --git a/ivy/functional/frontends/numpy/statistics/histograms.py b/ivy/functional/frontends/numpy/statistics/histograms.py index 944934ffa5cd6..9f77716db0480 100644 --- a/ivy/functional/frontends/numpy/statistics/histograms.py +++ b/ivy/functional/frontends/numpy/statistics/histograms.py @@ -3,7 +3,7 @@ from ivy.func_wrapper import with_supported_dtypes -@with_supported_dtypes({"1.25.0 and below": ("int64",)}, "numpy") +@with_supported_dtypes({"1.25.1 and below": ("int64",)}, "numpy") @to_ivy_arrays_and_back def bincount(x, /, weights=None, minlength=0): return ivy.bincount(x, weights=weights, minlength=minlength) From 6068c57f38f670e7e6da7975fa0436411240aba0 Mon Sep 17 00:00:00 2001 From: Felix Hirwa Nshuti Date: Mon, 10 Jul 2023 11:51:42 +0200 Subject: [PATCH 13/24] fix the tests discovery issue caused duplicate tests (#19141) --- .../test_core/test_statistical.py | 76 ------------------- 1 file changed, 76 deletions(-) diff --git a/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py b/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py index 9fc9ab75c1017..4ee944ecbe9dd 100644 --- a/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py +++ b/ivy_tests/test_ivy/test_functional/test_core/test_statistical.py @@ -282,52 +282,6 @@ def test_cumsum( ) -@handle_test( - fn_tree="functional.ivy.cummax", - dtype_x_axis_castable=helpers.dtype_values_axis( - available_dtypes=helpers.get_dtypes("valid"), - min_num_dims=1, - max_num_dims=6, - min_value=-100, - max_value=100, - valid_axis=True, - allow_neg_axes=False, - max_axes_size=1, - force_int_axis=True, - ), - exclusive=st.booleans(), - reverse=st.booleans(), -) -def test_cummax( - *, - dtype_x_axis_castable, - exclusive, - reverse, - test_flags, - backend_fw, - fn_name, - on_device, -): - input_dtype, x, axis = dtype_x_axis_castable - if "torch" in backend_fw.__name__: - assume(not test_flags.as_variable[0]) - assume(not test_flags.test_gradients) - - helpers.test_function( - input_dtypes=input_dtype, - test_flags=test_flags, - fw=backend_fw, - fn_name=fn_name, - on_device=on_device, - x=x[0], - axis=axis, - exclusive=exclusive, - reverse=reverse, - rtol_=1e-1, - atol_=1e-1, - ) - - # cumprod @handle_test( fn_tree="functional.ivy.cumprod", @@ -374,36 +328,6 @@ def test_cumprod( ) -# cummin -@handle_test( - fn_tree="functional.ivy.cummin", - dtype_x_axis_castable=_get_castable_dtype(), - reverse=st.booleans(), -) -def test_cummin( - *, dtype_x_axis_castable, reverse, test_flags, backend_fw, fn_name, on_device -): - input_dtype, x, axis, castable_dtype = dtype_x_axis_castable - # ToDo: set as_variable_flags as the parameter generated by test_cummin once - # this issue is marked as completed https://github.com/pytorch/pytorch/issues/75733 - if "torch" in backend_fw.__name__: - assume(not test_flags.as_variable[0]) - assume(not test_flags.test_gradients) - helpers.test_function( - input_dtypes=[input_dtype], - test_flags=test_flags, - fw=backend_fw, - fn_name=fn_name, - on_device=on_device, - x=x[0], - axis=axis, - reverse=reverse, - dtype=castable_dtype, - rtol_=1e-4, - atol_=1e-4, - ) - - # TODO: add more general tests and fix get instance method testing passing # einsum @handle_test( From 72390ac50e9dcf60e2f56f5db26227a6a7da8884 Mon Sep 17 00:00:00 2001 From: Zaky <55076176+fadhlanzaky@users.noreply.github.com> Date: Mon, 10 Jul 2023 17:23:47 +0700 Subject: [PATCH 14/24] Add tolist to Paddle frontend (#17973) Co-authored-by: @MahmoudAshraf97 --- .../frontends/paddle/tensor/tensor.py | 3 ++ .../test_tensor/test_paddle_tensor.py | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index b52ab8c97cfa0..361fb92463a03 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -528,3 +528,6 @@ def sign(self, name=None): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sgn(self, name=None): return ivy.sign(self._ivy_array, np_variant=True) + + def tolist(self): + return ivy.to_list(self._ivy_array) \ No newline at end of file diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index c1b4b4af29b40..c2a3fca169e4a 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -2586,3 +2586,34 @@ def test_paddle_instance_sgn( frontend=frontend, on_device=on_device, ) + +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="tolist", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + ), +) +def test_paddle_instance_tolist( + dtype_and_x, + frontend_method_data, + init_flags, + method_flags, + frontend, + on_device, +): + input_dtype, x = dtype_and_x + 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={}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + on_device=on_device, + ) \ No newline at end of file From b2e744ab7a33a93645f3651f187e53d243fe6332 Mon Sep 17 00:00:00 2001 From: BenG <65197619+BBBenG23@users.noreply.github.com> Date: Mon, 10 Jul 2023 04:05:23 -0700 Subject: [PATCH 15/24] Paddle frontend clip (#18022) --- .../frontends/paddle/tensor/tensor.py | 18 ++++++ .../test_tensor/test_paddle_tensor.py | 59 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 361fb92463a03..9d4d07745e08a 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -165,6 +165,24 @@ def argsort(self, axis=-1, descending=False, name=None): def floor(self, name=None): return ivy.floor(self._ivy_array) + @with_supported_dtypes( + {"2.5.0 and below": ("float32", "float64", "int32", "int64")}, "paddle" + ) + def clip(self, min=None, max=None, name=None): + ivy.utils.assertions.check_all_or_any_fn( + min, + max, + fn=ivy.exists, + type="any", + limit=[1, 2], + message="at most one of min or max can be None", + ) + if min is None: + return ivy.minimum(self._ivy_array, max) + if max is None: + return ivy.maximum(self._ivy_array, min) + return ivy.clip(self._ivy_array, min, max) + @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def floor_(self): return ivy.floor(self._ivy_array) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py index c2a3fca169e4a..c92203049c034 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_tensor.py @@ -56,6 +56,34 @@ def _get_dtype_and_square_matrix(draw): return dtype, mat +@st.composite +def _get_clip_inputs(draw): + shape = draw( + helpers.get_shape( + min_num_dims=1, max_num_dims=5, min_dim_size=1, max_dim_size=10 + ) + ) + x_dtype, x = draw( + helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + shape=shape, + min_value=0, + max_value=50, + ) + ) + min = draw( + helpers.array_values(dtype=x_dtype[0], shape=(1,), min_value=0, max_value=25) + ) + max = draw( + helpers.array_values(dtype=x_dtype[0], shape=(1,), min_value=26, max_value=50) + ) + if draw(st.booleans()): + min = None + elif draw(st.booleans()): + max = None + return x_dtype, x, min, max + + # Tests # # ----- # @@ -1904,6 +1932,37 @@ def test_paddle_instance_minimum( ) +# clip +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="clip", + input_and_ranges=_get_clip_inputs(), +) +def test_paddle_clip( + input_and_ranges, + frontend, + frontend_method_data, + init_flags, + method_flags, + on_device, +): + input_dtype, x, min, max = input_and_ranges + 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={"min": min, "max": max}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + on_device=on_device, + ) + + # less_than @handle_frontend_method( class_tree=CLASS_TREE, From 66f7e5472bac8b4ac7bef2fe49ad2bcd3391b078 Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:28:49 +0100 Subject: [PATCH 16/24] renamed outputs_to_numpy_arrays to match the frontend wrapper convention --- .../creation_routines/from_shape_or_value.py | 22 +++++++++---------- .../creation_routines/numerical_ranges.py | 4 ++-- .../frontends/numpy/func_wrapper.py | 10 ++++----- .../test_numpy/test_func_wrapper.py | 10 ++++----- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ivy/functional/frontends/numpy/creation_routines/from_shape_or_value.py b/ivy/functional/frontends/numpy/creation_routines/from_shape_or_value.py index 249ff358c60be..5fcd632632a31 100644 --- a/ivy/functional/frontends/numpy/creation_routines/from_shape_or_value.py +++ b/ivy/functional/frontends/numpy/creation_routines/from_shape_or_value.py @@ -1,19 +1,19 @@ # local import ivy from ivy.functional.frontends.numpy.func_wrapper import ( - outputs_to_numpy_arrays, + outputs_to_frontend_arrays, handle_numpy_dtype, ) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def empty(shape, dtype="float64", order="C", *, like=None): return ivy.empty(shape=shape, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def empty_like(prototype, dtype=None, order="K", subok=True, shape=None): if shape: return ivy.empty(shape=shape, dtype=dtype) @@ -21,25 +21,25 @@ def empty_like(prototype, dtype=None, order="K", subok=True, shape=None): @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def eye(N, M=None, k=0, dtype="float64", order="C", *, like=None): return ivy.eye(N, M, k=k, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def identity(n, dtype=None, *, like=None): return ivy.eye(n, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def ones(shape, dtype=None, order="C", *, like=None): return ivy.ones(shape, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def ones_like(a, dtype=None, order="K", subok=True, shape=None): if shape: return ivy.ones(shape, dtype=dtype) @@ -47,13 +47,13 @@ def ones_like(a, dtype=None, order="K", subok=True, shape=None): @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def zeros(shape, dtype=float, order="C", *, like=None): return ivy.zeros(shape, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def zeros_like(a, dtype=None, order="K", subok=True, shape=None): if shape: return ivy.zeros(shape, dtype=dtype) @@ -61,13 +61,13 @@ def zeros_like(a, dtype=None, order="K", subok=True, shape=None): @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def full(shape, fill_value, dtype=None, order="C", *, like=None): return ivy.full(shape, fill_value, dtype=dtype) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def full_like(a, fill_value, dtype=None, order="K", subok=True, shape=None): if shape: return ivy.full(shape, fill_value, dtype=dtype) diff --git a/ivy/functional/frontends/numpy/creation_routines/numerical_ranges.py b/ivy/functional/frontends/numpy/creation_routines/numerical_ranges.py index c80d25cd805dc..c4ec734f6f22b 100644 --- a/ivy/functional/frontends/numpy/creation_routines/numerical_ranges.py +++ b/ivy/functional/frontends/numpy/creation_routines/numerical_ranges.py @@ -1,14 +1,14 @@ # global import ivy from ivy.functional.frontends.numpy.func_wrapper import ( - outputs_to_numpy_arrays, + outputs_to_frontend_arrays, to_ivy_arrays_and_back, handle_numpy_dtype, ) @handle_numpy_dtype -@outputs_to_numpy_arrays +@outputs_to_frontend_arrays def arange(start, stop=None, step=1, dtype=None, *, like=None): return ivy.arange(start, stop, step, dtype=dtype) diff --git a/ivy/functional/frontends/numpy/func_wrapper.py b/ivy/functional/frontends/numpy/func_wrapper.py index 06db92782da1c..f6cdf0bc05d51 100644 --- a/ivy/functional/frontends/numpy/func_wrapper.py +++ b/ivy/functional/frontends/numpy/func_wrapper.py @@ -359,9 +359,9 @@ def _inputs_to_ivy_arrays_np(*args, **kwargs): return _inputs_to_ivy_arrays_np -def outputs_to_numpy_arrays(fn: Callable) -> Callable: +def outputs_to_frontend_arrays(fn: Callable) -> Callable: @functools.wraps(fn) - def _outputs_to_numpy_arrays(*args, order="K", **kwargs): + def _outputs_to_frontend_arrays(*args, order="K", **kwargs): """ Convert `ivy.Array` into `ndarray` instances. @@ -421,8 +421,8 @@ def _outputs_to_numpy_arrays(*args, order="K", **kwargs): order_pos = list(inspect.signature(fn).parameters).index("order") else: contains_order = False - _outputs_to_numpy_arrays.outputs_to_numpy_arrays = True - return _outputs_to_numpy_arrays + _outputs_to_frontend_arrays.outputs_to_frontend_arrays = True + return outputs_to_frontend_arrays def to_ivy_arrays_and_back(fn: Callable) -> Callable: @@ -433,7 +433,7 @@ def to_ivy_arrays_and_back(fn: Callable) -> Callable: instances and return arrays are all converted to `ndarray` instances. """ - return outputs_to_numpy_arrays(inputs_to_ivy_arrays(fn)) + return outputs_to_frontend_arrays(inputs_to_ivy_arrays(fn)) def from_zero_dim_arrays_to_scalar(fn: Callable) -> Callable: diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_func_wrapper.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_func_wrapper.py index a21850d4e6691..7defaf2cc75fc 100644 --- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_func_wrapper.py +++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_func_wrapper.py @@ -7,7 +7,7 @@ import ivy_tests.test_ivy.helpers as helpers from ivy.functional.frontends.numpy.func_wrapper import ( inputs_to_ivy_arrays, - outputs_to_numpy_arrays, + outputs_to_frontend_arrays, to_ivy_arrays_and_back, handle_numpy_dtype, from_zero_dim_arrays_to_scalar, @@ -76,20 +76,20 @@ def test_inputs_to_ivy_arrays(dtype_x_shape): ), dtype=helpers.get_dtypes("valid", none=True, full=False, prune_function=False), ) -def test_outputs_to_numpy_arrays(dtype_and_x, dtype): +def test_outputs_to_frontend_arrays(dtype_and_x, dtype): x_dtype, x = dtype_and_x # check for ivy array input_ivy = ivy.array(x[0], dtype=x_dtype[0]) if not len(input_ivy.shape): scalar_input_ivy = ivy.to_scalar(input_ivy) - outputs_to_numpy_arrays(_fn)( + outputs_to_frontend_arrays(_fn)( scalar_input_ivy, scalar_input_ivy, check_default=True, dtype=dtype ) - outputs_to_numpy_arrays(_fn)( + outputs_to_frontend_arrays(_fn)( scalar_input_ivy, input_ivy, check_default=True, dtype=dtype ) - output = outputs_to_numpy_arrays(_fn)(input_ivy, check_default=True, dtype=dtype) + output = outputs_to_frontend_arrays(_fn)(input_ivy, check_default=True, dtype=dtype) assert isinstance(output, ndarray) assert input_ivy.dtype == output.ivy_array.dtype assert ivy.all(input_ivy == output.ivy_array) From 5ad42bd8e1d5c9b03e23235a8bd577e8929e55d2 Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:41:12 +0100 Subject: [PATCH 17/24] fixed mistake in 66f7e54 --- ivy/functional/frontends/numpy/func_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivy/functional/frontends/numpy/func_wrapper.py b/ivy/functional/frontends/numpy/func_wrapper.py index f6cdf0bc05d51..cda996c7a5df2 100644 --- a/ivy/functional/frontends/numpy/func_wrapper.py +++ b/ivy/functional/frontends/numpy/func_wrapper.py @@ -422,7 +422,7 @@ def _outputs_to_frontend_arrays(*args, order="K", **kwargs): else: contains_order = False _outputs_to_frontend_arrays.outputs_to_frontend_arrays = True - return outputs_to_frontend_arrays + return _outputs_to_frontend_arrays def to_ivy_arrays_and_back(fn: Callable) -> Callable: From d1211d81053e744d6a3d6d1bc95b46ae1c85053c Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:18:16 +0100 Subject: [PATCH 18/24] update torch.Tensor.__bool__ to return frontend array --- ivy/functional/frontends/torch/tensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py index 6342756170c62..4c1737d7c27f4 100644 --- a/ivy/functional/frontends/torch/tensor.py +++ b/ivy/functional/frontends/torch/tensor.py @@ -1015,7 +1015,7 @@ def dot(self, tensor): def __bool__(self): if len(self.shape) == sum(self.shape): - return self.ivy_array.to_scalar().__bool__() + return torch_frontend.tensor(self.ivy_array.to_scalar().__bool__()) raise ValueError( "The truth value of an array with more than one element is ambiguous. " "Use a.any() or a.all()" From 8f03498e77a38dcfcfda7519fc9e195a9b5a0b89 Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:25:26 +0100 Subject: [PATCH 19/24] numpy ndarray __int__ __float__ __complex__ should not return ivy arrays --- ivy/functional/frontends/numpy/ndarray/ndarray.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ivy/functional/frontends/numpy/ndarray/ndarray.py b/ivy/functional/frontends/numpy/ndarray/ndarray.py index 745afb7093cba..7ef9c73bd684b 100644 --- a/ivy/functional/frontends/numpy/ndarray/ndarray.py +++ b/ivy/functional/frontends/numpy/ndarray/ndarray.py @@ -455,17 +455,17 @@ def __lt__(self, value, /): def __int__( self, ): - return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.int64)[0] + return ivy.to_scalar(ivy.reshape(self.ivy_array, (-1,)).astype(ivy.int64)) def __float__( self, ): - return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.float64)[0] + return ivy.to_scalar(ivy.reshape(self.ivy_array, (-1,)).astype(ivy.float64)) def __complex__( self, ): - return ivy.array(ivy.reshape(self.ivy_array, (-1,)), dtype=ivy.complex128)[0] + return ivy.to_scalar(ivy.reshape(self.ivy_array, (-1,)).astype(ivy.complex128)) def __contains__(self, key, /): return key in ivy.reshape(self.ivy_array, -1) From 5c763687844db90c6786e8ef203697e14410848f Mon Sep 17 00:00:00 2001 From: Ziad Amerr <70425741+ZiadAmerr@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:25:58 +0300 Subject: [PATCH 20/24] Fixed gradient computation in Regressor example in README.rst --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index a25b8492472c0..7773fe2a1fdd5 100644 --- a/README.rst +++ b/README.rst @@ -285,7 +285,8 @@ but this can easily be changed to your favorite framework, such as TensorFlow, o y = 0.2 * x ** 2 + 0.5 * x + 0.1 + noise - def loss_fn(pred, target): + def loss_fn(v, x, target): + pred = model(x, v=v) return ivy.mean((pred - target) ** 2) for epoch in range(40): @@ -293,7 +294,7 @@ but this can easily be changed to your favorite framework, such as TensorFlow, o pred = model(x) # compute loss and gradients - loss, grads = ivy.execute_with_gradients(lambda v: loss_fn(pred, y), model.v) + loss, grads = ivy.execute_with_gradients(lambda params: loss_fn(*params), (model.v, x, y), xs_grad_idxs=[[0]]) # update parameters model.v = optimizer.step(model.v, grads) From 9d0b8e0c5d716f95885572cad27297ffb5670f9e Mon Sep 17 00:00:00 2001 From: Tom Edwards <49121269+tomatillos@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:47:16 +0100 Subject: [PATCH 21/24] Add __iter__ method to Sequential (#18948) --- ivy/stateful/sequential.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ivy/stateful/sequential.py b/ivy/stateful/sequential.py index e73f40cd9c3b1..e43ec4f7b5eb1 100644 --- a/ivy/stateful/sequential.py +++ b/ivy/stateful/sequential.py @@ -45,9 +45,12 @@ def __init__( self._submodules = list(sub_modules) Module.__init__(self, device=device, v=v, dtype=dtype) + def __iter__(self): + return iter(self._submodules) + def _forward(self, inputs): """ - Perform forward pass of the Linear layer. + Perform forward pass of the Sequential container. Parameters ---------- @@ -57,7 +60,7 @@ def _forward(self, inputs): Returns ------- ret - The outputs following the linear operation and bias addition. + The output after each of the layers in the Sequential has been applied. """ x = inputs for i, submod in enumerate(self._submodules): From fcfea5f8b4155472629e0cd56a42da955a004a90 Mon Sep 17 00:00:00 2001 From: Aadya Chinubhai <77720426+aadya940@users.noreply.github.com> Date: Mon, 10 Jul 2023 18:55:52 +0530 Subject: [PATCH 22/24] ENH: Add softplus to paddle frontend (#18286) Co-authored-by: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> --- .../paddle/nn/functional/activation.py | 6 +++++ .../test_functional/test_paddle_activation.py | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ivy/functional/frontends/paddle/nn/functional/activation.py b/ivy/functional/frontends/paddle/nn/functional/activation.py index dec1dbefb4ff8..d9be530affa25 100644 --- a/ivy/functional/frontends/paddle/nn/functional/activation.py +++ b/ivy/functional/frontends/paddle/nn/functional/activation.py @@ -211,6 +211,12 @@ def mish(x, name=None): return ivy.mish(x) +@with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") +@to_ivy_arrays_and_back +def softplus(x, beta=1, threshold=20, name=None): + return ivy.softplus(x, beta=beta, threshold=threshold) + + @with_supported_dtypes({"2.4.2 and below": ("float32", "float64")}, "paddle") @to_ivy_arrays_and_back def leaky_relu(x, negative_slope=0.01, name=None): diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_paddle_activation.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_paddle_activation.py index d6b1030ee98e8..9424e70712e29 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_paddle_activation.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_nn/test_functional/test_paddle_activation.py @@ -515,7 +515,33 @@ def test_paddle_mish( x=x[0], ) + +@handle_frontend_test( + fn_tree="paddle.nn.functional.softplus", + dtype_and_input=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + min_num_dims=1, + ), +) +def test_paddle_softplus( + *, + dtype_and_input, + on_device, + fn_tree, + frontend, + test_flags, +): + input_dtype, x = dtype_and_input + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + ) + @handle_frontend_test( fn_tree="paddle.nn.functional.leaky_relu", dtype_and_x=helpers.dtype_and_values( From dfd491b8b71798726a24e3ae5aacf0b87de9b5ba Mon Sep 17 00:00:00 2001 From: AnnaTz <111577222+AnnaTz@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:49:57 +0100 Subject: [PATCH 23/24] modify paddle tensor methods to return frontend arrays --- .../frontends/paddle/tensor/tensor.py | 136 ++++++++++-------- 1 file changed, 77 insertions(+), 59 deletions(-) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 9d4d07745e08a..353a88fd0df3d 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -98,7 +98,7 @@ def abs(self): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def acosh(self, name=None): - return ivy.acosh(self._ivy_array) + return paddle_frontend.Tensor(ivy.acosh(self._ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def ceil(self): @@ -106,64 +106,67 @@ def ceil(self): @with_unsupported_dtypes({"2.5.0 and below": ("float16",)}, "paddle") def asinh(self, name=None): - return ivy.asinh(self._ivy_array) + return paddle_frontend.Tensor(ivy.asinh(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def asin(self, name=None): - return ivy.asin(self._ivy_array) + return paddle_frontend.Tensor(ivy.asin(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def cosh(self, name=None): - return ivy.cosh(self._ivy_array) + return paddle_frontend.Tensor(ivy.cosh(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def log(self, name=None): - return ivy.log(self._ivy_array) + return paddle_frontend.Tensor(ivy.log(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def sin(self, name=None): - return ivy.sin(self._ivy_array) + return paddle_frontend.Tensor(ivy.sin(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def sinh(self, name=None): - return ivy.sinh(self._ivy_array) + return paddle_frontend.Tensor(ivy.sinh(self._ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def argmax(self, axis=None, keepdim=False, dtype=None, name=None): - return ivy.argmax(self._ivy_array, axis=axis, keepdims=keepdim, dtype=dtype) + return paddle_frontend.Tensor( + ivy.argmax(self._ivy_array, axis=axis, keepdims=keepdim, dtype=dtype) + ) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def sqrt(self, name=None): - return ivy.sqrt(self._ivy_array) + return paddle_frontend.Tensor(ivy.sqrt(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def cos(self, name=None): - return ivy.cos(self._ivy_array) + return paddle_frontend.Tensor(ivy.cos(self._ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def exp(self, name=None): - return ivy.exp(self._ivy_array) + return paddle_frontend.Tensor(ivy.exp(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def erf(self, name=None): - return ivy.erf(self._ivy_array) + return paddle_frontend.Tensor(ivy.erf(self._ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def subtract(self, y, name=None): - y_ivy = _to_ivy_array(y) - return ivy.subtract(self._ivy_array, y_ivy) + return paddle_frontend.Tensor(ivy.subtract(self._ivy_array, _to_ivy_array(y))) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def log10(self, name=None): - return ivy.log10(self._ivy_array) + return paddle_frontend.Tensor(ivy.log10(self._ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def argsort(self, axis=-1, descending=False, name=None): - return ivy.argsort(self._ivy_array, axis=axis, descending=descending) + return paddle_frontend.Tensor( + ivy.argsort(self._ivy_array, axis=axis, descending=descending) + ) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def floor(self, name=None): - return ivy.floor(self._ivy_array) + return paddle_frontend.Tensor(ivy.floor(self._ivy_array)) @with_supported_dtypes( {"2.5.0 and below": ("float32", "float64", "int32", "int64")}, "paddle" @@ -178,37 +181,39 @@ def clip(self, min=None, max=None, name=None): message="at most one of min or max can be None", ) if min is None: - return ivy.minimum(self._ivy_array, max) - if max is None: - return ivy.maximum(self._ivy_array, min) - return ivy.clip(self._ivy_array, min, max) + ret = ivy.minimum(self._ivy_array, max) + elif max is None: + ret = ivy.maximum(self._ivy_array, min) + else: + ret = ivy.clip(self._ivy_array, min, max) + return paddle_frontend.Tensor(ret) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def floor_(self): - return ivy.floor(self._ivy_array) + return paddle_frontend.Tensor(ivy.floor(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def tanh(self, name=None): - return ivy.tanh(self._ivy_array) + return paddle_frontend.Tensor(ivy.tanh(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def add_(self, name=None): - return ivy.add(self._ivy_array) + return paddle_frontend.Tensor(ivy.add(self._ivy_array)) @with_supported_dtypes( {"2.5.0 and below": ("float16", "float32", "float64", "int32", "int64")}, "paddle", ) def isinf(self, name=None): - return ivy.isinf(self._ivy_array) + return paddle_frontend.Tensor(ivy.isinf(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def square(self, name=None): - return ivy.square(self._ivy_array) + return paddle_frontend.Tensor(ivy.square(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def cholesky(self, upper=False, name=None): - return ivy.cholesky(self._ivy_array, upper=upper) + return paddle_frontend.Tensor(ivy.cholesky(self._ivy_array, upper=upper)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def multiply(self, y, name=None): @@ -219,21 +224,27 @@ def multiply(self, y, name=None): "paddle", ) def isfinite(self, name=None): - return ivy.isfinite(self._ivy_array) + return paddle_frontend.Tensor(ivy.isfinite(self._ivy_array)) @with_supported_dtypes({"2.4.2 and below": ("float16", "bfloat16")}, "paddle") def all(self, axis=None, keepdim=False, dtype=None, name=None): - return ivy.all(self.ivy_array, axis=axis, keepdims=keepdim, dtype=dtype) + return paddle_frontend.Tensor( + ivy.all(self.ivy_array, axis=axis, keepdims=keepdim, dtype=dtype) + ) @with_supported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def allclose(self, other, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): - return ivy.allclose( - self._ivy_array, other, rtol=rtol, atol=atol, equal_nan=equal_nan + return paddle_frontend.Tensor( + ivy.allclose( + self._ivy_array, other, rtol=rtol, atol=atol, equal_nan=equal_nan + ) ) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sort(self, axis=-1, descending=False, name=None): - return ivy.sort(self._ivy_array, axis=axis, descending=descending) + return paddle_frontend.Tensor( + ivy.sort(self._ivy_array, axis=axis, descending=descending) + ) @with_supported_dtypes( { @@ -277,18 +288,20 @@ def bitwise_xor(self, y, out=None, name=None): @with_supported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def any(self, axis=None, keepdim=False, name=None): - return ivy.any(self._ivy_array, axis=axis, keepdims=keepdim) + return paddle_frontend.Tensor( + ivy.any(self._ivy_array, axis=axis, keepdims=keepdim) + ) @with_supported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def astype(self, dtype): - return ivy.astype(self._ivy_array, dtype=dtype) + return paddle_frontend.Tensor(ivy.astype(self._ivy_array, dtype=dtype)) @with_supported_dtypes( {"2.5.0 and below": ("bool", "uint8", "int8", "int16", "int32", "int64")}, "paddle", ) def bitwise_not(self, out=None, name=None): - return ivy.bitwise_invert(self._ivy_array, out=out) + return paddle_frontend.Tensor(ivy.bitwise_invert(self._ivy_array, out=out)) @with_supported_dtypes( { @@ -347,7 +360,7 @@ def greater_than(self, y, name=None): @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def rsqrt(self, name=None): - return ivy.reciprocal(ivy.sqrt(self._ivy_array)) + return paddle_frontend.Tensor(ivy.reciprocal(ivy.sqrt(self._ivy_array))) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def reciprocal(self, name=None): @@ -392,18 +405,22 @@ def less_than(self, y, name=None): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def cumprod(self, dim=None, dtype=None, name=None): - return ivy.cumprod(self._ivy_array, axis=dim, dtype=dtype) + return paddle_frontend.Tensor( + ivy.cumprod(self._ivy_array, axis=dim, dtype=dtype) + ) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def cumsum(self, axis=None, dtype=None, name=None): - return ivy.cumsum(self._ivy_array, axis=axis, dtype=dtype) + return paddle_frontend.Tensor( + ivy.cumsum(self._ivy_array, axis=axis, dtype=dtype) + ) @with_supported_dtypes( {"2.5.0 and below": ("complex64", "complex128", "float32", "float64")}, "paddle", ) def angle(self, name=None): - return ivy.angle(self._ivy_array) + return paddle_frontend.Tensor(ivy.angle(self._ivy_array)) @with_unsupported_dtypes( { @@ -422,7 +439,7 @@ def equal(self, y, name=None): @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def rad2deg(self, name=None): - return ivy.rad2deg(self._ivy_array) + return paddle_frontend.Tensor(ivy.rad2deg(self._ivy_array)) @with_unsupported_dtypes( { @@ -438,41 +455,41 @@ def rad2deg(self, name=None): "paddle", ) def equal_all(self, y, name=None): - y_ivy = _to_ivy_array(y) - return ivy.array_equal(self._ivy_array, y_ivy) + return paddle_frontend.Tensor( + ivy.array_equal(self._ivy_array, _to_ivy_array(y)) + ) @with_unsupported_dtypes({"2.5.0 and below": "bfloat16"}, "paddle") def fmax(self, y, name=None): - y_ivy = _to_ivy_array(y) - return ivy.fmax(self._ivy_array, y_ivy) + return paddle_frontend.Tensor(ivy.fmax(self._ivy_array, _to_ivy_array(y))) @with_unsupported_dtypes({"2.5.0 and below": "bfloat16"}, "paddle") def fmin(self, y, name=None): - y_ivy = _to_ivy_array(y) - return ivy.fmin(self._ivy_array, y_ivy) + return paddle_frontend.Tensor(ivy.fmin(self._ivy_array, _to_ivy_array(y))) @with_supported_dtypes( {"2.5.0 and below": ("float32", "float64", "int32", "int64")}, "paddle" ) def minimum(self, y, name=None): - y_ivy = _to_ivy_array(y) - return ivy.minimum(self._ivy_array, y_ivy) + return paddle_frontend.Tensor(ivy.minimum(self._ivy_array, _to_ivy_array(y))) @with_supported_dtypes( {"2.5.0 and below": ("float32", "float64", "int32", "int64")}, "paddle" ) def max(self, axis=None, keepdim=False, name=None): - return ivy.max(self._ivy_array, axis=axis, keepdims=keepdim) + return paddle_frontend.Tensor( + ivy.max(self._ivy_array, axis=axis, keepdims=keepdim) + ) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def deg2rad(self, name=None): - return ivy.deg2rad(self._ivy_array) + return paddle_frontend.Tensor(ivy.deg2rad(self._ivy_array)) @with_supported_dtypes( {"2.5.0 and below": ("float32", "float64", "int32", "int64", "bool")}, "paddle" ) def rot90(self, k=1, axes=(0, 1), name=None): - return ivy.rot90(self._ivy_array, k=k, axes=axes) + return paddle_frontend.Tensor(ivy.rot90(self._ivy_array, k=k, axes=axes)) @with_supported_dtypes( {"2.5.0 and below": ("complex64", "complex128")}, @@ -500,8 +517,9 @@ def isclose(self, y, rtol=1e-05, atol=1e-08, equal_nan=False, name=None): @with_supported_dtypes({"2.5.0 and below": ("int32", "int64")}, "paddle") def floor_divide(self, y, name=None): - y_ivy = y._ivy_array if isinstance(y, Tensor) else _to_ivy_array(y) - return ivy.floor_divide(self._ivy_array, y_ivy) + return paddle_frontend.Tensor( + ivy.floor_divide(self._ivy_array, _to_ivy_array(y)) + ) # cond @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") @@ -510,11 +528,11 @@ def cond(self, p=None, name=None): @with_unsupported_dtypes({"2.4.2 and below": ("int16", "float16")}, "paddle") def conj(self, name=None): - return ivy.conj(self._ivy_array) + return paddle_frontend.Tensor(ivy.conj(self._ivy_array)) @with_supported_dtypes({"2.5.0 and below": ("float32", "float64")}, "paddle") def log2(self, name=None): - return ivy.log2(self._ivy_array) + return paddle_frontend.Tensor(ivy.log2(self._ivy_array)) @with_unsupported_dtypes( {"2.4.2 and below": ("float32", "float64", "int32", "int64")}, "paddle" @@ -537,15 +555,15 @@ def neg(self, name=None): "paddle", ) def logical_not(self, out=None, name=None): - return ivy.logical_not(self.ivy_array) + return paddle_frontend.Tensor(ivy.logical_not(self.ivy_array)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sign(self, name=None): - return ivy.sign(self._ivy_array, np_variant=False) + return paddle_frontend.Tensor(ivy.sign(self._ivy_array, np_variant=False)) @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") def sgn(self, name=None): - return ivy.sign(self._ivy_array, np_variant=True) + return paddle_frontend.Tensor(ivy.sign(self._ivy_array, np_variant=True)) def tolist(self): - return ivy.to_list(self._ivy_array) \ No newline at end of file + return paddle_frontend.Tensor(ivy.to_list(self._ivy_array)) From 092986b304b0b0d1585c1fbd000fc4ba19f9fea7 Mon Sep 17 00:00:00 2001 From: Selvaraj Sembulingam Date: Mon, 10 Jul 2023 19:32:23 +0530 Subject: [PATCH 24/24] added repo name (#18625) --- docs/partial_conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/partial_conf.py b/docs/partial_conf.py index d029067164aeb..ec73b869265f1 100644 --- a/docs/partial_conf.py +++ b/docs/partial_conf.py @@ -49,3 +49,5 @@ from docs.conf import html_theme_options html_theme_options["switcher"]["json_url"] = "https://unify.ai/docs/versions/ivy.json" + +repo_name = "ivy"