From 9f7d55a3566b0f1044110000b033d663b26d3a6c Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Mon, 8 Feb 2021 13:20:24 +0000 Subject: Fix CLDepthwiseConvolutionLayer 3x3 QASYMM8 Fix errors when computing tensors with one element only - Replace Tensor3D with raw pointers so to get rid of offset to first element for NCHW layout - Add stronger out of bound constraints for NHWC layout - Set the border size to the input's padding for NHWC - Fill the strides == 0 with the largest stride, so to avoid accessing empty strides and multiplying by 0 Resolve COMPMID-4088 Change-Id: I751a4e6d7094b3c42306ff7f53af848fd35f19ac Signed-off-by: Giorgio Arena Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5024 Tested-by: Arm Jenkins Reviewed-by: Manuel Bottini Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/core/helpers/Utils.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/core/helpers/Utils.h') diff --git a/src/core/helpers/Utils.h b/src/core/helpers/Utils.h index 3c3b2b93f9..d64eddb9aa 100644 --- a/src/core/helpers/Utils.h +++ b/src/core/helpers/Utils.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020 Arm Limited. +* Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -50,6 +50,30 @@ inline Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fix strides.set(i, shape[i - 1] * strides[i - 1]); } + size_t first_zero = std::distance(strides.begin(), std::find_if(strides.begin(), strides.end(), [](uint32_t val) + { + return val == 0U; + })); + + if(first_zero > 0) + { + if(first_zero == 1) + { + strides.set(1, strides[0] * (shape[0] + info.padding().left + info.padding().right)); + ++first_zero; + } + else if(first_zero == 2) + { + strides.set(2, strides[1] * (shape[1] + info.padding().top + info.padding().bottom)); + ++first_zero; + } + + for(size_t i = first_zero; i < Strides::num_max_dimensions; ++i) + { + strides.set(i, strides[first_zero - 1]); + } + } + return strides; } -- cgit v1.2.1