blob: 02b29fb64e426343ac1da9823001be805c49d236 [file] [log] [blame]
Georgios Pinitasd9769582017-08-03 10:19:40 +01001/*
John Richardson73d4aef2018-05-08 14:34:33 +01002 * Copyright (c) 2017-2018 ARM Limited.
Georgios Pinitasd9769582017-08-03 10:19:40 +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 */
24#ifndef __ARM_COMPUTE_NEREDUCTIONOPERATION_H__
25#define __ARM_COMPUTE_NEREDUCTIONOPERATION_H__
26
27#include "arm_compute/runtime/IFunction.h"
28
29#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
30#include "arm_compute/core/NEON/kernels/NEReductionOperationKernel.h"
31#include "arm_compute/core/Types.h"
32
33namespace arm_compute
34{
35class ITensor;
36
37/** Basic function to simulate a reduction operation. This function calls the following NEON kernels:
38 *
39 * -# @ref NEFillBorderKernel
40 * -# @ref NEReductionOperationKernel
41 *
42 */
43class NEReductionOperation : public IFunction
44{
45public:
46 /** Default constructor */
47 NEReductionOperation();
48 /** Set the input and output tensors.
49 *
John Richardson73d4aef2018-05-08 14:34:33 +010050 * @param[in, out] input Source tensor. Data type supported: F32. Data layouts supported: NCHW. (Written to only for border_size != 0)
51 * @param[out] output Destination tensor. Data types and data layouts supported: same as @p input.
Georgios Pinitasd9769582017-08-03 10:19:40 +010052 * @param[in] axis Dimension along which to reduce. Supported reduction axis : 0
53 * @param[in] op Reduction operation to perform.
54 */
55 void configure(ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op);
56
John Richardson73d4aef2018-05-08 14:34:33 +010057 /** Static function to check if given info will lead to a valid configuration of @ref NEReductionOperation.
58 *
59 * @param[in] input Source tensor info. Data type supported: F32. Data layouts supported: NCHW. (Written to only for border_size != 0)
60 * @param[in] output Destination tensor info. Data types and data layouts supported: same as @p input.
61 * @param[in] axis Dimension along which to reduce. Supported reduction axis : 0
62 * @param[in] op Reduction operation to perform.
63 *
64 * @return a status
65 */
66 static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op);
67
Georgios Pinitasd9769582017-08-03 10:19:40 +010068 // Inherited methods overridden:
69 void run() override;
70
71private:
72 NEReductionOperationKernel _reduction_kernel;
73 NEFillBorderKernel _fill_border_kernel;
74 size_t _window_split;
75};
76}
77#endif /* __ARM_COMPUTE_NEREDUCTIONOPERATION_H__ */