/* * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved * Copyright (c) 2016-2018 ARM Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __ARM_COMPUTE_NENORMALIZATIONLAYEREXKERNEL_H__ #define __ARM_COMPUTE_NENORMALIZATIONLAYEREXKERNEL_H__ #include "arm_compute/core/NEON/INEKernel.h" namespace arm_compute { class ITensor; /** Interface for the normalization layer kernel. */ class NENormalizationLayerExKernel : public INEKernel { public: const char *name() const override { return "NENormalizationLayerKernel"; } /** Default constructor */ NENormalizationLayerExKernel(); /** Prevent instances of this class from being copied (As this class contains pointers) */ NENormalizationLayerExKernel(const NENormalizationLayerExKernel &) = delete; /** Prevent instances of this class from being copied (As this class contains pointers) */ NENormalizationLayerExKernel &operator=(const NENormalizationLayerExKernel &) = delete; /** Default Move Constructor. */ NENormalizationLayerExKernel(NENormalizationLayerExKernel &&) = default; /** Default move assignment operator */ NENormalizationLayerExKernel &operator=(NENormalizationLayerExKernel &&) = default; /** Default destructor */ ~NENormalizationLayerExKernel() = default; /** Set the input and output tensors. * * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions * [width, height, IFM], * and an optional 4th dimension for batch of inputs. Data types * supported: FP16/F32. * @param[in] input_squared Source with each element has been squared. 3 lower dims represent a * single input with dimensions [width, height, IFM], * Data type supported: same as @p input * @param[out] output Destination tensor. Output will have the same number of dimensions as * input. Data type supported: same as @p input * @param[in] norm_info Normalization layer information like the normalization type, * normalization size and other parameters. */ void configure(const ITensor *input, const ITensor *input_squared, ITensor *output, NormalizationLayerInfo norm_info); /** Static function to check if given info will lead to a valid configuration of @ref * NENormalizationLayerKernel * * @param[in] input Source tensor. 3 lower dims represent a single input with dimensions * [width, height, IFM], * and an optional 4th dimension for batch of inputs. Data types * supported: FP16/F32. * @param[in] input_squared Source with each element has been squared. 3 lower dims represent a * single input with dimensions [width, height, IFM], * Data type supported: same as @p input * @param[in] output Destination tensor. Output will have the same number of dimensions as * input. Data type supported: same as @p input * @param[in] norm_info Normalization layer information like the normalization type, * normalization size and other parameters. * * @return a status */ static Status validate(const ITensorInfo *input, const ITensorInfo *input_squared, const ITensorInfo *output, NormalizationLayerInfo norm_info); // Inherited methods overridden: void run(const Window &window, const ThreadInfo &info) override; BorderSize border_size() const override; private: /** Function to perform normalization depending on the given template * dimension. The second template parameter specifies whether the * normalization has to be 1D or 2D. * * @note Only supported normalizations are: * - 1D over X or Z * - 2D over X and Y * * @param[in] window Region on which to execute the kernel. */ template void normalize_float(const Window &window); /** Common signature for all the specialised normalization functions * * @param[in] window Region on which to execute the kernel. */ using NormalizationFunctionEx = void (NENormalizationLayerExKernel::*)(const Window &window); private: NormalizationFunctionEx _func; const ITensor *_input; const ITensor *_input_squared; ITensor *_output; NormalizationLayerInfo _norm_info; BorderSize _border_size; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_NENORMALIZATIONLAYEREXKERNEL_H__ */