2 // Copyright (c) 2017 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/reshape.h"
20 #include "primitive.hpp"
24 /// @addtogroup cpp_api C++ API
26 /// @addtogroup cpp_topology Network Topology
28 /// @addtogroup cpp_primitives Primitives
31 /// @brief Changes information about inputs's layout effectively creating new memory which share underlaying buffer
32 /// but is interpreted in a different way (different shape).
33 /// @note reshape primitive is supposed only to reinterpret shape of the memory therefore it's not possible to change
34 /// neither data type nor format of the input buffer and total number of elements in input and output (excluding paddings) must match.
35 /// Please note that there is no guarantee that underlying data will be in proper format if primitive was explicitly added to output list.
36 struct reshape : public primitive_base<reshape, CLDNN_PRIMITIVE_DESC(reshape)>
38 CLDNN_DECLARE_PRIMITIVE(reshape)
40 /// @brief Constructs reshape primitive.
41 /// @param id This primitive id.
42 /// @param input Input primitive id.
43 /// @param output_shape Requested memory shape (excluding padding).
44 /// A dimension could be 0, in this case, the value is taken from the input tensor.
45 /// At most one dimension of the new shape can be -1. In this case, the value is inferred from the size of the tensor and the remaining dimensions.
46 /// @param output_padding Requested memory padding.
48 const primitive_id& id,
49 const primitive_id& input,
50 const tensor& output_shape,
51 const padding& output_padding = padding()
53 : primitive_base(id, { input }, output_padding)
54 , output_shape(output_shape)
58 /// @brief Constructs a copy from basic C API @CLDNN_PRIMITIVE_DESC{reshape}
59 reshape(const dto* dto)
61 , output_shape(dto->output_shape)
65 /// @brief Requested memory shape.
69 void update_dto(dto& dto) const override
71 dto.output_shape = output_shape;