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); |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 49 | /** Initialise the kernel's inputs, output and interpolation policy |
| 50 | * |
| 51 | * @param[in] compile_context The compile context to be used. |
| 52 | * @param[in] input Source tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/F16/F32 |
| 53 | * @param[out] output Destination tensor. 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 |
| 58 | * @param[in] align_corners (Optional) Align corners of input and output, only affecting bilinear policy with TOP_LEFT sampling policy. Defaults to false. |
| 59 | */ |
Manuel Bottini | 2803f70 | 2020-04-21 16:20:03 +0100 | [diff] [blame^] | 60 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 61 | SamplingPolicy sampling_policy = SamplingPolicy::CENTER, bool align_corners = false); |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 62 | |
| 63 | /** Static function to check if given info will lead to a valid configuration of @ref CLScaleKernel |
| 64 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 65 | * @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] | 66 | * @param[in] output Destination tensor info. Data types supported: Same as @p input |
| 67 | * 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. |
| 68 | * @param[in] policy Interpolation type to use |
| 69 | * @param[in] border_mode Selected border mode. |
| 70 | * @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] | 71 | * @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] | 72 | * |
| 73 | * @return a status |
| 74 | */ |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 75 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, InterpolationPolicy policy, BorderMode border_mode, SamplingPolicy sampling_policy = SamplingPolicy::CENTER, |
| 76 | bool align_corners = false); |
Georgios Pinitas | 6c95c2d | 2018-08-20 16:06:58 +0100 | [diff] [blame] | 77 | /** Input tensor accessor. |
| 78 | * |
| 79 | * @return Pointer to input tensor. |
| 80 | */ |
| 81 | const ICLTensor *input() const; |
| 82 | /** Output tensor accessor. |
| 83 | * |
| 84 | * @return Pointer to output tensor. |
| 85 | */ |
| 86 | const ICLTensor *output() const; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 87 | |
| 88 | // Inherited methods overridden: |
| 89 | BorderSize border_size() const override; |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 90 | void run(const Window &window, cl::CommandQueue &queue) override; |
Georgios Pinitas | 6c95c2d | 2018-08-20 16:06:58 +0100 | [diff] [blame] | 91 | |
| 92 | public: |
| 93 | InterpolationPolicy _interpolationPolicy = InterpolationPolicy::BILINEAR; |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 94 | DataLayout _data_layout = DataLayout::UNKNOWN; |
Sang-Hoon Park | 5b7fd87 | 2020-01-09 15:27:51 +0000 | [diff] [blame] | 95 | bool _align_corners = false; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 96 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 97 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 98 | #endif /*ARM_COMPUTE_CLSCALEKERNEL_H */ |