2 // Copyright (c) 2016 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 #include "../C/concatenation.h"
20 #include "primitive.hpp"
24 /// @addtogroup cpp_api C++ API
26 /// @addtogroup cpp_topology Network Topology
28 /// @addtogroup cpp_primitives Primitives
31 /// @details Concatenation is used to concatenate multiple sources into one destination along specified dimension.
33 /// - all other dimensions (except the one along which concatenation take place) must have the same value in each source.
34 /// - order of arguments in primitive creation has impact on order of feature maps in output primitive.
41 /// for(f : i.features)
43 /// output[outputIdx] = f
49 /// @li input : data structure holding all source inputs for this primitive
50 /// @li output : data structure holding output data for this primitive
51 /// @li i.features : number of features in currently processed input
52 /// @li outputIdx : index of destination feature
53 struct concatenation : public primitive_base<concatenation, CLDNN_PRIMITIVE_DESC(concatenation)>
55 CLDNN_DECLARE_PRIMITIVE(concatenation)
57 enum concatenation_axis
59 along_b = cldnn_concatenation_along_b,
60 along_f = cldnn_concatenation_along_f,
61 along_x = cldnn_concatenation_along_x,
62 along_y = cldnn_concatenation_along_y
65 /// @li Constructs concatenation primitive.
66 /// @param id This primitive id.
67 /// @param input Vector of input primitives ids.
68 /// @param axis Selected dimension for concatenation.
70 const primitive_id& id,
71 const std::vector<primitive_id>& input,
72 const concatenation_axis axis,
73 const padding& output_padding = padding()
75 :primitive_base(id, { input }, output_padding)
79 /// @brief Constructs a copy from C API @CLDNN_PRIMITIVE_DESC(depth_concatenate)
80 concatenation(const dto* dto)
82 , axis(static_cast<concatenation_axis>(dto->axis))
85 /// @brief Dimension along which concatenation should take place
86 concatenation_axis axis;
89 void update_dto(dto& dto) const override
91 dto.axis = static_cast<cldnn_concatenation_axis>(axis);