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 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #include "select_inst.h"
19 #include "primitive_type_base.h"
20 #include "error_handler.h"
21 #include "json_object.h"
25 primitive_type_id select_type_id()
27 static primitive_type_base<select> instance;
31 layout select_inst::calc_output_layout(select_node const& node)
33 assert((bool)node.get_primitive()->output_data_type == false
34 && "Output data type forcing is not supported for select_node!");
35 return node.input().get_non_padded_output_layout();
38 std::string select_inst::to_string(select_node const& node)
40 auto node_info = node.desc_to_json();
41 auto desc = node.get_primitive();
43 std::stringstream primitive_description;
45 json_composite select_info;
46 for (size_t i = 0; i < node.inputs_count(); i++)
48 select_info.add("input_"+std::to_string(i), node.input(i).id());
51 node_info->add("select info", select_info);
52 node_info->dump(primitive_description);
54 return primitive_description.str();
57 select_inst::typed_primitive_inst(network_impl& network, select_node const& node)
58 :parent(network, node)
60 auto& deps = node.get_dependencies();
62 for (size_t i = 0; i < deps.size() - 1; i++)
64 auto batch1 = deps[i]->get_output_layout().size.batch[0];
65 auto batch2 = deps[i+1]->get_output_layout().size.batch[0];
66 CLDNN_ERROR_NOT_EQUAL(node.id(), "Batch size input", batch1, "Batch size next input", batch2, "");
68 auto feature1 = deps[i]->get_output_layout().size.feature[0];
69 auto feature2 = deps[i+1]->get_output_layout().size.feature[0];
70 CLDNN_ERROR_NOT_EQUAL(node.id(), "Feature size input", feature1, "Feature size next input", feature2, "");
72 auto spatial1 = deps[i]->get_output_layout().size.spatial[0];
73 auto spatial2 = deps[i + 1]->get_output_layout().size.spatial[0];
74 CLDNN_ERROR_NOT_EQUAL(node.id(), "Spatial size input", spatial1, "Spatial size next input", spatial2, "");
76 auto format1 = deps[i]->get_output_layout().format;
77 auto format2 = deps[i+1]->get_output_layout().format;
78 CLDNN_ERROR_NOT_EQUAL(node.id(), "Format input", format1, "Format next input", format2, "");
81 auto data_type1 = deps[0]->get_output_layout().data_type;
82 auto data_type2 = deps[1]->get_output_layout().data_type;
83 CLDNN_ERROR_DATA_TYPES_MISMATCH(node.id(), "Data type input 1", data_type1, "Data type input 2", data_type2, "");