diff options
author | Michalis Spyrou <michalis.spyrou@arm.com> | 2018-11-20 12:39:47 +0000 |
---|---|---|
committer | Michalis Spyrou <michalis.spyrou@arm.com> | 2018-11-20 14:56:11 +0000 |
commit | 8f2cbfa15bfb0e49ca6a334a220f0e36964289d6 (patch) | |
tree | 25d292198b85c3d131d288814e92b998b423a06e | |
parent | 8773d7cec5a22dd39305206072a496eb2548968b (diff) | |
download | ComputeLibrary-8f2cbfa15bfb0e49ca6a334a220f0e36964289d6.tar.gz |
COMPMID-1451: Fix CLBatchToSpace static validation method
Change-Id: I770b044b67d93510ef65e556905135b34be7ea0a
-rw-r--r-- | src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp | 19 | ||||
-rw-r--r-- | tests/validation/CL/BatchToSpaceLayer.cpp | 16 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp b/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp index 8f56f66845..58a8d104c0 100644 --- a/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp +++ b/src/core/CL/kernels/CLBatchToSpaceLayerKernel.cpp @@ -55,18 +55,19 @@ Status validate_arguments_static(const ITensorInfo *input, const int block_shape ARM_COMPUTE_RETURN_ERROR_ON(block_shape_x <= 0); ARM_COMPUTE_RETURN_ERROR_ON(block_shape_y <= 0); + 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) { - const DataLayout data_layout = input->data_layout(); - const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); - 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); - const int idx_batch = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES); - ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape()[idx_width] != (block_shape_x * output->tensor_shape()[idx_width])); - ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape()[idx_height] != (block_shape_x * output->tensor_shape()[idx_height])); - ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape()[idx_channel] != output->tensor_shape()[idx_channel]); - ARM_COMPUTE_RETURN_ERROR_ON(output->tensor_shape()[idx_batch] % (block_shape_x * block_shape_y) != 0); + const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); + 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_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/validation/CL/BatchToSpaceLayer.cpp b/tests/validation/CL/BatchToSpaceLayer.cpp index db96571f1d..93fccf002b 100644 --- a/tests/validation/CL/BatchToSpaceLayer.cpp +++ b/tests/validation/CL/BatchToSpaceLayer.cpp @@ -91,17 +91,17 @@ DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( ARM_COMPUTE_EXPECT(has_error == expected, framework::LogLevel::ERRORS); } DATA_TEST_CASE(ValidateStatic, framework::DatasetMode::ALL, zip(zip(zip(zip( - framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), - TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), // Mismatching data types - TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32), // Negative block shapes - TensorInfo(TensorShape(32U, 16U, 2U, 1U, 4U), 1, DataType::F32), // Wrong tensor shape + framework::dataset::make("InputInfo", { TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), + 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("OutputInfo",{ TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), - TensorInfo(TensorShape(32U, 8U, 2U, 4U), 1, DataType::F16), - TensorInfo(TensorShape(32U, 8U, 2U, 4U), 1, DataType::F32), - TensorInfo(TensorShape(32U, 8U, 2U, 4U), 1, DataType::F32), + framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 16U, 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})), input_info, block_shape_x, block_shape_y, output_info, expected) |