diff options
author | Giorgio Arena <giorgio.arena@arm.com> | 2019-07-12 14:49:49 +0100 |
---|---|---|
committer | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2019-07-26 13:52:08 +0000 |
commit | 44f5572f3d6ba8e39c4a18a991049992d590ce39 (patch) | |
tree | c78abd8f4ddd44d2ff28433fa44997be0972bc2d /arm_compute/core | |
parent | c050e0ce189585599b2b70c20aad089e58f657ff (diff) | |
download | ComputeLibrary-44f5572f3d6ba8e39c4a18a991049992d590ce39.tar.gz |
COMPMID-2179 New generic depthwise convolution for NEON F32 NHWC
Change-Id: I2b883785c0500d4bdb6ee4700382ee058be2cd36
Signed-off-by: Giorgio Arena <giorgio.arena@arm.com>
Reviewed-on: https://review.mlplatform.org/c/1538
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r-- | arm_compute/core/NEON/NEKernels.h | 1 | ||||
-rw-r--r-- | arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayerKernel.h | 109 |
2 files changed, 110 insertions, 0 deletions
diff --git a/arm_compute/core/NEON/NEKernels.h b/arm_compute/core/NEON/NEKernels.h index e41f299611..8fddec2c5f 100644 --- a/arm_compute/core/NEON/NEKernels.h +++ b/arm_compute/core/NEON/NEKernels.h @@ -53,6 +53,7 @@ #include "arm_compute/core/NEON/kernels/NEDepthConvertLayerKernel.h" #include "arm_compute/core/NEON/kernels/NEDepthToSpaceLayerKernel.h" #include "arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayer3x3Kernel.h" +#include "arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayerKernel.h" #include "arm_compute/core/NEON/kernels/NEDepthwiseIm2ColKernel.h" #include "arm_compute/core/NEON/kernels/NEDepthwiseVectorToTensorKernel.h" #include "arm_compute/core/NEON/kernels/NEDepthwiseWeightsReshapeKernel.h" diff --git a/arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayerKernel.h b/arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayerKernel.h new file mode 100644 index 0000000000..63635b3a6c --- /dev/null +++ b/arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayerKernel.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2019 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_NEDEPTHWISECONVOLUTIONKERNEL_H__ +#define __ARM_COMPUTE_NEDEPTHWISECONVOLUTIONKERNEL_H__ + +#include "arm_compute/core/NEON/INEKernel.h" + +namespace arm_compute +{ +// Forward declarations +class ITensor; + +/** Interface for the kernel to run a depthwise convolution on a tensor. */ +class NEDepthwiseConvolutionLayerKernel : public INEKernel +{ +public: + const char *name() const override + { + return "NEDepthwiseConvolutionLayerKernel"; + } + /** Default constructor */ + NEDepthwiseConvolutionLayerKernel(); + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEDepthwiseConvolutionLayerKernel(const NEDepthwiseConvolutionLayerKernel &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + NEDepthwiseConvolutionLayerKernel &operator=(const NEDepthwiseConvolutionLayerKernel &) = delete; + /** Default Move Constructor. */ + NEDepthwiseConvolutionLayerKernel(NEDepthwiseConvolutionLayerKernel &&) = default; + /** Default move assignment operator */ + NEDepthwiseConvolutionLayerKernel &operator=(NEDepthwiseConvolutionLayerKernel &&) = default; + /** Initialize the function's source, destination and parameters. + * + * @note Supported data layouts: NHWC + * + * @param[in] input Source tensor. DataType supported: F32. + * @param[in] weights Weights tensor. This is a 3D tensor with dimensions [IFM, W, H]. Data type supported: Same as @p input. + * @param[in] biases Biases tensor. A 1D tensor with dimensions [IFM]. Must be nullptr if not needed. Data type supported: Same as @p input. + * @param[out] output Destination tensor. Data type supported: Same as @p input. + * @param[in] conv_info Padding and stride information to use for the convolution. + * @param[in] depth_multiplier (Optional) Multiplier to apply to the input's depth in order to retrieve the output's depth. Defaults to 1. + * @param[in] dilation (Optional) Dilation, in elements, across x and y. Defaults to (1, 1). + * + */ + void configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier = 1, + const Size2D &dilation = Size2D(1U, 1U)); + /** Static function to check if given info will lead to a valid configuration of @ref NEDepthwiseConvolutionLayerKernel + * + * @note Supported data layouts: NHWC + * + * @param[in] input Source tensor info. DataType supported: F32. + * @param[in] weights Weights tensor info. This is a 3D tensor with dimensions [IFM, W, H]. Data type supported: Same as @p input. + * @param[in] biases Biases tensor info. A 1D tensor with dimensions [IFM]. Must be nullptr if not needed. Data type supported: Same as @p input. + * @param[in] output Destination tensor info. Data type supported: Same as @p input. + * @param[in] conv_info Padding and stride information to use for the convolution. + * @param[in] depth_multiplier (Optional) Multiplier to apply to the input's depth in order to retrieve the output's depth. Defaults to 1. + * @param[in] dilation (Optional) Dilation, in elements, across x and y. Defaults to (1, 1). + * + * @return a status + */ + static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier = 1, + const Size2D &dilation = Size2D(1U, 1U)); + + // Inherited methods overridden: + void run(const Window &window, const ThreadInfo &info) override; + BorderSize border_size() const override; + +private: + template <typename T, int S, bool has_biases> + void run_depthwise(const Window &window); + + /** Common signature for all the specialised depthwise convolution functions + * + * @param[in] window Region on which to execute the kernel. + */ + using DepthwiseFunctionPtr = void (NEDepthwiseConvolutionLayerKernel::*)(const Window &window); + + DepthwiseFunctionPtr _func; + BorderSize _border_size; + const ITensor *_input; + const ITensor *_weights; + const ITensor *_biases; + ITensor *_output; + PadStrideInfo _conv_info; + unsigned int _depth_multiplier; + Size2D _dilation; +}; +} // namespace arm_compute +#endif /* __ARM_COMPUTE_NEDEPTHWISECONVOLUTIONKERNEL_H__ */ |