Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2020 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CLSCALEKERNEL_H |
| 25 | #define ARM_COMPUTE_CLSCALEKERNEL_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/CL/ICLSimple2DKernel.h" |
| 28 | #include "arm_compute/core/Types.h" |
| 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | class ICLTensor; |
| 33 | |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 34 | /** Interface for the scale kernel */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | class CLScaleKernel : public ICLSimple2DKernel |
| 36 | { |
| 37 | public: |
| 38 | /** Initialise the kernel's inputs, output and interpolation policy |
| 39 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 40 | * @param[in] input Source tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/F32 |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 41 | * @param[out] output Destination tensor. Data types supported: Same as @p input |
| 42 | * All but the lowest two dimensions must be the same size as in the input tensor, i.e. scaling is only performed within the XY-plane. |
| 43 | * @param[in] policy Interpolation type to use |
| 44 | * @param[in] border_mode Selected border mode. |
| 45 | * @param[in] sampling_policy (Optional) Sampling policy used by the interpolation. Defaults to @ref SamplingPolicy::CENTER |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 46 | * @param[in] align_corners (Optional) Align corners of input and output, only affecting bilinear policy with TOP_LEFT sampling policy. Defaults to false. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | */ |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 48 | void configure(const ICLTensor *input, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, SamplingPolicy sampling_policy = SamplingPolicy::CENTER, bool align_corners = false); |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 49 | |
| 50 | /** Static function to check if given info will lead to a valid configuration of @ref CLScaleKernel |
| 51 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 52 | * @param[in] input Source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/F32 |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 53 | * @param[in] output Destination tensor info. Data types supported: Same as @p input |
| 54 | * All but the lowest two dimensions must be the same size as in the input tensor, i.e. scaling is only performed within the XY-plane. |
| 55 | * @param[in] policy Interpolation type to use |
| 56 | * @param[in] border_mode Selected border mode. |
| 57 | * @param[in] sampling_policy (Optional) Sampling policy used by the interpolation. Defaults to @ref SamplingPolicy::CENTER |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 58 | * @param[in] align_corners (Optional) Align corners of input and output, only affecting bilinear policy with TOP_LEFT sampling policy. Defaults to false. |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 59 | * |
| 60 | * @return a status |
| 61 | */ |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 62 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, InterpolationPolicy policy, BorderMode border_mode, SamplingPolicy sampling_policy = SamplingPolicy::CENTER, |
| 63 | bool align_corners = false); |
Georgios Pinitas | 6c95c2d | 2018-08-20 16:06:58 +0100 | [diff] [blame] | 64 | /** Input tensor accessor. |
| 65 | * |
| 66 | * @return Pointer to input tensor. |
| 67 | */ |
| 68 | const ICLTensor *input() const; |
| 69 | /** Output tensor accessor. |
| 70 | * |
| 71 | * @return Pointer to output tensor. |
| 72 | */ |
| 73 | const ICLTensor *output() const; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 74 | |
| 75 | // Inherited methods overridden: |
| 76 | BorderSize border_size() const override; |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 77 | void run(const Window &window, cl::CommandQueue &queue) override; |
Georgios Pinitas | 6c95c2d | 2018-08-20 16:06:58 +0100 | [diff] [blame] | 78 | |
| 79 | public: |
| 80 | InterpolationPolicy _interpolationPolicy = InterpolationPolicy::BILINEAR; |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 81 | DataLayout _data_layout = DataLayout::UNKNOWN; |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 82 | bool _align_corners = false; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 84 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 85 | #endif /*ARM_COMPUTE_CLSCALEKERNEL_H */ |