From 704c22f1373e1276acb43c71e7e17048271bbc03 Mon Sep 17 00:00:00 2001 From: Adnan AlSinan Date: Tue, 24 Oct 2023 11:05:56 +0100 Subject: [GPU] Update Reverse layer to allow negative axis and reversed axis order - Adds option to use negative axis and inverted axis. - Adds validation tests for the above. Resolves COMPMID-6459 Change-Id: I88afd845d078f92c82ec8529ce7241fccd4c417e Signed-off-by: Adnan AlSinan Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10523 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: Viet-Hoa Do Benchmark: Arm Jenkins --- tests/validation/CL/Reverse.cpp | 29 ++++++++++++++-------------- tests/validation/fixtures/ReverseFixture.h | 31 +----------------------------- 2 files changed, 16 insertions(+), 44 deletions(-) (limited to 'tests') diff --git a/tests/validation/CL/Reverse.cpp b/tests/validation/CL/Reverse.cpp index ff46ba64ad..82effc2136 100644 --- a/tests/validation/CL/Reverse.cpp +++ b/tests/validation/CL/Reverse.cpp @@ -44,7 +44,7 @@ namespace validation using framework::dataset::make; namespace { -auto run_small_dataset = combine(datasets::SmallShapes(), datasets::Tiny1DShapes()); +auto run_small_dataset = combine(datasets::Small3DShapes(), datasets::Tiny1DShapes()); auto run_large_dataset = combine(datasets::LargeShapes(), datasets::Tiny1DShapes()); } // namespace @@ -80,7 +80,8 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( { Status s = CLReverse::validate(&src_info.clone()->set_is_resizable(false), &dst_info.clone()->set_is_resizable(false), - &axis_info.clone()->set_is_resizable(false)); + &axis_info.clone()->set_is_resizable(false), + false); ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS); } // clang-format on @@ -97,8 +98,8 @@ FIXTURE_DATA_TEST_CASE(RunSmall, combine( run_small_dataset, make("DataType", DataType::F16), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); @@ -110,8 +111,8 @@ FIXTURE_DATA_TEST_CASE(RunLarge, combine( run_large_dataset, make("DataType", DataType::F16), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); @@ -125,8 +126,8 @@ FIXTURE_DATA_TEST_CASE(RunSmall, combine( run_small_dataset, make("DataType", DataType::F32), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); @@ -138,8 +139,8 @@ FIXTURE_DATA_TEST_CASE(RunLarge, combine( run_large_dataset, make("DataType", DataType::F32), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); @@ -155,8 +156,8 @@ FIXTURE_DATA_TEST_CASE(RunSmall, combine( run_small_dataset, make("DataType", DataType::QASYMM8), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); @@ -168,8 +169,8 @@ FIXTURE_DATA_TEST_CASE(RunLarge, combine( run_large_dataset, make("DataType", DataType::QASYMM8), - make("use_negative_axis", { false }), - make("use_inverted_axis", { false }))) + make("use_negative_axis", { true, false }), + make("use_inverted_axis", { true, false }))) { // Validate output validate(CLAccessor(_target), _reference); diff --git a/tests/validation/fixtures/ReverseFixture.h b/tests/validation/fixtures/ReverseFixture.h index d53945191e..856bff7b12 100644 --- a/tests/validation/fixtures/ReverseFixture.h +++ b/tests/validation/fixtures/ReverseFixture.h @@ -27,9 +27,6 @@ #include "arm_compute/core/Helpers.h" #include "arm_compute/core/TensorShape.h" #include "arm_compute/core/Types.h" -#ifdef ARM_COMPUTE_OPENCL_ENABLED -#include "arm_compute/runtime/CL/functions/CLReverse.h" -#endif // ARM_COMPUTE_OPENCL_ENABLED #include "arm_compute/runtime/Tensor.h" #include "tests/AssetsLibrary.h" #include "tests/Globals.h" @@ -44,31 +41,6 @@ namespace test { namespace validation { -namespace -{ -template -#ifdef ARM_COMPUTE_OPENCL_ENABLED -std::enable_if_t < !std::is_same::value, void > -#else // ARM_COMPUTE_OPENCL_ENABLED -void -#endif // ARM_COMPUTE_OPENCL_ENABLED -configureReverse(ReverseFunction &func, TensorType &src, TensorType &axis, TensorType &dst, bool use_inverted_axis) -{ - func.configure(&src, &dst, &axis, use_inverted_axis); -} - -#ifdef ARM_COMPUTE_OPENCL_ENABLED -template -std::enable_if_t::value, void> -configureReverse(ReverseFunction &func, TensorType &src, TensorType &axis, TensorType &dst, bool use_inverted_axis) -{ - ARM_COMPUTE_UNUSED(use_inverted_axis); - func.configure(&src, &dst, &axis); -} - -#endif // ARM_COMPUTE_OPENCL_ENABLED -} //namespace - template class ReverseValidationFixture : public framework::Fixture { @@ -113,8 +85,7 @@ protected: // Create and configure function FunctionType reverse_func; - - configureReverse(reverse_func, src, axis, dst, use_inverted_axis); + reverse_func.configure(&src, &dst, &axis, use_inverted_axis); ARM_COMPUTE_ASSERT(src.info()->is_resizable()); ARM_COMPUTE_ASSERT(axis.info()->is_resizable()); -- cgit v1.2.1