From 0a33a2117018291ff9bb5df5a44e1285aa3f1e41 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Tue, 23 Apr 2019 12:06:19 +0100 Subject: COMPMID-2114: CLBatchToSpace missing validation test Added test cases to exercise block_x != block_y path. Fixed CL back validation test to allow different block values for xy Change-Id: I8c354aceec16d9b16c2f7fcd2cae3f09b747ec0a Signed-off-by: Pablo Tello Reviewed-on: https://review.mlplatform.org/c/1017 Tested-by: Arm Jenkins Reviewed-by: Usama Arif Comments-Addressed: Arm Jenkins Reviewed-by: Michalis Spyrou --- src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp | 4 ++-- src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp | 3 +-- tests/datasets/BatchToSpaceDataset.h | 6 +++++- tests/validation/CL/BatchToSpaceLayer.cpp | 19 +++++++++++++++---- tests/validation/NEON/BatchToSpaceLayer.cpp | 18 ++++++++++++++---- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp b/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp index 58a8d104c0..aa06d3af8c 100644 --- a/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp +++ b/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -66,7 +66,7 @@ Status validate_arguments_static(const ITensorInfo *input, const int block_shape const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); const int idx_channel = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL); ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_width] != (block_shape_x * input->tensor_shape()[idx_width])); - ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_height] != (block_shape_x * input->tensor_shape()[idx_height])); + ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_height] != (block_shape_y * input->tensor_shape()[idx_height])); ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_channel] != input->tensor_shape()[idx_channel]); ARM_COMPUTE_RETURN_ERROR_ON(output->num_dimensions() > 4); ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); diff --git a/src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp b/src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp index 8c24d9fad8..6211abcad0 100644 --- a/src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp +++ b/src/core/NEON/kernels/NEBatchToSpaceLayerKernel.cpp @@ -63,7 +63,6 @@ Status validate_arguments_static(const ITensorInfo *input, const int block_shape const DataLayout data_layout = input->data_layout(); const int idx_batch = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES); ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape()[idx_batch] % (block_shape_x * block_shape_y) != 0); - // Validate output if initialized if(output->total_size() != 0) { @@ -71,7 +70,7 @@ Status validate_arguments_static(const ITensorInfo *input, const int block_shape const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); const int idx_channel = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL); ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_width] != (block_shape_x * input->tensor_shape()[idx_width])); - ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_height] != (block_shape_x * input->tensor_shape()[idx_height])); + ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_height] != (block_shape_y * input->tensor_shape()[idx_height])); ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_channel] != input->tensor_shape()[idx_channel]); ARM_COMPUTE_RETURN_ERROR_ON(output->num_dimensions() > 4); ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); diff --git a/tests/datasets/BatchToSpaceDataset.h b/tests/datasets/BatchToSpaceDataset.h index 63e6214939..7449392ec9 100644 --- a/tests/datasets/BatchToSpaceDataset.h +++ b/tests/datasets/BatchToSpaceDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -117,6 +117,8 @@ public: add_config(TensorShape(1U, 2U, 2U, 4U), TensorShape(2U), TensorShape(2U, 4U, 2U, 1U)); add_config(TensorShape(1U, 3U, 1U, 8U), TensorShape(2U), TensorShape(2U, 6U, 1U, 2U)); add_config(TensorShape(3U, 4U, 1U, 4U), TensorShape(2U), TensorShape(6U, 8U, 1U, 1U)); + add_config(TensorShape(1U, 1U, 1U, 8U), TensorShape(4U, 2U), TensorShape(4U, 2U, 1U, 1U)); + add_config(TensorShape(3U, 1U, 1U, 8U), TensorShape(2U, 4U), TensorShape(6U, 4U, 1U, 1U)); } }; @@ -127,6 +129,8 @@ public: { add_config(TensorShape(64U, 32U, 2U, 4U), TensorShape(2U), TensorShape(128U, 64U, 2U, 1U)); add_config(TensorShape(128U, 16U, 2U, 16U), TensorShape(2U), TensorShape(512U, 64U, 2U, 1U)); + add_config(TensorShape(16U, 8U, 2U, 8U), TensorShape(4U, 2U), TensorShape(64U, 16U, 2U, 1U)); + add_config(TensorShape(8U, 16U, 2U, 8U), TensorShape(2U, 4U), TensorShape(16U, 64U, 2U, 1U)); } }; } // namespace datasets diff --git a/tests/validation/CL/BatchToSpaceLayer.cpp b/tests/validation/CL/BatchToSpaceLayer.cpp index e36663e73d..30b7817f40 100644 --- a/tests/validation/CL/BatchToSpaceLayer.cpp +++ b/tests/validation/CL/BatchToSpaceLayer.cpp @@ -52,21 +52,28 @@ using CLBatchToSpaceLayerFixture = BatchToSpaceLayerValidationFixture blocky + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blocky > blockx TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), // Mismatching data types TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), // Wrong data type block shape TensorInfo(TensorShape(32U, 13U, 2U, 2U, 4U), 1, DataType::F32), // Wrong tensor shape }), framework::dataset::make("BlockShapeInfo",{ TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), + TensorInfo(TensorShape(2U, 4U), 1, DataType::S32), + TensorInfo(TensorShape(4U, 2U), 1, DataType::S32), TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), TensorInfo(TensorShape(2U, 2U), 1, DataType::F16), TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(64U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 32U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F16), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), })), - framework::dataset::make("Expected", { true, false, false, false})), + framework::dataset::make("Expected", { true, true,true, false, false, false})), input_info, block_shape_info, output_info, expected) { bool has_error = bool(CLBatchToSpaceLayer::validate(&input_info.clone()->set_is_resizable(false), &block_shape_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false))); @@ -74,18 +81,22 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( } DATA_TEST_CASE(ValidateStatic, framework::DatasetMode::ALL, zip(zip(zip(zip( framework::dataset::make("InputInfo", { TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blockx > blocky + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blocky > blockx TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Mismatching data types TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Negative block shapes TensorInfo(TensorShape(32U, 16U, 2U, 4U, 4U), 1, DataType::F32), // Wrong tensor shape }), - framework::dataset::make("BlockShapeX", { 2, 2, 2, 2 })), - framework::dataset::make("BlockShapeY", { 2, 2, -2, 2 })), + framework::dataset::make("BlockShapeX", { 2, 4, 2, 2, 2, 2 })), + framework::dataset::make("BlockShapeY", { 2, 2, 4, 2, -2, 2 })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(64U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 32U, 2U, 1U), 1, DataType::F32), TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F16), TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), TensorInfo(TensorShape(32U, 8U, 2U, 1U), 1, DataType::F32), })), - framework::dataset::make("Expected", { true, false, false, false})), + framework::dataset::make("Expected", { true, true,true, false, false, false})), input_info, block_shape_x, block_shape_y, output_info, expected) { bool has_error = bool(CLBatchToSpaceLayer::validate(&input_info.clone()->set_is_resizable(false), block_shape_x, block_shape_y, &output_info.clone()->set_is_resizable(false))); diff --git a/tests/validation/NEON/BatchToSpaceLayer.cpp b/tests/validation/NEON/BatchToSpaceLayer.cpp index 96ea5b8241..b5d684a451 100644 --- a/tests/validation/NEON/BatchToSpaceLayer.cpp +++ b/tests/validation/NEON/BatchToSpaceLayer.cpp @@ -51,21 +51,27 @@ using NEBatchToSpaceLayerFixture = BatchToSpaceLayerValidationFixture blocky + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blocky > blockx TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), // Mismatching data types TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), // Wrong data type block shape TensorInfo(TensorShape(32U, 13U, 2U, 2U, 4U), 1, DataType::F32), // Wrong tensor shape }), framework::dataset::make("BlockShapeInfo",{ TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), + TensorInfo(TensorShape(2U, 4U), 1, DataType::S32), + TensorInfo(TensorShape(4U, 2U), 1, DataType::S32), TensorInfo(TensorShape(2U, 2U), 1, DataType::F16), TensorInfo(TensorShape(2U, 2U), 1, DataType::S32), })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), + TensorInfo(TensorShape(64U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 32U, 2U, 1U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F16), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), })), - framework::dataset::make("Expected", { true, false, false, false})), + framework::dataset::make("Expected", { true, true, true, false, false, false})), input_info, block_shape_info, output_info, expected) { bool has_error = bool(NEBatchToSpaceLayer::validate(&input_info.clone()->set_is_resizable(false), &block_shape_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false))); @@ -73,18 +79,22 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( } DATA_TEST_CASE(ValidateStatic, framework::DatasetMode::ALL, zip(zip(zip(zip( framework::dataset::make("InputInfo", { TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blockx > blocky + TensorInfo(TensorShape(16U, 8U, 2U, 16U), 1, DataType::F32), // blockx != blocky && blocky > blockx TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Mismatching data types TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Negative block shapes TensorInfo(TensorShape(32U, 16U, 2U, 4U, 4U), 1, DataType::F32), // Wrong tensor shape }), - framework::dataset::make("BlockShapeX", { 2, 2, 2, 2 })), - framework::dataset::make("BlockShapeY", { 2, 2, -2, 2 })), + framework::dataset::make("BlockShapeX", { 2, 4, 2, 2, 2, 2 })), + framework::dataset::make("BlockShapeY", { 2, 2, 4, 2, -2, 2 })), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(64U, 16U, 2U, 1U), 1, DataType::F32), + TensorInfo(TensorShape(32U, 32U, 2U, 1U), 1, DataType::F32), TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F16), TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), TensorInfo(TensorShape(32U, 8U, 2U, 1U), 1, DataType::F32), })), - framework::dataset::make("Expected", { true, false, false, false})), + framework::dataset::make("Expected", { true, true, true, false, false, false})), input_info, block_shape_x, block_shape_y, output_info, expected) { bool has_error = bool(NEBatchToSpaceLayer::validate(&input_info.clone()->set_is_resizable(false), block_shape_x, block_shape_y, &output_info.clone()->set_is_resizable(false))); -- cgit v1.2.1