blob: e2162ef04274c4dd5fc59e0277850b71fd5979d4 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +01002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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_NEDEPTHCONCATENATE_H__
25#define __ARM_COMPUTE_NEDEPTHCONCATENATE_H__
26
27#include "arm_compute/runtime/IFunction.h"
28
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000029#include "arm_compute/core/NEON/kernels/NEDepthConcatenateLayerKernel.h"
Georgios Pinitasac4e8732017-07-05 17:02:25 +010030#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
31
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032#include <memory>
33#include <vector>
34
35namespace arm_compute
36{
37class ITensor;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038
39/** Basic function to execute concatenate tensors along z axis. This function calls the following kernels:
40 *
41 * -# @ref NEFillBorderKernel (executed if input's lowest two dimensions are smaller than respective output's dimensions)
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000042 * -# @ref NEDepthConcatenateLayerKernel
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043 *
44 */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000045class NEDepthConcatenateLayer : public IFunction
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046{
47public:
48 /** Default constructor */
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000049 NEDepthConcatenateLayer();
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050 /** Initialise the kernel's inputs vector and output.
51 *
Georgios Pinitasae54e022018-07-16 15:41:27 +010052 * @param[in,out] inputs_vector The vectors containing all the tensors to concatenate. Data types supported: QASYMM8/F16/F32.
53 * Input dimensions might differ for each input for the first three dimensions (width, height, depth)
54 * and must match for the rest.
55 * Note that the difference between the minimum and maximum width and height among the input tensors
56 * must be divisible by 2 otherwise it is not clear how padding should be added on the inputs' width and
57 * height when they are less than the maximum input sizes.
58 * @param[out] output Output tensor. Data types supported: Same as @p input.
59 * Output tensor dimensions match the inputs' ones from the fourth dimension and above,
60 * while width and height are the maximum width and height of the input tensors.
61 * Finally, depth is the sum of the input depths.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010062 */
Georgios Pinitasae54e022018-07-16 15:41:27 +010063 void configure(const std::vector<ITensor *> &inputs_vector, ITensor *output);
64 /** Static function to check if given info will lead to a valid configuration of @ref NEDepthConcatenateLayer
65 *
66 * @param[in] inputs_vector The vectors containing all the tensors to concatenate. Data types supported: QASYMM8/F16/F32.
67 * Input dimensions might differ for each input for the first three dimensions (width, height, depth)
68 * and must match for the rest.
69 * Note that the difference between the minimum and maximum width and height among the input tensors
70 * must be divisible by 2 otherwise it is not clear how padding should be added on the inputs' width and
71 * height when they are less than the maximum input sizes.
72 * @param[in] output Output tensor. Data types supported: Same as @p input.
73 * Output tensor dimensions match the inputs' ones from the fourth dimension and above,
74 * while width and height are the maximum width and height of the input tensors.
75 * Finally, depth is the sum of the input depths.
76 *
77 * @return a status
78 */
79 static Status validate(const std::vector<ITensorInfo *> &inputs_vector, const ITensorInfo *output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080
81 // Inherited methods overridden:
82 void run() override;
83
84private:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000085 std::vector<ITensor *> _inputs_vector;
86 std::unique_ptr<NEDepthConcatenateLayerKernel[]> _concat_kernels_vector;
87 std::unique_ptr<NEFillBorderKernel[]> _border_handlers_vector;
88 unsigned int _num_inputs;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010089};
90}
91#endif /* __ARM_COMPUTE_NEDEPTHCONCATENATE_H__ */