From 67a68caaf5be9638121bd3894efcba41ca9fb4cd Mon Sep 17 00:00:00 2001 From: samthakur587 Date: Tue, 27 Jun 2023 18:49:07 +0530 Subject: [PATCH] added divide method to paddle tensor --- .../frontends/paddle/tensor/tensor.py | 4 +++ .../test_tensor/test_paddle_tensor.py | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/tensor.py b/ivy/functional/frontends/paddle/tensor/tensor.py index a5fd73318a855..17ab2d34a15f0 100644 --- a/ivy/functional/frontends/paddle/tensor/tensor.py +++ b/ivy/functional/frontends/paddle/tensor/tensor.py @@ -276,3 +276,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)) + + @with_unsupported_dtypes({"2.5.0 and below": ("float16", "bfloat16")}, "paddle") + def divide(x, y, name=None): + return paddle_frontend.divide(x, y) 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 7857131272498..f9e86c1bdab54 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 @@ -1448,3 +1448,38 @@ def test_paddle_greater_than( frontend=frontend, on_device=on_device, ) + + +# greater_than +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="paddle.to_tensor", + method_name="divde", + dtypes_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + num_arrays=2, + shared_dtype=True, + safety_factor_scale="log", + small_abs_safety_factor=32, + ), +) +def test_paddle_divide( + dtypes_and_x, + frontend_method_data, + init_flags, + method_flags, + frontend, + on_device, +): + input_dtype, x = dtypes_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={"y": x[1]}, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + on_device=on_device, + )