blob: 81e98f1ba2c5d43a8550658d417c197d940fa598 [file] [log] [blame]
Michalis Spyroua9c44722019-04-05 17:18:36 +01001/*
Matthew Bentham92046462020-03-07 22:15:55 +00002 * Copyright (c) 2019-2020 ARM Limited.
Michalis Spyroua9c44722019-04-05 17:18:36 +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#include "arm_compute/runtime/GLES_COMPUTE/functions/GCConcatenateLayer.h"
25
26#include "arm_compute/core/Error.h"
27#include "arm_compute/core/GLES_COMPUTE/IGCTensor.h"
28#include "arm_compute/core/PixelValue.h"
29#include "arm_compute/core/Types.h"
30#include "arm_compute/core/utils/misc/ShapeCalculator.h"
31#include "arm_compute/runtime/GLES_COMPUTE/GCScheduler.h"
Matthew Bentham92046462020-03-07 22:15:55 +000032#include "support/MemorySupport.h"
Michalis Spyroua9c44722019-04-05 17:18:36 +010033
34namespace arm_compute
35{
36GCConcatenateLayer::GCConcatenateLayer()
37 : _concat_kernels(),
38 _num_inputs(0),
39 _axis(Window::DimZ)
40{
41}
42
43void GCConcatenateLayer::configure(std::vector<IGCTensor *> inputs_vector, IGCTensor *output, size_t axis)
44{
45 ARM_COMPUTE_ERROR_ON(inputs_vector.size() < 2);
46
47 _num_inputs = inputs_vector.size();
48 _axis = axis;
49
50 TensorShape output_shape = arm_compute::misc::shape_calculator::calculate_concatenate_shape(inputs_vector, axis);
51
52 // Output auto inizialitation if not yet initialized
53 auto_init_if_empty(*output->info(), output_shape, 1, inputs_vector[0]->info()->data_type());
54
55 unsigned int offset = 0;
56 switch(axis)
57 {
58 case Window::DimZ:
59 {
60 for(unsigned int i = 0; i < _num_inputs; ++i)
61 {
62 auto kernel = support::cpp14::make_unique<GCDepthConcatenateLayerKernel>();
63 kernel->configure(inputs_vector.at(i), offset, output);
64 offset += inputs_vector.at(i)->info()->dimension(axis);
65 _concat_kernels.emplace_back(std::move(kernel));
66 }
67 break;
68 }
69 default:
70 ARM_COMPUTE_ERROR("Axis not supported");
71 }
72}
73
74void GCConcatenateLayer::run()
75{
76 for(auto &kernel : _concat_kernels)
77 {
78 GCScheduler::get().dispatch(*kernel, true);
79 }
80}
81} // namespace arm_compute