Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / CPP / gather.hpp
1 /*
2 // Copyright (c) 2019 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/gather.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
32 /// @details
33 struct gather : public primitive_base<gather, CLDNN_PRIMITIVE_DESC(gather)>
34 {
35     CLDNN_DECLARE_PRIMITIVE(gather)
36
37     enum gather_axis
38     {
39         along_b = cldnn_gather_along_b,
40         along_f = cldnn_gather_along_f,
41         along_x = cldnn_gather_along_x,
42         along_y = cldnn_gather_along_y
43     };
44
45     /// @brief Constructs gather primitive.
46     /// @param id This primitive id.
47     /// @param dict Input dictionary primitive id.
48     /// @param idx Input indexes primitive id.
49     /// @param axis Gathering axis.
50     /// @param output_shape Output shape.
51     gather(
52             const primitive_id& id,
53             const primitive_id& dict,
54             const primitive_id& idx,
55             const gather_axis axis,
56             const tensor& output_shape,
57             const padding& output_padding = padding()
58     )
59             : primitive_base(id, {dict, idx}, output_padding)
60             , axis(axis)
61             , output_shape(output_shape)
62     {
63     }
64
65     /// @brief Constructs a copy from C API @CLDNN_PRIMITIVE_DESC{gather}
66     gather(const dto* dto)
67             : primitive_base(dto)
68             , axis(static_cast<gather_axis >(dto->axis))
69             , output_shape(dto->output_shape)
70     {
71     }
72
73     /// @brief Gathering axis
74     gather_axis axis;
75     /// @brief Gathering input shape
76     tensor output_shape;
77 protected:
78
79     void update_dto(dto& dto) const override
80     {
81         dto.axis = static_cast<cldnn_gather_axis>(axis);
82         dto.output_shape = output_shape;
83     }
84 };
85 /// @}
86 /// @}
87 /// @}
88 }