From 37c989a58a04985dfdc21089c7dacc7e1925a4d0 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Fri, 24 Feb 2023 15:52:21 +0000 Subject: Add support for arbitrary parameters for CPU Gather * The shape of input and indices tensors, and the gather axis can be any number, as long as these are valid and the output tensor doesn't have more dimensions than the library supports. * Update the reference code to be more generic and straightforward. * Add necessary test cases. Signed-off-by: Viet-Hoa Do Resolves: COMPMID-5919 Change-Id: Ic7e2032777aa97ecc147f61d5388528697508ab1 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/9199 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- src/core/NEON/kernels/NEGatherKernel.h | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/core/NEON/kernels/NEGatherKernel.h') diff --git a/src/core/NEON/kernels/NEGatherKernel.h b/src/core/NEON/kernels/NEGatherKernel.h index 3dc0cad7be..ce69daeda7 100644 --- a/src/core/NEON/kernels/NEGatherKernel.h +++ b/src/core/NEON/kernels/NEGatherKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 Arm Limited. + * Copyright (c) 2019-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -81,27 +81,8 @@ public: void run(const Window &window, const ThreadInfo &info) override; private: - /** Implementation of the gather operation for 0 axis. - * - * For gather on the 0 axis an element by element copy is performed. - * - * @param[in] window Region on which to run the kernel. (Must be a region of the window returned by window()) - * @param[in] info Info about running thread and CPU. - */ - template - void gather_0_axis(const Window &window, const ThreadInfo &info); - - template - void gather_multiindices_1_axis(const Window &window, const ThreadInfo &info); - /** Implementation of the gather operation. - * - * For 1<=axis a row-wise copy is taking place. - * - * @param[in] window Region on which to run the kernel. (Must be a region of the window returned by window()) - * @param[in] info Info about running thread and CPU. - */ - template - void gather_n_axis(const Window &window, const ThreadInfo &info); + template + void gather_common(const Window &window, const ThreadInfo &info); using kernel_ptr = void (NEGatherKernel::*)(const Window &window, const ThreadInfo &info); @@ -110,6 +91,9 @@ private: int _axis; ITensor *_output; kernel_ptr _func; + + Strides _src_it_strides; + Strides _idx_it_strides; }; } // namespace arm_compute #endif /* ARM_COMPUTE_NEGATHERKERNEL_H */ -- cgit v1.2.1