From dbfed2c3005a44d4912382517173a7861b9a51bb Mon Sep 17 00:00:00 2001 From: Yash Jindal Date: Fri, 4 Aug 2023 15:27:25 +0530 Subject: [PATCH 1/4] added function and test(test as comment) --- .../mindspore/ops/function/nn_func.py | 19 ++++++++++++++ .../test_function/test_mindspore_nn_func.py | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/ivy/functional/frontends/mindspore/ops/function/nn_func.py b/ivy/functional/frontends/mindspore/ops/function/nn_func.py index 2035dad6f7343..900351730c578 100644 --- a/ivy/functional/frontends/mindspore/ops/function/nn_func.py +++ b/ivy/functional/frontends/mindspore/ops/function/nn_func.py @@ -36,3 +36,22 @@ def selu(input_x): @to_ivy_arrays_and_back def softsign(x): return ivy.divide(x, ivy.add(1, ivy.abs(x))) + + +@with_supported_dtypes( + { + "2.0.0 and below": ( + "int8", + "int16", + "int32", + "int64", + "float16", + "float32", + "float64", + ) + }, + "mindspore", +) +@to_ivy_arrays_and_back +def hardswish(x): + return ivy.hardswish(x) diff --git a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py index 73851ad1f7343..ba92860ad9ba7 100644 --- a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py +++ b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py @@ -77,3 +77,29 @@ # on_device=on_device, # x=x[0], # ) +# +# +# hardswish +# @handle_frontend_test( +# fn_tree="mindspore.ops.function.nn_func.hardswish", +# dtype_and_x=helpers.dtype_and_values( +# available_dtypes=helpers.get_dtypes("valid"), +# ), +# ) +# def test_mindspore_hardswish( +# *, +# 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 e6f68fad91796a11bcc3aade046a4768409ce477 Mon Sep 17 00:00:00 2001 From: Yash Jindal Date: Sun, 6 Aug 2023 16:05:53 +0530 Subject: [PATCH 2/4] formatting --- .../frontends/mindspore/ops/function/nn_func.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ivy/functional/frontends/mindspore/ops/function/nn_func.py b/ivy/functional/frontends/mindspore/ops/function/nn_func.py index 165d5a43c4e51..d192943c72c0a 100644 --- a/ivy/functional/frontends/mindspore/ops/function/nn_func.py +++ b/ivy/functional/frontends/mindspore/ops/function/nn_func.py @@ -56,8 +56,21 @@ def softsign(x): def hardswish(x): return ivy.hardswish(x) - -@with_supported_dtypes({"2.0 and below": ("int8", "int16", "int32", "int64", "float16", "float32", "float64")}, "mindspore") + +@with_supported_dtypes( + { + "2.0 and below": ( + "int8", + "int16", + "int32", + "int64", + "float16", + "float32", + "float64", + ) + }, + "mindspore", +) @to_ivy_arrays_and_back def pad(input, pad_width, mode="constant", constant_values=0): return ivy.pad(input, pad_width, mode=mode, constant_values=constant_values) From 54dced5842af993b6a05a7c954b259e55d5d68ec Mon Sep 17 00:00:00 2001 From: Yash Jindal <57638523+yashj8@users.noreply.github.com> Date: Sun, 6 Aug 2023 16:14:37 +0530 Subject: [PATCH 3/4] formatting --- .../test_ops/test_function/test_mindspore_nn_func.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py index 876252f9c4c21..062354ed396bf 100644 --- a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py +++ b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py @@ -77,8 +77,8 @@ # on_device=on_device, # x=x[0], # ) -# -# + + # hardswish # @handle_frontend_test( # fn_tree="mindspore.ops.function.nn_func.hardswish", @@ -163,9 +163,6 @@ # input_dtypes=input_dtype, # frontend=frontend, # test_flags=test_flags, -# fn_tree=fn_tree, -# on_device=on_device, -# x=x[0], # on_device=on_device, # fn_tree=fn_tree, # x=x[0], From eb051803ae1402a0f9a01f668cd7d75d29b6b601 Mon Sep 17 00:00:00 2001 From: Yash Jindal <57638523+yashj8@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:06:31 +0530 Subject: [PATCH 4/4] completed test --- .../test_function/test_mindspore_nn_func.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py index 062354ed396bf..cf984a15cd20c 100644 --- a/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py +++ b/ivy_tests/test_ivy/test_frontends/test_mindspore/test_ops/test_function/test_mindspore_nn_func.py @@ -89,6 +89,20 @@ # def test_mindspore_hardswish( # *, # 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], +# ) # pad