blob: 376534275f35d63670ef06c379b92a77356c2033 [file] [log] [blame]
Georgios Pinitas61ba0692021-01-10 04:07:39 +00001/*
2 * Copyright (c) 2021 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_CPU_CONCATENATE_H
25#define ARM_COMPUTE_CPU_CONCATENATE_H
26
27#include "src/core/cpu/ICpuKernel.h"
28#include "src/runtime/cpu/ICpuOperator.h"
29
30#include <vector>
31
32namespace arm_compute
33{
34namespace cpu
35{
36/** Basic function to execute concatenate tensors along a given axis. This function calls the following kernels:
37 *
38 * -# @ref CpuConcatenateWidthKernel (if underlying concatenation axis is 0).
39 * -# @ref CpuConcatenateHeightKernel (if underlying concatenation axis is 1).
40 * -# @ref CpuConcatenateDepthKernel (if underlying concatenation axis is 2).
41 * -# @ref CpuConcatenateBatchKernel (if underlying concatenation axis is 3).
42 */
43class CpuConcatenate : public ICpuOperator
44{
45public:
46 /** Constructor */
47 CpuConcatenate();
48 /** Configure operator for a given list of arguments
49 *
50 * @note Input and output tensor dimensions preconditions defer depending on the concatenation axis.
51 * @note Preconditions can be found respectively at @ref CpuConcatenateWidthKernel, @ref CpuConcatenateHeightKernel, @ref CpuConcatenateDepthKernel and @ref CpuConcatenateBatchKernel.
52 *
53 * @param[in,out] srcs_vector The vectors containing all the tensors to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
54 * @param[out] dst Output tensor. Data types supported: Same as @p srcs_vector.
55 * @param[in] axis Concatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.
56 */
57 void configure(const std::vector<const ITensorInfo *> &srcs_vector, ITensorInfo *dst, size_t axis);
58 /** Static function to check if given info will lead to a valid configuration of @ref NEConcatenateLayer
59 *
60 * @note Input and output tensor dimensions preconditions defer depending on the concatenation axis.
61 * @note Preconditions can be found respectively at @ref CpuConcatenateWidthKernel, @ref CpuConcatenateHeightKernel, @ref CpuConcatenateDepthKernel and @ref CpuConcatenateBatchKernel.
62 *
63 * @param[in] srcs_vector The vectors containing all the tensors info to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
64 * @param[in] dst Output tensor info. Data types supported: Same as @p srcs_vector.
65 * @param[in] axis Concatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.
66 *
67 * @return a status
68 */
69 static Status validate(const std::vector<const ITensorInfo *> &srcs_vector, const ITensorInfo *dst, size_t axis);
70
71 // Inherited methods overridden:
72 void run(ITensorPack &tensors) override;
73
74private:
75 std::vector<std::unique_ptr<ICpuKernel>> _concat_kernels;
76 unsigned int _num_srcs;
77 unsigned int _axis;
78};
79} // namespace cpu
80} // namespace arm_compute
81#endif /* ARM_COMPUTE_CPU_CONCATENATE_H */