blob: e067da084f5ad3e9b15fa24c655655efde6d88cb [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2016-2020 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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_CLACCUMULATEKERNEL_H
25#define ARM_COMPUTE_CLACCUMULATEKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/CL/ICLSimple2DKernel.h"
28
29#include <cstdint>
30
31namespace arm_compute
32{
33class ICLTensor;
34
35/** Interface for the accumulate kernel.
36 *
37 * Accumulation is computed by:
38 * @f[ accum(x,y) = accum(x,y) + input(x,y) @f]
39 */
40class CLAccumulateKernel : public ICLSimple2DKernel
41{
42public:
43 /** Set the input and accumulation tensors.
44 *
45 * @param[in] input Source tensor. Data types supported: U8.
46 * @param[out] accum Destination tensor. Data types supported: S16.
47 */
48 void configure(const ICLTensor *input, ICLTensor *accum);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010049 /** Set the input and accumulation tensors.
50 *
51 * @param[in] compile_context The compile context to be used.
52 * @param[in] input Source tensor. Data types supported: U8.
53 * @param[out] accum Destination tensor. Data types supported: S16.
54 */
Manuel Bottini256c0b92020-04-21 13:29:30 +010055 void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *accum);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056};
57
58/** Interface for the accumulate weighted kernel.
59 *
60 * Weighted accumulation is computed:
61 * @f[ accum(x,y) = (1 - \alpha)*accum(x,y) + \alpha*input(x,y) @f]
62 *
63 * Where @f$ 0 \le \alpha \le 1 @f$
64 * Conceptually, the rounding for this is defined as:
65 * @f[ output(x,y)= uint8( (1 - \alpha) * float32( int32( output(x,y) ) ) + \alpha * float32( int32( input(x,y) ) ) ) @f]
66*/
67class CLAccumulateWeightedKernel : public ICLSimple2DKernel
68{
69public:
70 /** Set the input and accumulation images, and the scale value.
71 *
72 * @param[in] input Source tensor. Data types supported: U8.
73 * @param[in] alpha Scalar value in the range [0, 1.0]. Data types supported: F32.
74 * @param[in,out] accum Accumulated tensor. Data types supported: U8.
75 */
76 void configure(const ICLTensor *input, float alpha, ICLTensor *accum);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010077 /** Set the input and accumulation images, and the scale value.
78 *
79 * @param[in] compile_context The compile context to be used.
80 * @param[in] input Source tensor. Data types supported: U8.
81 * @param[in] alpha Scalar value in the range [0, 1.0]. Data types supported: F32.
82 * @param[in,out] accum Accumulated tensor. Data types supported: U8.
83 */
Manuel Bottini256c0b92020-04-21 13:29:30 +010084 void configure(const CLCompileContext &compile_context, const ICLTensor *input, float alpha, ICLTensor *accum);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085};
86
87/** Interface for the accumulate squared kernel.
88 *
89 * The accumulation of squares is computed:
90 * @f[ accum(x,y) = saturate_{int16} ( (uint16) accum(x,y) + (((uint16)(input(x,y)^2)) >> (shift)) ) @f]
91 *
92 * Where @f$ 0 \le shift \le 15 @f$
93*/
94class CLAccumulateSquaredKernel : public ICLSimple2DKernel
95{
96public:
97 /** Set the input and accumulation tensors and the shift value.
98 *
99 * @param[in] input Source tensor. Data types supported: U8.
100 * @param[in] shift Shift value in the range of [0, 15]. Data types supported: U32.
101 * @param[in,out] accum Accumulated tensor. Data types supported: S16.
102 */
103 void configure(const ICLTensor *input, uint32_t shift, ICLTensor *accum);
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100104 /** Set the input and accumulation tensors and the shift value.
105 *
106 * @param[in] compile_context The compile context to be used.
107 * @param[in] input Source tensor. Data types supported: U8.
108 * @param[in] shift Shift value in the range of [0, 15]. Data types supported: U32.
109 * @param[in,out] accum Accumulated tensor. Data types supported: S16.
110 */
Manuel Bottini256c0b92020-04-21 13:29:30 +0100111 void configure(const CLCompileContext &compile_context, const ICLTensor *input, uint32_t shift, ICLTensor *accum);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100112};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +0100113} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000114#endif /*ARM_COMPUTE_CLACCUMULATEKERNEL_H */