diff options
author | Anitha Raj <anitha.raj@arm.com> | 2023-07-14 11:19:34 +0100 |
---|---|---|
committer | Anitha Raj <Anitha.Raj@arm.com> | 2023-08-22 09:42:32 +0000 |
commit | eb5696d99d85e1d402188151e021bc4b14f93969 (patch) | |
tree | f78337a676d6cfbb8421ff27315b0d7ad4dffc34 /src/core/helpers/Utils.h | |
parent | e1c3b466960d5e3fd5a54871287f5eb6102bfb8c (diff) | |
download | ComputeLibrary-eb5696d99d85e1d402188151e021bc4b14f93969.tar.gz |
Optimize CpuReshapeKernel
Resolves COMPMID-5279
Change-Id: Id9b007eed62c200702bbfcc83b94dab7b5de1714
Signed-off-by: Anitha Raj <anitha.raj@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9962
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: SiCong Li <sicong.li@arm.com>
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/helpers/Utils.h')
-rw-r--r-- | src/core/helpers/Utils.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/core/helpers/Utils.h b/src/core/helpers/Utils.h index 326dc962c7..641d536c13 100644 --- a/src/core/helpers/Utils.h +++ b/src/core/helpers/Utils.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020-2021 Arm Limited. +* Copyright (c) 2020-2021, 2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,6 @@ #define SRC_CORE_HELPERS_UTILS_H #include "arm_compute/core/ITensorInfo.h" - namespace arm_compute { /** Create a strides object based on the provided strides and the tensor dimensions. @@ -38,7 +37,7 @@ namespace arm_compute * calculated based on the tensor shape and the strides of lower dimensions. */ template <typename T, typename... Ts> -inline Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fixed_strides) +inline Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&...fixed_strides) { const TensorShape &shape = info.tensor_shape(); @@ -92,6 +91,32 @@ inline unsigned int get_next_power_two(unsigned int x) return x; } + +/** Check if the tensor has any holes. + * + * @param[in] info Tensor info object defining the shape of the input tensor. + * @param[in] dimension Highest dimension to check. + * + * @note This function checks for holes in all the dimensions upto and including the highest dimension. + * + */ +inline bool has_holes(const ITensorInfo &info, size_t dimension) +{ + const auto &shape = info.tensor_shape(); + const auto &strides = info.strides_in_bytes(); + size_t squashed_bytes = info.element_size(); + + for(size_t dim = 0; dim <= dimension; ++dim) + { + if(strides[dim] != squashed_bytes) + { + return true; + } + squashed_bytes *= shape[dim]; + } + return false; +} + } // namespace arm_compute #endif /* SRC_CORE_HELPERS_UTILS_H */ |