2 // Copyright (c) 2019 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 "gather_inst.h"
19 #include "primitive_type_base.h"
20 #include "error_handler.h"
21 #include "json_object.h"
25 primitive_type_id gather_type_id()
27 static primitive_type_base<gather> instance;
31 layout gather_inst::calc_output_layout(gather_node const& node)
33 auto desc = node.get_primitive();
35 auto input_layout = node.input(1).get_output_layout();
36 auto input_format = input_layout.format;
38 auto input_shape = node.get_primitive()->output_shape;
41 return layout{input_layout.data_type, input_format, input_shape};
44 std::string gather_inst::to_string(gather_node const& node)
46 auto desc = node.get_primitive();
47 auto node_info = node.desc_to_json();
48 auto& input = node.input();
50 std::stringstream primitive_description;
52 json_composite gather_info;
53 gather_info.add("input id", input.id());
54 gather_info.add("axis", desc->axis);
55 gather_info.add("output shape", desc->output_shape.to_string());
57 node_info->add("gather info", gather_info);
58 node_info->dump(primitive_description);
60 return primitive_description.str();
63 gather_inst::typed_primitive_inst(network_impl& network, gather_node const& node)
64 : parent(network, node)