embeddingbag_offsets_sum.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 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 #pragma once
18 
19 #include "ngraph/axis_set.hpp"
20 #include "ngraph/op/util/embeddingbag_offsets_base.hpp"
21 #include "ngraph/op/util/index_reduction.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v3
28  {
29  /// \brief Returns embeddings for given indices
31  {
32  public:
33  static constexpr NodeTypeInfo type_info{"EmbeddingBagOffsetsSum", 3};
34  const NodeTypeInfo& get_type_info() const override { return type_info; }
35  /// \brief Constructs a EmbeddingBagOffsetsSum operation.
37  /// \brief Constructs a EmbeddingBagOffsetsSum operation.
38  ///
39  /// EmbeddingBagOffsetsSum constructs an output tensor by replacing every index in a
40  /// given
41  /// input tensor with a row (from the weights matrix) at that index
42  ///
43  /// \param emb_table tensor containing the embedding lookup table of the module of
44  /// shape [num_emb, emb_dim1, emb_dim2, ...] and of type T
45  /// \param tensor of shape [num_indices] and of type T_IND. Required
46  /// \param offsets tensor of shape [batch] and of type T_IND containing the starting
47  /// index positions of each "bag" in indices. Required.
48  /// \param default_index scalar of type T_IND containing default index in embedding
49  /// table to fill empty "bags". If not provided empty "bags"
50  /// are filled with zeros. Optional.
51  /// \param per_sample_weigths tensor of the same shape as indices and of type T.
52  /// Each value in this tensor are multiplied with each
53  /// value pooled from embedding table for each index. Optional.
54 
55  EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
56  const Output<Node>& indices,
57  const Output<Node>& offsets,
58  const Output<Node>& default_index,
59  const Output<Node>& per_sample_weights);
60 
61  EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
62  const Output<Node>& indices,
63  const Output<Node>& offsets,
64  const Output<Node>& default_index);
65 
66  EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
67  const Output<Node>& indices,
68  const Output<Node>& offsets);
69 
70  virtual std::shared_ptr<Node>
71  clone_with_new_inputs(const OutputVector& new_args) const override;
72  };
73  }
75  }
76 }
ngraph::op::v3::EmbeddingBagOffsetsSum::EmbeddingBagOffsetsSum
EmbeddingBagOffsetsSum(const Output< Node > &emb_table, const Output< Node > &indices, const Output< Node > &offsets, const Output< Node > &default_index, const Output< Node > &per_sample_weights)
Constructs a EmbeddingBagOffsetsSum operation.
ngraph::op::v3::EmbeddingBagOffsetsSum::EmbeddingBagOffsetsSum
EmbeddingBagOffsetsSum()=default
Constructs a EmbeddingBagOffsetsSum operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v3::EmbeddingBagOffsetsSum
Returns embeddings for given indices.
Definition: embeddingbag_offsets_sum.hpp:31
ngraph::op::util::EmbeddingBagOffsetsBase
Returns embeddings for given indices.
Definition: embeddingbag_offsets_base.hpp:30
ngraph::op::v3::EmbeddingBagOffsetsSum::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: embeddingbag_offsets_sum.hpp:34