Publishing 2019 R2 content (#223)
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / CPP / input_layout.hpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
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
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #pragma once
19 #include "../C/input_layout.h"
20 #include "primitive.hpp"
21 #include "memory.hpp"
22
23 namespace cldnn {
24 /// @addtogroup cpp_api C++ API
25 /// @{
26 /// @addtogroup cpp_topology Network Topology
27 /// @{
28 /// @addtogroup cpp_primitives Primitives
29 /// @{
30
31 /// @brief Provides input layout for a data to be passed later to network.
32 /// @details This primitive allows to define the layout for input data
33 /// which will be passed to network before execution.
34 /// For example, network input images.
35 /// @note User should call network::set_input_data() for every @p input_layout primitive before network execution.
36 /// @note @p output_padding property of @p input_layout is ignored - its output layout is always equal to input layout defined during object creation.
37 /// @sa network::set_input_data(), cldnn::data
38 struct input_layout : public primitive_base<input_layout, CLDNN_PRIMITIVE_DESC(input_layout)> {
39     CLDNN_DECLARE_PRIMITIVE(input_layout)
40
41     /// @brief Constructs input layout primitive.
42     /// @param id This primitive id.
43     /// @param layout Defines layout for the data will be passed to network.
44     input_layout(const primitive_id& id, const layout& layout)
45         : primitive_base(id, {}, layout.data_padding), layout(layout) {}
46
47     /// @brief Constructs a copy from C API @CLDNN_PRIMITIVE_DESC{input_layout}
48     explicit input_layout(const dto* dto)
49         : primitive_base(dto), layout(dto->layout) {
50         output_padding = layout.data_padding;
51     }
52
53     /// @brief Defines layout for the data will be passed to network.
54     mutable cldnn::layout layout;
55
56     void change_layout(cldnn::layout new_layout) {
57         layout = new_layout;
58     }
59
60 private:
61     void update_dto(dto& dto) const override {
62         dto.layout = layout;
63     }
64 };
65 /// @}
66 /// @}
67 /// @}
68 }  // namespace cldnn