embeddingbag_offsets_sum.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/axis_set.hpp"
8 #include "ngraph/op/util/embeddingbag_offsets_base.hpp"
9 #include "ngraph/op/util/index_reduction.hpp"
10 
11 namespace ngraph
12 {
13  namespace op
14  {
15  namespace v3
16  {
17  /// \brief Returns embeddings for given indices
19  {
20  public:
21  static constexpr NodeTypeInfo type_info{"EmbeddingBagOffsetsSum", 3};
22  const NodeTypeInfo& get_type_info() const override { return type_info; }
23  /// \brief Constructs a EmbeddingBagOffsetsSum operation.
25  /// \brief Constructs a EmbeddingBagOffsetsSum operation.
26  ///
27  /// EmbeddingBagOffsetsSum constructs an output tensor by replacing every index in a
28  /// given
29  /// input tensor with a row (from the weights matrix) at that index
30  ///
31  /// \param emb_table tensor containing the embedding lookup table of the module of
32  /// shape [num_emb, emb_dim1, emb_dim2, ...] and of type T
33  /// \param tensor of shape [num_indices] and of type T_IND. Required
34  /// \param offsets tensor of shape [batch] and of type T_IND containing the starting
35  /// index positions of each "bag" in indices. Required.
36  /// \param default_index scalar of type T_IND containing default index in embedding
37  /// table to fill empty "bags". If not provided empty "bags"
38  /// are filled with zeros. Optional.
39  /// \param per_sample_weigths tensor of the same shape as indices and of type T.
40  /// Each value in this tensor are multiplied with each
41  /// value pooled from embedding table for each index. Optional.
42 
44  const Output<Node>& indices,
45  const Output<Node>& offsets,
46  const Output<Node>& default_index,
47  const Output<Node>& per_sample_weights);
48 
49  EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
50  const Output<Node>& indices,
51  const Output<Node>& offsets,
52  const Output<Node>& default_index);
53 
54  EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
55  const Output<Node>& indices,
56  const Output<Node>& offsets);
57 
58  virtual std::shared_ptr<Node>
59  clone_with_new_inputs(const OutputVector& new_args) const override;
60  };
61  } // namespace v3
63  } // namespace op
64 } // namespace ngraph
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Returns embeddings for given indices.
Definition: embeddingbag_offsets_base.hpp:18
Returns embeddings for given indices.
Definition: embeddingbag_offsets_sum.hpp:19
EmbeddingBagOffsetsSum()=default
Constructs a EmbeddingBagOffsetsSum operation.
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.
const NodeTypeInfo & get_type_info() const override
Definition: embeddingbag_offsets_sum.hpp:22
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27