Skip to content

Commit

Permalink
Fix tests and broken backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikolajcz committed May 16, 2024
1 parent e631787 commit 9991ca3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/core/include/openvino/op/util/embeddingbag_offsets_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ class OPENVINO_API EmbeddingBagOffsetsBase : public Op {
/// \param default_index scalar of type T_IND containing default index in embedding
/// table to fill empty "bags". If not provided empty "bags"
/// are filled with zeros. Optional.
EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
const Output<Node>& default_index,
const Output<Node>& per_sample_weights);

EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
const Output<Node>& default_index);

EmbeddingBagOffsetsBase(const Output<Node>& emb_table, const Output<Node>& indices, const Output<Node>& offsets);

EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
Expand Down Expand Up @@ -71,7 +83,7 @@ class OPENVINO_API EmbeddingBagOffsetsBase : public Op {
static constexpr int PER_SAMPLE_WEIGHTS = 4;

protected:
Reduction m_reduction = Reduction::MEAN;
Reduction m_reduction = Reduction::SUM;
};
} // namespace util
} // namespace op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class OPENVINO_API EmbeddingBagPackedBase : public Op {
/// \param per_sample_weights tensor of the same shape as indices and of type T.
/// Each value in this tensor are multiplied with each
/// value pooled from embedding table for each index. Optional.
EmbeddingBagPackedBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& per_sample_weights);

EmbeddingBagPackedBase(const Output<Node>& emb_table, const Output<Node>& indices);

EmbeddingBagPackedBase(const Output<Node>& emb_table,
const Output<Node>& indices,
Expand All @@ -51,7 +56,7 @@ class OPENVINO_API EmbeddingBagPackedBase : public Op {
static constexpr int PER_SAMPLE_WEIGHTS = 2;

protected:
Reduction m_reduction = Reduction::MEAN;
Reduction m_reduction = Reduction::SUM;
};
} // namespace util
} // namespace op
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/op/embeddingbag_offsets_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ op::v3::EmbeddingBagOffsetsSum::EmbeddingBagOffsetsSum(const Output<Node>& emb_t
const Output<Node>& offsets,
const Output<Node>& default_index,
const Output<Node>& per_sample_weights)
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets, default_index, per_sample_weights, Reduction::SUM) {}
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets, default_index, per_sample_weights) {}

op::v3::EmbeddingBagOffsetsSum::EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
const Output<Node>& default_index)
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets, default_index, Reduction::SUM) {}
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets, default_index) {}

op::v3::EmbeddingBagOffsetsSum::EmbeddingBagOffsetsSum(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets)
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets, Reduction::SUM) {}
: util::EmbeddingBagOffsetsBase(emb_table, indices, offsets) {}

std::shared_ptr<Node> op::v3::EmbeddingBagOffsetsSum::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v3_EmbeddingBagOffsetsSum_clone_with_new_inputs);
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/op/embeddingbag_packedsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace ov {
op::v3::EmbeddingBagPackedSum::EmbeddingBagPackedSum(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& per_sample_weights)
: util::EmbeddingBagPackedBase(emb_table, indices, per_sample_weights, Reduction::SUM) {}
: util::EmbeddingBagPackedBase(emb_table, indices, per_sample_weights) {}

op::v3::EmbeddingBagPackedSum::EmbeddingBagPackedSum(const Output<Node>& emb_table, const Output<Node>& indices)
: util::EmbeddingBagPackedBase(emb_table, indices, Reduction::SUM) {}
: util::EmbeddingBagPackedBase(emb_table, indices) {}

std::shared_ptr<Node> op::v3::EmbeddingBagPackedSum::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v3_EmbeddingBagPackedSum_clone_with_new_inputs);
Expand Down
27 changes: 27 additions & 0 deletions src/core/src/op/util/embeddingbag_offsets_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@
#include "embeddingbag_offsets_shape_inference.hpp"
#include "itt.hpp"

ov::op::util::EmbeddingBagOffsetsBase::EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
const Output<Node>& default_index,
const Output<Node>& per_sample_weights)
: Op({emb_table, indices, offsets, default_index, per_sample_weights}),
m_reduction{Reduction::SUM} {
constructor_validate_and_infer_types();
}

ov::op::util::EmbeddingBagOffsetsBase::EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
const Output<Node>& default_index)
: Op({emb_table, indices, offsets, default_index}),
m_reduction{Reduction::SUM} {
constructor_validate_and_infer_types();
}

ov::op::util::EmbeddingBagOffsetsBase::EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets)
: Op({emb_table, indices, offsets}),
m_reduction{Reduction::SUM} {
constructor_validate_and_infer_types();
}

ov::op::util::EmbeddingBagOffsetsBase::EmbeddingBagOffsetsBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& offsets,
Expand Down
13 changes: 12 additions & 1 deletion src/core/src/op/util/embeddingbag_packed_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@
#include "embeddingbag_packed_shape_inference.hpp"
#include "itt.hpp"

using namespace std;
ov::op::util::EmbeddingBagPackedBase::EmbeddingBagPackedBase(const Output<Node>& emb_table,
const Output<Node>& indices,
const Output<Node>& per_sample_weights)
: Op({emb_table, indices, per_sample_weights}),
m_reduction{Reduction::SUM} {
constructor_validate_and_infer_types();
}

ov::op::util::EmbeddingBagPackedBase::EmbeddingBagPackedBase(const Output<Node>& emb_table, const Output<Node>& indices)
: Op({emb_table, indices}),
m_reduction{Reduction::SUM} {
constructor_validate_and_infer_types();
}
ov::op::util::EmbeddingBagPackedBase::EmbeddingBagPackedBase(
const Output<Node>& emb_table,
const Output<Node>& indices,
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/opset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ INSTANTIATE_TEST_SUITE_P(opset,
OpsetTestParams{ov::get_opset12, 178},
OpsetTestParams{ov::get_opset13, 186},
OpsetTestParams{ov::get_opset14, 189},
OpsetTestParams{ov::get_opset15, 6}),
OpsetTestParams{ov::get_opset15, 7}),
OpsetTestNameGenerator{});

class MyOpOld : public ov::op::Op {
Expand Down

0 comments on commit 9991ca3

Please sign in to comment.