From 9149a0721239da5adac1a9bbc79f277433e1e5cb Mon Sep 17 00:00:00 2001 From: Arsalan ali Date: Mon, 4 Sep 2023 18:04:52 +0500 Subject: [PATCH] Sqrt (#22972) --- .../frontends/paddle/tensor/math.py | 6 ++++ .../test_paddle/test_tensor/test_math.py | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/math.py b/ivy/functional/frontends/paddle/tensor/math.py index d7aa514de3d14..2c1e9e6a708ae 100644 --- a/ivy/functional/frontends/paddle/tensor/math.py +++ b/ivy/functional/frontends/paddle/tensor/math.py @@ -496,6 +496,12 @@ def sqrt(x, name=None): return ivy.sqrt(x) +@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") +@to_ivy_arrays_and_back +def sqrt_(x, name=None): + return ivy.inplace_update(x, sqrt(x)) + + @with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle") @to_ivy_arrays_and_back def square(x, name=None): diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_math.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_math.py index 6d40a70681b3f..2ace5a91b36d6 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_math.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_math.py @@ -2187,6 +2187,34 @@ def test_paddle_sqrt( ) +# sqrt_ +@handle_frontend_test( + fn_tree="paddle.tensor.math.sqrt_", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + ), +) +def test_paddle_sqrt_( + *, + dtype_and_x, + fn_tree, + frontend, + test_flags, + backend_fw, + on_device, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + backend_to_test=backend_fw, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + x=x[0], + ) + + # square @handle_frontend_test( fn_tree="paddle.tensor.math.square",