Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / tile.cpp
1 /*
2 // Copyright (c) 2018 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 #include "tile_inst.h"
18 #include "primitive_type_base.h"
19 #include "memory_impl.h"
20 #include "error_handler.h"
21 #include "json_object.h"
22
23 namespace cldnn
24 {
25 primitive_type_id tile_type_id()
26 {
27     static primitive_type_base<tile> instance;
28     return &instance;
29 }
30
31 layout tile_inst::calc_output_layout(tile_node const& node)
32 {
33     assert((bool)node.get_primitive()->output_data_type == false
34            && "Output data type forcing is not supported for tile_node!");
35     auto desc = node.get_primitive();
36
37     auto input_layout = node.input().get_output_layout();
38     auto input_format = input_layout.format;
39     auto result_sizes = input_layout.size.sizes();
40
41     auto axis_index = node.get_primitive()->axis;
42     auto tiles = node.get_primitive()->tiles;
43
44     // calculate sum of features from all inputs
45     result_sizes[axis_index] *= tiles;
46     return layout{ input_layout.data_type, input_format, result_sizes };
47 }
48
49 std::string tile_inst::to_string(tile_node const& node)
50 {
51     auto desc           = node.get_primitive();
52     auto node_info      = node.desc_to_json();
53     auto& input         = node.input();
54     
55     std::stringstream primitive_description;
56
57     json_composite tile_info;
58     tile_info.add("input id", input.id());
59     tile_info.add("axis", desc->axis);
60     tile_info.add("tiles", desc->tiles);
61     
62     node_info->add("tile info", tile_info);
63     node_info->dump(primitive_description);
64
65     return primitive_description.str();
66 }
67
68 tile_inst::typed_primitive_inst(network_impl& network, tile_node const& node)
69     :parent(network, node)
70 {
71 }
72
73 }