Publishing R3
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / CPP / lookup_table.hpp
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 #pragma once
19 #include "../C/lookup_table.h"
20 #include "primitive.hpp"
21
22 namespace cldnn
23 {
24     /// @addtogroup cpp_api C++ API
25     /// @{
26     /// @addtogroup cpp_topology Network Topology
27     /// @{
28     /// @addtogroup cpp_primitives Primitives
29     /// @{
30
31     /// @brief Returns values from data on which given indices are pointing at.
32     struct lookup_table : public primitive_base<lookup_table, CLDNN_PRIMITIVE_DESC(lookup_table)>
33     {
34         CLDNN_DECLARE_PRIMITIVE(lookup_table)
35
36         /// @brief Enum type to specify axis to maximize/minimize along.
37         enum axis_name
38         {
39             batch,
40             feature,
41             x,
42             y,
43             xyf
44         };
45
46         /// @brief Constructs lookup_table primitive.
47         /// @param id This primitive id.
48         /// @param input_data Input data primitive id.
49         /// @param input_indices Input indices primitive id.
50         /// @param axis Axis to return values from.
51         lookup_table(
52             const primitive_id& id,
53             const primitive_id& input_data,
54             const primitive_id& input_indices,
55             axis_name axis = axis_name::xyf,
56             const padding& output_padding = padding()
57         )
58             :primitive_base(id, { input_data, input_indices }, output_padding)
59             , axis(axis)
60             , with_axis(axis == axis_name::xyf ? false : true)
61         {}
62
63         /// @brief Constructs a copy from C API @CLDNN_PRIMITIVE_DESC{lookup_table}
64         lookup_table(const dto* dto)
65             :primitive_base(dto)
66             , axis(static_cast<axis_name>(dto->axis))
67             , with_axis(dto->with_axis != 0)
68         {}
69
70         /// @brief Axis to return values from. If not set, returns data which index is pointing at in the flattened x, y, f dimensions for each batch.
71         axis_name axis;
72         /// @brief Indicates that the primitive has user defined axis to return values from.
73         bool with_axis;
74
75     protected:
76
77         void update_dto(dto& dto) const override
78         {
79             dto.with_axis = with_axis;
80             dto.axis = static_cast<cldnn_lookup_table_axis>(axis);
81         }
82     };
83     /// @}
84     /// @}
85     /// @}
86 }