From 4ffc7bba601654e7b60089b164e8ff008b640a33 Mon Sep 17 00:00:00 2001 From: Akshay Venkataraman Date: Thu, 13 Jul 2023 23:12:15 +0530 Subject: [PATCH] max function for paddle frontend and the corresponding test (#18339) --- .../frontends/paddle/tensor/math.py | 8 +++++ .../test_paddle/test_tensor/test_math.py | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ivy/functional/frontends/paddle/tensor/math.py b/ivy/functional/frontends/paddle/tensor/math.py index 20ac879926058..b2d07b90cccdb 100644 --- a/ivy/functional/frontends/paddle/tensor/math.py +++ b/ivy/functional/frontends/paddle/tensor/math.py @@ -338,3 +338,11 @@ def maximum(x, y, name=None): @to_ivy_arrays_and_back def frac(x, name=None): return x - ivy.sign(x) * ivy.floor(ivy.abs(x)) + + +@with_supported_dtypes( + {"2.5.0 and below": ("float32", "float64", "int32", "int64")}, "paddle" +) +@to_ivy_arrays_and_back +def max(x, axis=None, keepdim=False, name=None): + return ivy.max(x, axis=axis, keepdims=keepdim) 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 72d2745186e12..df64ac4b3bc03 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 @@ -1409,3 +1409,35 @@ def test_paddle_frac( on_device=on_device, x=x[0], ) + + +# max +@handle_frontend_test( + fn_tree="paddle.tensor.math.max", + dtype_and_x=helpers.dtype_values_axis( + available_dtypes=helpers.get_dtypes("valid"), + min_axis=-1, + max_axis=0, + min_num_dims=1, + force_int_axis=False, + ), +) +def test_paddle_max( + *, + dtype_and_x, + on_device, + fn_tree, + frontend, + test_flags, +): + input_dtype, x, axis = 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], + axis=axis, + keepdim=False, + )