diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index 42d40604532f0..5123836cef7ec 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -190,6 +190,13 @@ def __iter__(self): ) def __rmul__(self, y, /, name=None): return paddle_frontend.multiply(self, y) + + @with_unsupported_dtypes( + {"2.5.2 and below": ("bool", "unsigned", "int8", "float16", "bfloat16")}, + "paddle", + ) + def __float__(self): + return float(self._ivy_array) # Instance Methods # # ---------------- # diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py index 525de3a57a643..45b147ad42949 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py @@ -868,6 +868,43 @@ def test_paddle_abs( ) +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="__float__", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("numeric"), + max_num_dims=0, + ), +) +def test_paddle__float__( + dtype_and_x, + frontend_method_data, + init_flags, + method_flags, + backend_fw, + frontend, + on_device, +): + input_dtypes, xs = dtype_and_x + # Numpy doesn't support complex to float conversion + assume(not np.issubdtype(input_dtypes[0], np.complexfloating)) + helpers.test_frontend_method( + init_input_dtypes=input_dtypes, + backend_to_test=backend_fw, + method_input_dtypes=input_dtypes, + init_all_as_kwargs_np={ + "object": xs[0], + }, + method_all_as_kwargs_np={}, + frontend=frontend, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + on_device=on_device, + ) + + # acosh @handle_frontend_method( class_tree=CLASS_TREE,