Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, 2017 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_CLACCUMULATEKERNEL_H__ |
| 25 | #define __ARM_COMPUTE_CLACCUMULATEKERNEL_H__ |
| 26 | |
| 27 | #include "arm_compute/core/CL/ICLSimple2DKernel.h" |
| 28 | |
| 29 | #include <cstdint> |
| 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | class 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 | */ |
| 40 | class CLAccumulateKernel : public ICLSimple2DKernel |
| 41 | { |
| 42 | public: |
| 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); |
| 49 | }; |
| 50 | |
| 51 | /** Interface for the accumulate weighted kernel. |
| 52 | * |
| 53 | * Weighted accumulation is computed: |
| 54 | * @f[ accum(x,y) = (1 - \alpha)*accum(x,y) + \alpha*input(x,y) @f] |
| 55 | * |
| 56 | * Where @f$ 0 \le \alpha \le 1 @f$ |
| 57 | * Conceptually, the rounding for this is defined as: |
| 58 | * @f[ output(x,y)= uint8( (1 - \alpha) * float32( int32( output(x,y) ) ) + \alpha * float32( int32( input(x,y) ) ) ) @f] |
| 59 | */ |
| 60 | class CLAccumulateWeightedKernel : public ICLSimple2DKernel |
| 61 | { |
| 62 | public: |
| 63 | /** Set the input and accumulation images, and the scale value. |
| 64 | * |
| 65 | * @param[in] input Source tensor. Data types supported: U8. |
| 66 | * @param[in] alpha Scalar value in the range [0, 1.0]. Data types supported: F32. |
| 67 | * @param[in,out] accum Accumulated tensor. Data types supported: U8. |
| 68 | */ |
| 69 | void configure(const ICLTensor *input, float alpha, ICLTensor *accum); |
| 70 | }; |
| 71 | |
| 72 | /** Interface for the accumulate squared kernel. |
| 73 | * |
| 74 | * The accumulation of squares is computed: |
| 75 | * @f[ accum(x,y) = saturate_{int16} ( (uint16) accum(x,y) + (((uint16)(input(x,y)^2)) >> (shift)) ) @f] |
| 76 | * |
| 77 | * Where @f$ 0 \le shift \le 15 @f$ |
| 78 | */ |
| 79 | class CLAccumulateSquaredKernel : public ICLSimple2DKernel |
| 80 | { |
| 81 | public: |
| 82 | /** Set the input and accumulation tensors and the shift value. |
| 83 | * |
| 84 | * @param[in] input Source tensor. Data types supported: U8. |
| 85 | * @param[in] shift Shift value in the range of [0, 15]. Data types supported: U32. |
| 86 | * @param[in,out] accum Accumulated tensor. Data types supported: S16. |
| 87 | */ |
| 88 | void configure(const ICLTensor *input, uint32_t shift, ICLTensor *accum); |
| 89 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 90 | } // namespace arm_compute |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 91 | #endif /*__ARM_COMPUTE_CLACCUMULATEKERNEL_H__ */ |