From 284cfe2e3a44e5b20978e561c96c94d2193e93a1 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 13 Feb 2018 12:15:13 +0000 Subject: COMPMID-903: Implements NEPermute for NHWC conversions Change-Id: I4083e8d16bb23933634f229a1408dfd0e8f2922a Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/120069 Tested-by: Jenkins Reviewed-by: Anthony Barbier --- arm_compute/runtime/NEON/NEFunctions.h | 3 +- .../runtime/NEON/functions/NEConvolutionLayer.h | 8 +++ .../NEON/functions/NEDepthwiseConvolutionLayer.h | 8 +-- arm_compute/runtime/NEON/functions/NEPermute.h | 61 ++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 arm_compute/runtime/NEON/functions/NEPermute.h (limited to 'arm_compute/runtime/NEON') diff --git a/arm_compute/runtime/NEON/NEFunctions.h b/arm_compute/runtime/NEON/NEFunctions.h index d09fcb280c..077cf577e7 100644 --- a/arm_compute/runtime/NEON/NEFunctions.h +++ b/arm_compute/runtime/NEON/NEFunctions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 ARM Limited. + * Copyright (c) 2016-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -88,6 +88,7 @@ #include "arm_compute/runtime/NEON/functions/NENonMaximaSuppression3x3.h" #include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" #include "arm_compute/runtime/NEON/functions/NEOpticalFlow.h" +#include "arm_compute/runtime/NEON/functions/NEPermute.h" #include "arm_compute/runtime/NEON/functions/NEPhase.h" #include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h" #include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" diff --git a/arm_compute/runtime/NEON/functions/NEConvolutionLayer.h b/arm_compute/runtime/NEON/functions/NEConvolutionLayer.h index f65e7ef36b..f80f67d944 100644 --- a/arm_compute/runtime/NEON/functions/NEConvolutionLayer.h +++ b/arm_compute/runtime/NEON/functions/NEConvolutionLayer.h @@ -146,6 +146,14 @@ private: * except for input of QASYMM8 type where output should be of S32 type. */ void configure_mm(const ITensor *input, const ITensor *weights, ITensor *output); + /** Prepare the appropriate assembly optimized kernel + * + * @param[in] ci CPU information + * @param[in] M M parameter of matrix multiplication + * @param[in] N N parameter of matrix multiplication + * @param[in] K K parameter of matrix multiplication + */ + void configure_asm_mm(const struct CPUInfo &ci, int M, int N, int K); private: MemoryGroup _memory_group; diff --git a/arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h b/arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h index 682effe84b..1c65b3ccf5 100644 --- a/arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h +++ b/arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h @@ -32,10 +32,10 @@ #include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h" #include "arm_compute/core/NEON/kernels/NEGEMMMatrixVectorMultiplyKernel.h" #include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CPP/functions/CPPPermute.h" #include "arm_compute/runtime/IFunction.h" #include "arm_compute/runtime/IMemoryManager.h" #include "arm_compute/runtime/MemoryGroup.h" +#include "arm_compute/runtime/NEON/functions/NEPermute.h" #include "arm_compute/runtime/Tensor.h" namespace arm_compute @@ -71,9 +71,9 @@ private: NEDepthwiseConvolutionLayer3x3Kernel _dwc_kernel; NEDirectConvolutionLayerOutputStageKernel _output_stage_kernel; NEFillBorderKernel _border_handler; - CPPPermute _permute_input; - CPPPermute _permute_weights; - CPPPermute _permute_output; + NEPermute _permute_input; + NEPermute _permute_weights; + NEPermute _permute_output; Tensor _accumulator; Tensor _input_nhwc; Tensor _weights_hwio; diff --git a/arm_compute/runtime/NEON/functions/NEPermute.h b/arm_compute/runtime/NEON/functions/NEPermute.h new file mode 100644 index 0000000000..58626cd2f2 --- /dev/null +++ b/arm_compute/runtime/NEON/functions/NEPermute.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_NEPERMUTE_H__ +#define __ARM_COMPUTE_NEPERMUTE_H__ + +#include "arm_compute/runtime/NEON/INESimpleFunction.h" + +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +class ITensor; + +/** Basic function to run @ref NEPermuteKernel */ +class NEPermute : public INESimpleFunction +{ +public: + /** Configure the permute NEON kernel + * + * @note Supported permutation vectors : [2, 0, 1], [1, 2, 0] + * + * @param[in] input The input tensor to permute. Data types supported: U8/S8/QS8/QASYMM8/U16/S16/QS16/F16/U32/S32/F32 + * @param[out] output The output tensor. Data types supported: Same as @p input + * @param[in] perm Permutation vector + */ + void configure(const ITensor *input, ITensor *output, const PermutationVector &perm); + /** Static function to check if given info will lead to a valid configuration of @ref NEPermute + * + * @note Supported permutation vectors : [2, 0, 1], [1, 2, 0] + * + * @param[in] input The input tensor to permute. Data types supported: U8/S8/QS8/QASYMM8/U16/S16/QS16/F16/U32/S32/F32 + * @param[in] output The output tensor. Data types supported: Same as @p input + * @param[in] perm Permutation vector + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm); +}; +} +#endif /* __ARM_COMPUTE_NEPERMUTE_H__ */ -- cgit v1.2.1