From 53ffcab088306df35e7d179902c921d4b827a742 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Shubham=20Gupta/SNAP=20/SRI-Bangalore/Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 9 Jan 2019 06:21:25 +0530 Subject: [PATCH] Correction in validation func in CL Host files (#4139) Since ARM_COMPUTE_RETURN_ERROR_ON_MSG() is an "ERROR_ON" macro, which means an error will be thrown if the expression evaluates to "true" Hence, checks need to be inverted. This patch will correct the checks in th following files: 1. CLBatchToSpaceNDKernel.cpp 2. CLDepthToSpaceKernel.cpp 3. CLPadLayerKernel.cpp 4. CLReduceOperationKernel.cpp 5. CLSpaceToDepthKernel.cpp Signed-off-by: shubham --- .../src/core/CL/kernels/CLBatchToSpaceNDKernel.cpp | 14 +++++++------- .../src/core/CL/kernels/CLDepthToSpaceKernel.cpp | 10 +++++----- libs/ARMComputeEx/src/core/CL/kernels/CLPadLayerKernel.cpp | 11 +++++------ .../src/core/CL/kernels/CLReduceOperationKernel.cpp | 2 +- .../src/core/CL/kernels/CLSpaceToDepthKernel.cpp | 14 +++++++------- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLBatchToSpaceNDKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLBatchToSpaceNDKernel.cpp index b0016d2..5a19106 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLBatchToSpaceNDKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLBatchToSpaceNDKernel.cpp @@ -33,23 +33,23 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::S32, DataType::F16, DataType::F32); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(block_size[0] >= 1 && block_size[1] >= 1, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(!(block_size[0] >= 1 && block_size[1] >= 1), "Block size should be greater than or equal to 1."); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(2) == output->dimension(2), + ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(2) != output->dimension(2), "Input Depth should be equal to Output Depth"); ARM_COMPUTE_RETURN_ERROR_ON_MSG( - output->dimension(3) * block_size[0] * block_size[1] == input->dimension(3), + output->dimension(3) * block_size[0] * block_size[1] != input->dimension(3), "Input batch should be equal to (output batch * block size[0] *block size[1])"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(!(output->dimension(0) % block_size[1]) && - !(output->dimension(1) % block_size[0]), + ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) % block_size[1]) || + (output->dimension(1) % block_size[0]), "Output height and width should be divisible by block size[0] " "and block_size[1] respectively"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) == input->dimension(0) * block_size[1]) && - (output->dimension(1) == input->dimension(1) * block_size[0]), + ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) != input->dimension(0) * block_size[1]) || + (output->dimension(1) != input->dimension(1) * block_size[0]), "Output height and width should be equal to " "input_height*blocksize[0] and input_width*blocksize[1] " "respectively"); diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLDepthToSpaceKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLDepthToSpaceKernel.cpp index c386e33..81278ae 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLDepthToSpaceKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLDepthToSpaceKernel.cpp @@ -33,20 +33,20 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::S32, DataType::F16, DataType::F32); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(block_size >= 1, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(block_size < 1, "Block size should be greater than or equal to 1."); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->dimension(0) == input->dimension(0) * block_size, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->dimension(0) != input->dimension(0) * block_size, "Output width should be equal to (Input width * block size)"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->dimension(1) == input->dimension(1) * block_size, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->dimension(1) != input->dimension(1) * block_size, "Output height should be equal to (Input height * block size)"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(2) % (block_size * block_size) == 0, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(2) % (block_size * block_size) != 0, "Input depth should be divisible by (block size * block size)"); ARM_COMPUTE_RETURN_ERROR_ON_MSG( - output->dimension(2) == input->dimension(2) / (block_size * block_size), + output->dimension(2) != input->dimension(2) / (block_size * block_size), "Output depth should be equal to (Input depth / (block size * block size))"); return Status{}; diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLPadLayerKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLPadLayerKernel.cpp index 99b54c8..2e559e2 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLPadLayerKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLPadLayerKernel.cpp @@ -35,13 +35,12 @@ Status validate_arguments(const ITensorInfo *input_info, const ITensorInfo *outp DataType::F32); ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(pad_size_info, 1, DataType::S32); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_info->num_dimensions() > 0 && - input_info->num_dimensions() <= 4, - "Pad kernel supports upto 4-D input tensor"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG( - input_info->num_dimensions() == output_info->num_dimensions(), - "output tensor should have same number of dimensions as input tensor"); + !(input_info->num_dimensions() > 0 && input_info->num_dimensions() <= 4), + "Pad kernel supports upto 4-D input tensor"); + + ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_info->num_dimensions() != output_info->num_dimensions(), + "Output and input should have same number of dimensions"); if (input_info->data_type() == DataType::QASYMM8) { diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLReduceOperationKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLReduceOperationKernel.cpp index f581780..6bed989 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLReduceOperationKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLReduceOperationKernel.cpp @@ -61,7 +61,7 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, c const auto num_dimensions = input->tensor_shape().num_dimensions(); ARM_COMPUTE_RETURN_ERROR_ON_MSG( - axis >= 0 && axis < num_dimensions, + axis < 0 || axis >= num_dimensions, "axis must be greater than or equal to 0 and less than (input's rank)."); const TensorShape output_shape = inferOutputShape(input->tensor_shape(), axis); diff --git a/libs/ARMComputeEx/src/core/CL/kernels/CLSpaceToDepthKernel.cpp b/libs/ARMComputeEx/src/core/CL/kernels/CLSpaceToDepthKernel.cpp index 5d6329e..b803366 100644 --- a/libs/ARMComputeEx/src/core/CL/kernels/CLSpaceToDepthKernel.cpp +++ b/libs/ARMComputeEx/src/core/CL/kernels/CLSpaceToDepthKernel.cpp @@ -33,22 +33,22 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::S32, DataType::F16, DataType::F32); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(block_size >= 1, + ARM_COMPUTE_RETURN_ERROR_ON_MSG(block_size < 1, "Block size should be greater than or equal to 1."); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(3) == output->dimension(3), + ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->dimension(3) != output->dimension(3), "Input batch should be equal to Output batch"); ARM_COMPUTE_RETURN_ERROR_ON_MSG( - input->dimension(2) * block_size * block_size == output->dimension(2), + input->dimension(2) * block_size * block_size != output->dimension(2), "Output depth should be equal to (input depth * block size *block size)"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG(!(input->dimension(0) % block_size) && - !(input->dimension(1) % block_size), + ARM_COMPUTE_RETURN_ERROR_ON_MSG((input->dimension(0) % block_size) || + (input->dimension(1) % block_size), "Input height and width should be divisible by block size"); - ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) == (input->dimension(0) / block_size)) && - (output->dimension(1) == (input->dimension(1) / block_size)), + ARM_COMPUTE_RETURN_ERROR_ON_MSG((output->dimension(0) != (input->dimension(0) / block_size)) || + (output->dimension(1) != (input->dimension(1) / block_size)), "Output height and width should be equal to " "input_height/blocksize and input_width/blocksize respectively"); -- 2.7.4