blob: d2af3e2ad216474ff5f5713084ed07223e75c128 [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 *
Michele Di Giorgiobd2c8e12021-01-19 15:29:02 +000038 * -# @ref kernels::CpuConcatenateWidthKernel (if underlying concatenation axis is 0).
39 * -# @ref kernels::CpuConcatenateHeightKernel (if underlying concatenation axis is 1).
40 * -# @ref kernels::CpuConcatenateDepthKernel (if underlying concatenation axis is 2).
41 * -# @ref kernels::CpuConcatenateBatchKernel (if underlying concatenation axis is 3).
Georgios Pinitas61ba0692021-01-10 04:07:39 +000042 */
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.
Michele Di Giorgiobd2c8e12021-01-19 15:29:02 +000051 * @note Preconditions can be found respectively at @ref kernels::CpuConcatenateWidthKernel, @ref kernels::CpuConcatenateHeightKernel,
52 * @ref kernels::CpuConcatenateDepthKernel and @ref kernels::CpuConcatenateBatchKernel.
Georgios Pinitas61ba0692021-01-10 04:07:39 +000053 *
54 * @param[in,out] srcs_vector The vectors containing all the tensors to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
55 * @param[out] dst Output tensor. Data types supported: Same as @p srcs_vector.
56 * @param[in] axis Concatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.
57 */
58 void configure(const std::vector<const ITensorInfo *> &srcs_vector, ITensorInfo *dst, size_t axis);
59 /** Static function to check if given info will lead to a valid configuration of @ref NEConcatenateLayer
60 *
61 * @note Input and output tensor dimensions preconditions defer depending on the concatenation axis.
Michele Di Giorgiobd2c8e12021-01-19 15:29:02 +000062 * @note Preconditions can be found respectively at @ref kernels::CpuConcatenateWidthKernel, @ref kernels::CpuConcatenateHeightKernel,
63 * @ref kernels::CpuConcatenateDepthKernel and @ref kernels::CpuConcatenateBatchKernel.
Georgios Pinitas61ba0692021-01-10 04:07:39 +000064 *
65 * @param[in] srcs_vector The vectors containing all the tensors info to concatenate. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
66 * @param[in] dst Output tensor info. Data types supported: Same as @p srcs_vector.
67 * @param[in] axis Concatenation axis. Supported underlying concatenation axis are 0, 1, 2 and 3.
68 *
69 * @return a status
70 */
71 static Status validate(const std::vector<const ITensorInfo *> &srcs_vector, const ITensorInfo *dst, size_t axis);
72
73 // Inherited methods overridden:
74 void run(ITensorPack &tensors) override;
75
76private:
77 std::vector<std::unique_ptr<ICpuKernel>> _concat_kernels;
78 unsigned int _num_srcs;
79 unsigned int _axis;
80};
81} // namespace cpu
82} // namespace arm_compute
83#endif /* ARM_COMPUTE_CPU_CONCATENATE_H */