Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / src / lookup_table.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 ///////////////////////////////////////////////////////////////////////////////////////////////////
18 #include "lookup_table_inst.h"
19 #include "primitive_type_base.h"
20 #include "sliding_window_utils.h"
21 #include "error_handler.h"
22 #include "json_object.h"
23
24 namespace cldnn
25 {
26     primitive_type_id lookup_table_type_id()
27     {
28         static primitive_type_base<lookup_table> instance;
29         return &instance;
30     }
31
32     layout lookup_table_inst::calc_output_layout(lookup_table_node const& node)
33     {
34         assert((bool)node.get_primitive()->output_data_type == false
35                && "Output data type forcing is not supported for "
36                   "lookup_table_node!");
37         auto desc = node.get_primitive();
38
39         auto input_data_layout = node.input().get_output_layout();
40         auto input_indices_layout = node.indices().get_output_layout();
41
42         return layout{ input_data_layout.data_type, input_data_layout.format, input_indices_layout.size };
43     }
44
45     std::string lookup_table_inst::to_string(lookup_table_node const& node)
46     {
47         auto desc = node.get_primitive();
48         auto node_info = node.desc_to_json();
49         auto axis = desc->with_axis ? "true" : "false";
50
51         std::stringstream primitive_description;
52
53         json_composite conv_info;
54         conv_info.add("with axis", axis);
55         if (desc->with_axis)
56             conv_info.add("axis", desc->axis);
57         node_info->add("lookup_table info", conv_info);
58         node_info->dump(primitive_description);
59
60         return primitive_description.str();
61     }
62
63     lookup_table_inst::typed_primitive_inst(network_impl& network, lookup_table_node const& node)
64         : parent(network, node)
65     {
66     }
67 }