Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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_NEDEPTHCONCATENATE_H__ |
| 25 | #define __ARM_COMPUTE_NEDEPTHCONCATENATE_H__ |
| 26 | |
| 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 29 | #include "arm_compute/core/NEON/kernels/NEDepthConcatenateLayerKernel.h" |
Georgios Pinitas | ac4e873 | 2017-07-05 17:02:25 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h" |
| 31 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 32 | #include <memory> |
| 33 | #include <vector> |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | class ITensor; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 38 | |
| 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 Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 42 | * -# @ref NEDepthConcatenateLayerKernel |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 43 | * |
| 44 | */ |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 45 | class NEDepthConcatenateLayer : public IFunction |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 46 | { |
| 47 | public: |
| 48 | /** Default constructor */ |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 49 | NEDepthConcatenateLayer(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | /** Initialise the kernel's inputs vector and output. |
| 51 | * |
Georgios Pinitas | ae54e02 | 2018-07-16 15:41:27 +0100 | [diff] [blame] | 52 | * @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 Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 62 | */ |
Georgios Pinitas | ae54e02 | 2018-07-16 15:41:27 +0100 | [diff] [blame] | 63 | 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 Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 80 | |
| 81 | // Inherited methods overridden: |
| 82 | void run() override; |
| 83 | |
| 84 | private: |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 85 | 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 Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 89 | }; |
| 90 | } |
| 91 | #endif /* __ARM_COMPUTE_NEDEPTHCONCATENATE_H__ */ |