Compute Library
 21.02
NEL2NormalizeLayer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Arm Limited.
3  *
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  */
24 #ifndef ARM_COMPUTE_NEL2NORMALIZELAYER_H
25 #define ARM_COMPUTE_NEL2NORMALIZELAYER_H
26 
32 
33 #include <memory>
34 
35 namespace arm_compute
36 {
37 class ITensor;
38 class NEL2NormalizeLayerKernel;
39 
40 /** Basic function to perform a L2 normalization on a given axis.
41  *
42  * This function runs the following kernels:
43  * -# @ref NEReductionOperation
44  * -# @ref NEL2NormalizeLayerKernel
45  */
47 {
48 public:
49  /** Constructor */
50  NEL2NormalizeLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
51  /** Prevent instances of this class from being copied (As this class contains pointers) */
52  NEL2NormalizeLayer(const NEL2NormalizeLayer &) = delete;
53  /** Prevent instances of this class from being copied (As this class contains pointers) */
55  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
57  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
59  /** Default destructor */
61  /** Set the input and output tensors.
62  *
63  * @param[in, out] input Source tensor. Data types supported: F16/F32. (Written to only for border_size != 0)
64  * @param[out] output Destination tensor. Data types and data layouts supported: same as @p input.
65  * @param[in] axis Axis along which to reduce. Negative values wrap around. Maximum supported actual reduction axis : 2
66  * @param[in] epsilon (Optional) Lower bound value for the normalization.
67  */
68  void configure(ITensor *input, ITensor *output, int axis, float epsilon = 1e-6f);
69 
70  /** Static function to check if given info will lead to a valid configuration of @ref NEL2NormalizeLayer.
71  *
72  * @param[in] input Source tensor info. Data types supported: F16/F32. (Written to only for border_size != 0)
73  * @param[in] output Destination tensor info. Data types and data layouts supported: same as @p input.
74  * @param[in] axis Axis along which to reduce. Negative values wrap around. Maximum supported actual reduction axis : 2
75  * @param[in] epsilon (Optional) Lower bound value for the normalization.
76  *
77  * @return a status
78  */
79  static Status validate(const ITensorInfo *input, const ITensorInfo *output, int axis, float epsilon = 1e-6f);
80 
81  // Inherited methods overridden:
82  void run() override;
83 
84 private:
85  MemoryGroup _memory_group;
86  NEReductionOperation _reduce_func;
87  std::unique_ptr<NEL2NormalizeLayerKernel> _normalize_kernel;
88  Tensor _sumsq;
89 };
90 }
91 #endif /* ARM_COMPUTE_NEL2NORMALIZELAYER_H */
Base class for all functions.
Definition: IFunction.h:30
void run() override
Run the kernels contained in the function.
~NEL2NormalizeLayer()
Default destructor.
Basic function to perform a L2 normalization on a given axis.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
void configure(ITensor *input, ITensor *output, int axis, float epsilon=1e-6f)
Set the input and output tensors.
Basic implementation of the tensor interface.
Definition: Tensor.h:37
NEL2NormalizeLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Constructor.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, int axis, float epsilon=1e-6f)
Static function to check if given info will lead to a valid configuration of NEL2NormalizeLayer.
NEL2NormalizeLayer & operator=(const NEL2NormalizeLayer &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Basic function to simulate a reduction operation.