blob: 5ba4c3edcaa56592dc6c202508f896086e038af6 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Pablo Marquez Telloba933712023-11-13 15:57:54 +00002 * Copyright (c) 2017-2020, 2023 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Pablo Marquez Telloba933712023-11-13 15:57:54 +000024#ifndef ACL_SRC_CORE_NEON_KERNELS_NENORMALIZATIONLAYERKERNEL_H
25#define ACL_SRC_CORE_NEON_KERNELS_NENORMALIZATIONLAYERKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Michalis Spyrouebcebf12020-10-21 00:04:14 +010027#include "src/core/NEON/INEKernel.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028
29namespace arm_compute
30{
31class ITensor;
32
33/** Interface for the normalization layer kernel.
34 */
35class NENormalizationLayerKernel : public INEKernel
36{
37public:
Anthony Barbiere8a49832018-01-18 10:04:05 +000038 const char *name() const override
39 {
40 return "NENormalizationLayerKernel";
41 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042 /** Default constructor */
43 NENormalizationLayerKernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 NENormalizationLayerKernel(const NENormalizationLayerKernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 NENormalizationLayerKernel &operator=(const NENormalizationLayerKernel &) = delete;
48 /** Default Move Constructor. */
49 NENormalizationLayerKernel(NENormalizationLayerKernel &&) = default;
Alex Gildayc357c472018-03-21 13:54:09 +000050 /** Default move assignment operator */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010051 NENormalizationLayerKernel &operator=(NENormalizationLayerKernel &&) = default;
52 /** Default destructor */
53 ~NENormalizationLayerKernel() = default;
54 /** Set the input and output tensors.
55 *
56 * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions [width, height, IFM],
Michalis Spyrou0c71d0b2018-11-22 11:22:18 +000057 * and an optional 4th dimension for batch of inputs. Data types supported: FP16/F32. Data layouts supported: NCHW/NHWC.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010058 * @param[in] input_squared Source with each element has been squared. 3 lower dims represent a single input with dimensions [width, height, IFM],
Michalis Spyrou0c71d0b2018-11-22 11:22:18 +000059 * Data type and layout supported: same as @p input.
60 * @param[out] output Destination tensor. Output will have the same number of dimensions as input. Data type and layout supported: same as @p input.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010061 * @param[in] norm_info Normalization layer information like the normalization type, normalization size and other parameters.
62 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010063 void
64 configure(const ITensor *input, const ITensor *input_squared, ITensor *output, NormalizationLayerInfo norm_info);
Michalis Spyrouafa5d812017-11-30 14:25:57 +000065 /** Static function to check if given info will lead to a valid configuration of @ref NENormalizationLayerKernel
66 *
67 * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions [width, height, IFM],
Michalis Spyrou0c71d0b2018-11-22 11:22:18 +000068 * and an optional 4th dimension for batch of inputs. Data types supported: FP16/F32. Data layouts supported: NCHW/NHWC.
Michalis Spyrouafa5d812017-11-30 14:25:57 +000069 * @param[in] input_squared Source with each element has been squared. 3 lower dims represent a single input with dimensions [width, height, IFM],
Michalis Spyrou0c71d0b2018-11-22 11:22:18 +000070 * Data type and layout supported: same as @p input.
71 * @param[in] output Destination tensor. Output will have the same number of dimensions as input. Data type and layout supported: same as @p input.
Michalis Spyrouafa5d812017-11-30 14:25:57 +000072 * @param[in] norm_info Normalization layer information like the normalization type, normalization size and other parameters.
73 *
74 * @return a status
75 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010076 static Status validate(const ITensorInfo *input,
77 const ITensorInfo *input_squared,
78 const ITensorInfo *output,
79 NormalizationLayerInfo norm_info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080
81 // Inherited methods overridden:
Moritz Pflanzerc186b572017-09-07 09:48:04 +010082 void run(const Window &window, const ThreadInfo &info) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083
84private:
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085 /** Common signature for all the specialised normalization functions
86 *
87 * @param[in] window Region on which to execute the kernel.
88 */
Pablo Marquez Telloba933712023-11-13 15:57:54 +000089 using NormalizationFunction = void (*)(
90 const Window &window, const ITensor *in, const ITensor *in_squared, ITensor *out, NormalizationLayerInfo ninfo);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010091
92private:
93 NormalizationFunction _func;
94 const ITensor *_input;
95 const ITensor *_input_squared;
96 ITensor *_output;
97 NormalizationLayerInfo _norm_info;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010098};
Gian Marco Iodice356f6432017-09-22 11:32:21 +010099} // namespace arm_compute
Pablo Marquez Telloba933712023-11-13 15:57:54 +0000100#endif // ACL_SRC_CORE_NEON_KERNELS_NENORMALIZATIONLAYERKERNEL_H