blob: 5ec58548417b2c4f8f282b9ea2c90b558dcf460a [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
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_NESCALEKERNEL_H__
25#define __ARM_COMPUTE_NESCALEKERNEL_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28#include "arm_compute/core/Types.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** NEON kernel to perform scaling on a tensor */
35class NEScaleKernel : public INEKernel
36{
37public:
38 /** Default constructor */
39 NEScaleKernel();
40 /** Prevent instances of this class from being copied (As this class contains pointers) */
41 NEScaleKernel(const NEScaleKernel &) = delete;
42 /** Prevent instances of this class from being copied (As this class contains pointers) */
43 NEScaleKernel &operator=(const NEScaleKernel &) = delete;
44 /** Allow instances of this class to be moved */
45 NEScaleKernel(NEScaleKernel &&) = default;
46 /** Allow instances of this class to be moved */
47 NEScaleKernel &operator=(NEScaleKernel &&) = default;
48 /** Default destructor */
49 ~NEScaleKernel() = default;
50
51 /** Initialise the kernel's inputs, output and interpolation policy
52 *
53 * @note dx, dy and offsets have the same dimensions (width and height) of the output tensor
54 *
Georgios Pinitas583137c2017-08-31 18:12:42 +010055 * @param[in] input Source tensor. Data types supported: U8/S16/F32.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056 * @param[in] dx Pixel's distance between the X real coordinate and the smallest X following integer. Data type supported: F32
57 * @param[in] dy Pixel's distance between the Y real coordinate and the smallest Y following integer. Data type supported: F32
58 * @param[in] offsets Offset to access the pixel with NEAREST interpolation or the top-left pixel with BILINEAR interpolation in the input tensor. Data type supported: S32.
Georgios Pinitas583137c2017-08-31 18:12:42 +010059 * @param[out] output Destination tensor. Data types supported: Same as @p input. 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.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010060 * @param[in] policy Interpolation type to use
61 * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant.
62 */
63 void configure(const ITensor *input, const ITensor *dx, const ITensor *dy, const ITensor *offsets, ITensor *output, InterpolationPolicy policy, bool border_undefined);
64
65 // Inherited methods overridden:
Moritz Pflanzerc186b572017-09-07 09:48:04 +010066 void run(const Window &window, const ThreadInfo &info) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010067 BorderSize border_size() const override;
68
69private:
70 /** function to perform scale using nearest interpolation on the given window */
71 void scale_nearest(const Window &window);
72 /** function to perform scale using bilinear interpolation on the given window */
73 void scale_bilinear(const Window &window);
74 /** function to perform scale using area interpolation on the given window
75 *
76 * @note Used only in case down-sampling.
77 */
78 void scale_area(const Window &window);
79 /** Scale function to use for the particular interpolation type passed to configure() */
80 void (NEScaleKernel::*_func)(const Window &window);
81
82 const ITensor *_offsets;
83 const ITensor *_dx;
84 const ITensor *_dy;
85 const ITensor *_input;
86 ITensor *_output;
87};
Gian Marco Iodice356f6432017-09-22 11:32:21 +010088} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +010089#endif /*__ARM_COMPUTE_NESCALEKERNEL_H__ */