Publishing 2019 R2 content (#223)
[platform/upstream/dldt.git] / inference-engine / thirdparty / clDNN / api / embed.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 "primitive.hpp"
20 #include <vector>
21
22 namespace cldnn {
23 /// @addtogroup cpp_api C++ API
24 /// @{
25 /// @addtogroup cpp_topology Network Topology
26 /// @{
27 /// @addtogroup cpp_primitives Primitives
28 /// @{
29
30 /// @brief
31 /// @details Performs embedding upon input.
32 /// @n\b Example:
33 /// @n input_size = { 8, 1, 1, 75 };
34 /// @n weights_size = {15, 1, 62, 1 };
35 /// @n output_size = { 8, 75, 15, 1 };
36 /// @par Algorithm:
37 /// @par Where:
38 struct embed : public primitive_base<embed> {
39     CLDNN_DECLARE_PRIMITIVE(embed)
40
41     /// @brief Constructs embed primitive.
42     /// @param id This primitive id.
43     /// @param input Input primitive id.
44     /// @param weights Primitive id containing weights data.
45     /// @param bias Primitive id containing bias data.
46     embed(
47         const primitive_id& id,
48         const primitive_id& input,
49         const primitive_id& weights,
50         const primitive_id& bias)
51         : primitive_base(id, {input}), weights(weights), bias(bias) {}
52
53     /// @brief Constructs embed primitive.
54     /// @param id This primitive id.
55     /// @param input Input primitive id.
56     embed(
57         const primitive_id& id,
58         const primitive_id& input,
59         const primitive_id& weights)
60         : primitive_base(id, {input}), weights(weights), bias("") {}
61
62     /// @brief Primitive id containing weights data.
63     primitive_id weights;
64     /// @brief Primitive id containing bias data.
65     primitive_id bias;
66
67 protected:
68     std::vector<std::reference_wrapper<const primitive_id>> get_dependencies() const override {
69         if (bias.empty())
70             return {weights};
71         else
72             return {weights, bias};
73     }
74 };
75 /// @}
76 /// @}
77 /// @}
78 }  // namespace cldnn
79 #pragma once