From 35767bc09f21050a9767a91b086b327afc928a81 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Wed, 5 Dec 2018 17:36:30 +0000 Subject: COMPMID-1697: NEPermute extended support for more cases. Regardless the input data layout NEPermute function has been added support for the all the permutations of 4d tensors Added corresponding validation tests. Change-Id: I0f8f20c2c3716e908a18a59783be53efab80ef5b Reviewed-on: https://review.mlplatform.org/367 Reviewed-by: Giuseppe Rossini Tested-by: Arm Jenkins --- tests/validation/CL/Permute.cpp | 14 +++++-- tests/validation/CPP/Permute.cpp | 39 ++++++++++++++----- tests/validation/NEON/Permute.cpp | 61 ++++++++++++++++++++++++------ tests/validation/fixtures/PermuteFixture.h | 18 ++++----- 4 files changed, 97 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/validation/CL/Permute.cpp b/tests/validation/CL/Permute.cpp index 1371e717e7..a75b8cf9cd 100644 --- a/tests/validation/CL/Permute.cpp +++ b/tests/validation/CL/Permute.cpp @@ -42,10 +42,16 @@ namespace validation { namespace { -const auto PermuteParametersSmall = combine(datasets::Small4DShapes(), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U), PermutationVector(3U, 2U, 0U, 1U) })); -const auto PermuteParametersLarge = combine(datasets::Large4DShapes(), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U), PermutationVector(3U, 2U, 0U, 1U) })); +const auto PermuteVectors = framework::dataset::make("PermutationVector", +{ + PermutationVector(2U, 0U, 1U), + PermutationVector(1U, 2U, 0U), + PermutationVector(3U, 2U, 0U, 1U) +}); +const auto PermuteInputLayout = framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }); +const auto PermuteParametersSmall = concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()) * PermuteInputLayout * PermuteVectors; +const auto PermuteParametersLarge = datasets::Large4DShapes() * PermuteInputLayout * PermuteVectors; + } // namespace TEST_SUITE(CL) TEST_SUITE(Permute) diff --git a/tests/validation/CPP/Permute.cpp b/tests/validation/CPP/Permute.cpp index 0a97041f81..2ba10ec651 100644 --- a/tests/validation/CPP/Permute.cpp +++ b/tests/validation/CPP/Permute.cpp @@ -42,10 +42,19 @@ namespace validation { namespace { -const auto PermuteParametersSmall = combine(concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U), PermutationVector(3U, 2U, 0U, 1U) })); -const auto PermuteParametersLarge = combine(datasets::Large4DShapes(), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U), PermutationVector(3U, 2U, 0U, 1U) })); +const auto PermuteVectors = framework::dataset::make("PermutationVector", +{ + PermutationVector(2U, 0U, 1U), + PermutationVector(1U, 2U, 0U), + PermutationVector(0U, 1U, 2U), + PermutationVector(0U, 2U, 1U), + PermutationVector(1U, 0U, 2U), + PermutationVector(2U, 1U, 0U), +}); +const auto PermuteInputLayout = framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }); +const auto PermuteParametersSmall = concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()) * PermuteInputLayout * PermuteVectors; +const auto PermuteParametersLarge = datasets::Large4DShapes() * PermuteInputLayout * PermuteVectors; + } // namespace TEST_SUITE(CPP) TEST_SUITE(Permute) @@ -77,25 +86,32 @@ template using CPPPermuteFixture = PermuteValidationFixture; TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U8))) +FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U8)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U8))) + +FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U8)) { // Validate output validate(Accessor(_target), _reference); } + TEST_SUITE_END() TEST_SUITE(U16) -FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U16))) +FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U16)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U16))) + +FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U16)) { // Validate output validate(Accessor(_target), _reference); @@ -103,12 +119,15 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::Dataset TEST_SUITE_END() TEST_SUITE(U32) -FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U32))) +FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U32)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U32))) + +FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U32)) { // Validate output validate(Accessor(_target), _reference); diff --git a/tests/validation/NEON/Permute.cpp b/tests/validation/NEON/Permute.cpp index 8c172ddded..a5a81b7ac3 100644 --- a/tests/validation/NEON/Permute.cpp +++ b/tests/validation/NEON/Permute.cpp @@ -42,10 +42,29 @@ namespace validation { namespace { -const auto PermuteParametersSmall = combine(concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U) })); -const auto PermuteParametersLarge = combine(datasets::Large4DShapes(), - framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U) })); +const auto PermuteVectors3 = framework::dataset::make("PermutationVector", +{ + PermutationVector(2U, 0U, 1U), + PermutationVector(1U, 2U, 0U), + PermutationVector(0U, 1U, 2U), + PermutationVector(0U, 2U, 1U), + PermutationVector(1U, 0U, 2U), + PermutationVector(2U, 1U, 0U), +}); +const auto PermuteVectors4 = framework::dataset::make("PermutationVector", +{ + PermutationVector(3U, 2U, 0U, 1U), + PermutationVector(3U, 2U, 1U, 0U), + PermutationVector(2U, 3U, 1U, 0U), + PermutationVector(1U, 3U, 2U, 0U), + PermutationVector(3U, 1U, 2U, 0U), + PermutationVector(3U, 0U, 2U, 1U), + PermutationVector(0U, 3U, 2U, 1U) +}); +const auto PermuteVectors = concat(PermuteVectors3, PermuteVectors4); +const auto PermuteInputLayout = framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }); +const auto PermuteParametersSmall = concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()) * PermuteInputLayout * PermuteVectors; +const auto PermuteParametersLarge = datasets::Large4DShapes() * PermuteInputLayout * PermuteVectors; } // namespace TEST_SUITE(NEON) TEST_SUITE(Permute) @@ -61,7 +80,11 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( TensorInfo(TensorShape(7U, 7U, 5U, 3U), 1, DataType::U16), // valid TensorInfo(TensorShape(27U, 13U, 37U, 2U), 1, DataType::F32), // valid TensorInfo(TensorShape(7U, 7U, 5U, 3U), 1, DataType::U16), // permutation not supported + TensorInfo(TensorShape(7U, 7U, 5U, 3U), 1, DataType::S16), // permutation not supported TensorInfo(TensorShape(27U, 13U, 37U, 2U), 1, DataType::F32), // permutation not supported + TensorInfo(TensorShape(27U, 13U, 37U, 2U), 1, DataType::F32), // permutation not supported + TensorInfo(TensorShape(27U, 13U, 37U, 2U), 1, DataType::F32) // permutation not supported + }), framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(5U, 7U, 7U, 3U), 1, DataType::U16), @@ -71,7 +94,11 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( TensorInfo(TensorShape(5U, 7U, 7U, 3U), 1, DataType::U16), TensorInfo(TensorShape(13U, 37U, 27U, 2U), 1, DataType::F32), TensorInfo(TensorShape(5U, 7U, 7U, 3U), 1, DataType::U16), + TensorInfo(TensorShape(3U, 5U, 7U, 7U), 1, DataType::S16), TensorInfo(TensorShape(13U, 37U, 27U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(37U, 2U, 13U, 27U), 1, DataType::F32), + TensorInfo(TensorShape(37U, 2U, 13U, 27U), 1, DataType::F32) + })), framework::dataset::make("PermutationVector", { PermutationVector(2U, 1U, 0U), @@ -81,9 +108,12 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U), PermutationVector(3U, 2U, 0U, 1U), - PermutationVector(2U, 3U, 1U, 0U) + PermutationVector(3U, 2U, 0U, 1U), + PermutationVector(2U, 3U, 1U, 0U), + PermutationVector(2U, 3U, 1U, 0U), + PermutationVector(0U, 0U, 0U, 1000U) })), - framework::dataset::make("Expected", { false, false, false, false, true, true, false, false })), + framework::dataset::make("Expected", { true, false, false, false, true, true, false,true, false, true, false })), input_info, output_info, perm_vect, expected) { ARM_COMPUTE_EXPECT(bool(NEPermute::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), perm_vect)) == expected, framework::LogLevel::ERRORS); @@ -118,12 +148,15 @@ template using NEPermuteFixture = PermuteValidationFixture; TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U8))) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U8)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U8))) + +FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U8)) { // Validate output validate(Accessor(_target), _reference); @@ -131,12 +164,14 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMo TEST_SUITE_END() TEST_SUITE(U16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U16))) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U16)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U16))) +FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U16)) { // Validate output validate(Accessor(_target), _reference); @@ -144,12 +179,14 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetM TEST_SUITE_END() TEST_SUITE(U32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U32))) +FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture, framework::DatasetMode::PRECOMMIT, + PermuteParametersSmall * framework::dataset::make("DataType", DataType::U32)) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U32))) +FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture, framework::DatasetMode::NIGHTLY, + PermuteParametersLarge * framework::dataset::make("DataType", DataType::U32)) { // Validate output validate(Accessor(_target), _reference); diff --git a/tests/validation/fixtures/PermuteFixture.h b/tests/validation/fixtures/PermuteFixture.h index 3aae384706..92d01a5654 100644 --- a/tests/validation/fixtures/PermuteFixture.h +++ b/tests/validation/fixtures/PermuteFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -46,10 +46,10 @@ class PermuteValidationFixture : public framework::Fixture { public: template - void setup(TensorShape shape, PermutationVector perm, DataType data_type) + void setup(TensorShape input_shape, DataLayout input_layout, PermutationVector perm, DataType data_type) { - _target = compute_target(shape, data_type, perm); - _reference = compute_reference(shape, data_type, perm); + _target = compute_target(input_shape, input_layout, data_type, perm); + _reference = compute_reference(input_shape, data_type, perm); } protected: @@ -59,14 +59,14 @@ protected: library->fill_tensor_uniform(tensor, 0); } - TensorType compute_target(const TensorShape &shape, DataType data_type, PermutationVector perm) + TensorType compute_target(const TensorShape &input_shape, DataLayout input_layout, DataType data_type, PermutationVector perm) { // Permute shapes - TensorShape output_shape = shape; + TensorShape output_shape = input_shape; permute(output_shape, perm); // Create tensors - TensorType src = create_tensor(shape, data_type); + TensorType src = create_tensor(input_shape, data_type); TensorType dst = create_tensor(output_shape, data_type); // Create and configure function @@ -92,10 +92,10 @@ protected: return dst; } - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, PermutationVector perm) + SimpleTensor compute_reference(const TensorShape &input_shape, DataType data_type, PermutationVector perm) { // Create reference - SimpleTensor src{ shape, data_type }; + SimpleTensor src{ input_shape, data_type }; // Fill reference fill(src); -- cgit v1.2.1