2 // Copyright (c) 2018 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 #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"
25 primitive_type_id tile_type_id()
27 static primitive_type_base<tile> instance;
31 layout tile_inst::calc_output_layout(tile_node const& node)
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();
37 auto input_layout = node.input().get_output_layout();
38 auto input_format = input_layout.format;
39 auto result_sizes = input_layout.size.sizes();
41 auto axis_index = node.get_primitive()->axis;
42 auto tiles = node.get_primitive()->tiles;
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 };
49 std::string tile_inst::to_string(tile_node const& node)
51 auto desc = node.get_primitive();
52 auto node_info = node.desc_to_json();
53 auto& input = node.input();
55 std::stringstream primitive_description;
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);
62 node_info->add("tile info", tile_info);
63 node_info->dump(primitive_description);
65 return primitive_description.str();
68 tile_inst::typed_primitive_inst(network_impl& network, tile_node const& node)
69 :parent(network, node)