embeddingbag_packedsum.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_packed_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{"EmbeddingBagPackedSum", 3};
34  const NodeTypeInfo& get_type_info() const override { return type_info; }
35  /// \brief Constructs a EmbeddingBagPackedSum operation.
36  EmbeddingBagPackedSum() = default;
37  /// \brief Constructs a EmbeddingBagPackedSum operation.
38  ///
39  /// EmbeddingBagPackedSum 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 indices Tensor of shape `[batch, indices_per_bag]` and of type *T_IND*.
46  /// Required.
47  /// \param per_sample_weigths tensor of the same shape as indices and of type T.
48  /// Each value in this tensor are multiplied with each
49  /// value pooled from embedding table for each index. Optional.
50 
51  EmbeddingBagPackedSum(const Output<Node>& emb_table,
52  const Output<Node>& indices,
53  const Output<Node>& per_sample_weights);
54 
55  EmbeddingBagPackedSum(const Output<Node>& emb_table, const Output<Node>& indices);
56 
57  virtual std::shared_ptr<Node>
58  clone_with_new_inputs(const OutputVector& new_args) const override;
59  };
60  }
62  }
63 }
ngraph::op::v3::EmbeddingBagPackedSum::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: embeddingbag_packedsum.hpp:34
ngraph::op::v3::EmbeddingBagPackedSum::EmbeddingBagPackedSum
EmbeddingBagPackedSum(const Output< Node > &emb_table, const Output< Node > &indices, const Output< Node > &per_sample_weights)
Constructs a EmbeddingBagPackedSum operation.
ngraph::op::util::EmbeddingBagPackedBase
Returns embeddings for given indices.
Definition: embeddingbag_packed_base.hpp:30
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v3::EmbeddingBagPackedSum
Returns embeddings for given indices.
Definition: embeddingbag_packedsum.hpp:31
ngraph::op::v3::EmbeddingBagPackedSum::EmbeddingBagPackedSum
EmbeddingBagPackedSum()=default
Constructs a EmbeddingBagPackedSum operation.