aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-25 00:04:08 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-25 12:29:59 +0000
commit9a67178b98783b1a886e633b0c1926a9072904ff (patch)
treea67c0c950ddb6b9f2e19373dc9b7706478510bd4
parent8a5146fb5cc17d101e3b6c86654f5aca81e60335 (diff)
downloadComputeLibrary-9a67178b98783b1a886e633b0c1926a9072904ff.tar.gz
Avoid division with zero
- Check pixel alignment before calculating the padding extension for CLGEMMReshapeRHSKernel - Add missing control flow in NEWinogradLayer to avoid division with zero for N_Blocks Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: I53fa432e0a4c463840917d81bedeb64a29bb07a4 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5177 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Manuel Bottini <manuel.bottini@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/core/CL/gemm/CLGEMMHelpers.cpp15
-rw-r--r--src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp8
2 files changed, 17 insertions, 6 deletions
diff --git a/src/core/CL/gemm/CLGEMMHelpers.cpp b/src/core/CL/gemm/CLGEMMHelpers.cpp
index 5abe224a3..61aa96219 100644
--- a/src/core/CL/gemm/CLGEMMHelpers.cpp
+++ b/src/core/CL/gemm/CLGEMMHelpers.cpp
@@ -73,10 +73,17 @@ void update_padding_for_cl_image(ITensorInfo *tensor)
constexpr unsigned int num_floats_per_pixel = 4;
const unsigned int stride_y_in_elements = tensor->strides_in_bytes()[1] / tensor->element_size();
- const unsigned int pixel_aligment = get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device());
- const unsigned int row_pitch_alignment = pixel_aligment * num_floats_per_pixel;
- const unsigned int round_up_width = ((stride_y_in_elements + row_pitch_alignment - 1) / row_pitch_alignment) * row_pitch_alignment;
- const unsigned int padding = round_up_width - stride_y_in_elements;
+ const unsigned int pixel_alignment = get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device());
+
+ ARM_COMPUTE_ERROR_ON_MSG(pixel_alignment == 0, "Cannot retrieve cl_image pitch alignment");
+ if(pixel_alignment == 0)
+ {
+ return;
+ }
+
+ const unsigned int row_pitch_alignment = pixel_alignment * num_floats_per_pixel;
+ const unsigned int round_up_width = ((stride_y_in_elements + row_pitch_alignment - 1) / row_pitch_alignment) * row_pitch_alignment;
+ const unsigned int padding = round_up_width - stride_y_in_elements;
tensor->extend_padding(PaddingSize(0, padding, 0, 0));
}
diff --git a/src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp b/src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp
index 21a4b7973..dc3bbbe56 100644
--- a/src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp
+++ b/src/runtime/NEON/functions/NEWinogradConvolutionLayer.cpp
@@ -336,8 +336,8 @@ void NEWinogradConvolutionLayer::configure(const ITensor *input, const ITensor *
_output = output;
_is_prepared = false;
- int n_gemms = 0;
- int N_BLOCK = 0; // Size of block used by GEMM.
+ int n_gemms = 1;
+ int N_BLOCK = 1; // Size of block used by GEMM.
std::unique_ptr<INEWinogradLayerTransformInputKernel> transform_input_kernel;
std::unique_ptr<INEWinogradLayerTransformWeightsKernel> transform_weights_kernel;
@@ -452,6 +452,10 @@ void NEWinogradConvolutionLayer::configure(const ITensor *input, const ITensor *
}
}
#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+ else
+ {
+ ARM_COMPUTE_ERROR("Not supported.");
+ }
const PaddingType use_padding_type = (conv_info.pad_top() != 0u || conv_info.pad_left() != 0) ? PADDING_SAME : PADDING_VALID;
const bool use_same_padding = use_padding_type == PADDING_SAME;