blob: 79c321f919cc7e30c10f29d9429797a83cec508f [file] [log] [blame]
giuros01ba368252019-02-19 13:53:10 +00001/*
2 * Copyright (c) 2019 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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NESPACETOBATCHLAYERKERNEL_H
25#define ARM_COMPUTE_NESPACETOBATCHLAYERKERNEL_H
giuros01ba368252019-02-19 13:53:10 +000026
27#include "arm_compute/core/NEON/INEKernel.h"
28#include "arm_compute/core/Types.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** Interface for the space to batch kernel */
35class NESpaceToBatchLayerKernel : public INEKernel
36{
37public:
38 const char *name() const override
39 {
40 return "NESpaceToBatchLayerKernel";
41 }
42 /** Default constructor */
43 NESpaceToBatchLayerKernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 NESpaceToBatchLayerKernel(const NESpaceToBatchLayerKernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 NESpaceToBatchLayerKernel &operator=(const NESpaceToBatchLayerKernel &) = delete;
48 /** Allow instances of this class to be moved */
49 NESpaceToBatchLayerKernel(NESpaceToBatchLayerKernel &&) = default;
50 /** Allow instances of this class to be moved */
51 NESpaceToBatchLayerKernel &operator=(NESpaceToBatchLayerKernel &&) = default;
52 /** Default destructor */
53 ~NESpaceToBatchLayerKernel() = default;
54 /** Initialise the kernel's inputs and output.
55 *
56 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
57 * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32
58 * @param[in] paddings 2-D tensor with shape [2, M]. Data types supported: S32
59 * @param[out] output Tensor output. Data types supported: same as @p input
60 */
61 void configure(const ITensor *input, const ITensor *block_shape, const ITensor *paddings, ITensor *output);
62 /** Initialise the kernel's input and output. (Static block shape and paddings)
63 *
64 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
65 * @param[in] block_shape_x Block shape x value.
66 * @param[in] block_shape_y Block shape y value.
67 * @param[in] padding_left The left padding of the output tensor.
68 * @param[in] padding_right The right padding of the output tensor.
69 * @param[out] output Tensor output. Data types supported: same as @p input
70 */
71 void configure(const ITensor *input, const int block_shape_x, const int block_shape_y, const Size2D &padding_left, const Size2D &padding_right, ITensor *output);
72 /** Static function to check if given info will lead to a valid configuration of @ref NESpaceToBatchLayerKernel
73 *
74 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
75 * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32
76 * @param[in] paddings 2-D tensor with shape [2, M]. Data types supported: S32
77 * @param[in] output Tensor output. Data types supported: same as @p input
78 *
79 * @return a status
80 */
81 static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *paddings, const ITensorInfo *output);
82 /** Static function to check if given info will lead to a valid configuration of @ref NESpaceToBatchLayerKernel (Static block shape and paddings)
83 *
84 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
85 * @param[in] block_shape_x Block shape x value.
86 * @param[in] block_shape_y Block shape y value.
87 * @param[in] padding_left The left padding of the output tensor.
88 * @param[in] padding_right The right padding of the output tensor.
89 * @param[in] output Tensor output. Data types supported: same as @p input
90 *
91 * @return a status
92 */
93 static Status validate(const ITensorInfo *input, const int block_shape_x, const int block_shape_y, const Size2D &padding_left, const Size2D &padding_right, const ITensorInfo *output);
94
95 // Inherited methods overridden:
96 void run(const Window &window, const ThreadInfo &info) override;
97
98private:
99 const ITensor *_input; /**< Source tensor */
100 const ITensor *_block_shape; /**< Block shape tensor */
101 const ITensor *_paddings; /**< Paddings tensor */
102 ITensor *_output; /**< Destination tensor */
103
104 Size2D _padding_left;
105 int _block_shape_x;
106 int _block_shape_y;
107};
108} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000109#endif /* ARM_COMPUTE_NESPACETOBATCHLAYERKERNEL_H */