Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/core/include/openvino/op/scatter_nd_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class OPENVINO_API ScatterNDUpdate : public util::ScatterNDBase {
bool has_evaluate() const override;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitruska, do we still need opset headers etc.? May it is enough to introduce just new version of operation without opset?

} // namespace v3
namespace v14 {
namespace v15 {
/// \brief Add updates to slices from inputs addressed by indices
/// \ingroup ov_ops_cpp_api
class OPENVINO_API ScatterNDUpdate : public util::ScatterNDBase {
public:
OPENVINO_OP("ScatterNDUpdate", "opset14", util::ScatterNDBase);
OPENVINO_OP("ScatterNDUpdate", "opset15", util::ScatterNDBase);

/// \brief Lists the supported reduction types for this version of the operator.
/// See the specification for the description of how reduction works with ScatterNDUpdate.
Expand Down Expand Up @@ -65,19 +65,19 @@ class OPENVINO_API ScatterNDUpdate : public util::ScatterNDBase {
private:
Reduction m_reduction = Reduction::NONE;
};
} // namespace v14
} // namespace v15
} // namespace op

OPENVINO_API
std::ostream& operator<<(std::ostream& s, const op::v14::ScatterNDUpdate::Reduction& reduction);
std::ostream& operator<<(std::ostream& s, const op::v15::ScatterNDUpdate::Reduction& reduction);

template <>
class OPENVINO_API AttributeAdapter<op::v14::ScatterNDUpdate::Reduction>
: public EnumAttributeAdapterBase<op::v14::ScatterNDUpdate::Reduction> {
class OPENVINO_API AttributeAdapter<op::v15::ScatterNDUpdate::Reduction>
: public EnumAttributeAdapterBase<op::v15::ScatterNDUpdate::Reduction> {
public:
AttributeAdapter(op::v14::ScatterNDUpdate::Reduction& value)
: EnumAttributeAdapterBase<op::v14::ScatterNDUpdate::Reduction>(value) {}
AttributeAdapter(op::v15::ScatterNDUpdate::Reduction& value)
: EnumAttributeAdapterBase<op::v15::ScatterNDUpdate::Reduction>(value) {}

OPENVINO_RTTI("AttributeAdapter<v14::ScatterNDUpdate::Reduction>");
OPENVINO_RTTI("AttributeAdapter<v15::ScatterNDUpdate::Reduction>");
};
} // namespace ov
2 changes: 1 addition & 1 deletion src/core/include/openvino/opsets/opset14_tbl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ _OPENVINO_OP_REG(Reshape, ov::op::v1)
_OPENVINO_OP_REG(Result, ov::op::v0)
_OPENVINO_OP_REG(ReverseSequence, ov::op::v0)
_OPENVINO_OP_REG(ROIPooling, ov::op::v0)
_OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v3)
_OPENVINO_OP_REG(Select, ov::op::v1)
_OPENVINO_OP_REG(Selu, ov::op::v0)
_OPENVINO_OP_REG(Sign, ov::op::v0)
Expand Down Expand Up @@ -220,4 +221,3 @@ _OPENVINO_OP_REG(FakeConvert, ov::op::v13)
// New operations added in opset14
_OPENVINO_OP_REG(ConvertPromoteTypes, ov::op::v14)
_OPENVINO_OP_REG(Inverse, ov::op::v14)
_OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v14)
1 change: 1 addition & 0 deletions src/core/include/openvino/opsets/opset15_tbl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ _OPENVINO_OP_REG(Convert, ov::op::v0)
_OPENVINO_OP_REG(ShapeOf, ov::op::v3)

// New operations added in opset15
_OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v15)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace ov {
namespace reference {
using Reduction = ov::op::v14::ScatterNDUpdate::Reduction;
using Reduction = ov::op::v15::ScatterNDUpdate::Reduction;
template <typename T>
using reduction_function = T (*)(const T, const T);

Expand Down
44 changes: 22 additions & 22 deletions src/core/src/op/scatter_nd_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Evaluate : public element::NoAction<bool> {
const Shape& data_shape,
const Shape& indices_shape,
const Shape& updates_shape,
const v14::ScatterNDUpdate::Reduction reduction) {
const v15::ScatterNDUpdate::Reduction reduction) {
using namespace ov::element;
return IF_TYPE_OF(sctter_nd_eval_idx_type,
OV_PP_ET_LIST(i32, i64),
Expand Down Expand Up @@ -51,7 +51,7 @@ struct Evaluate : public element::NoAction<bool> {
const Shape& data_shape,
const Shape& indices_shape,
const Shape& updates_shape,
const v14::ScatterNDUpdate::Reduction reduction) {
const v15::ScatterNDUpdate::Reduction reduction) {
reference::scatterNdUpdate(data,
indices.data<IT>(),
updates,
Expand All @@ -68,7 +68,7 @@ namespace {
bool evaluate(const op::util::ScatterNDBase* node,
TensorVector& outputs,
const TensorVector& inputs,
const op::v14::ScatterNDUpdate::Reduction reduction) {
const op::v15::ScatterNDUpdate::Reduction reduction) {
OPENVINO_ASSERT(inputs.size() == 3);
OPENVINO_ASSERT(outputs.size() == 1);

Expand Down Expand Up @@ -131,7 +131,7 @@ std::shared_ptr<Node> ScatterNDUpdate::clone_with_new_inputs(const OutputVector&

bool ScatterNDUpdate::evaluate(TensorVector& outputs, const TensorVector& inputs) const {
OV_OP_SCOPE(v3_ScatterNDUpdate_evaluate);
constexpr auto reduction = op::v14::ScatterNDUpdate::Reduction::NONE;
constexpr auto reduction = op::v15::ScatterNDUpdate::Reduction::NONE;
return scatter_nd_update::evaluate(this, outputs, inputs, reduction);
}

Expand All @@ -156,7 +156,7 @@ bool ScatterNDUpdate::evaluate_symbol(TensorSymbolVector& output_symbols) const
}
} // namespace v3

namespace v14 {
namespace v15 {
ScatterNDUpdate::ScatterNDUpdate(const Output<Node>& inputs,
const Output<Node>& indices,
const Output<Node>& updates,
Expand All @@ -166,24 +166,24 @@ ScatterNDUpdate::ScatterNDUpdate(const Output<Node>& inputs,
constructor_validate_and_infer_types();
}
std::shared_ptr<Node> ScatterNDUpdate::clone_with_new_inputs(const OutputVector& new_args) const {
OV_OP_SCOPE(v14_ScatterNDUpdate_clone_with_new_inputs);
OV_OP_SCOPE(v15_ScatterNDUpdate_clone_with_new_inputs);
check_new_args_count(this, new_args);
return std::make_shared<ScatterNDUpdate>(new_args.at(0), new_args.at(1), new_args.at(2), m_reduction);
}

bool ScatterNDUpdate::visit_attributes(AttributeVisitor& visitor) {
OV_OP_SCOPE(v14_ScatterNDUpdate_visit_attributes);
OV_OP_SCOPE(v15_ScatterNDUpdate_visit_attributes);
visitor.on_attribute("reduction", m_reduction);
return true;
}

bool ScatterNDUpdate::evaluate(TensorVector& outputs, const TensorVector& inputs) const {
OV_OP_SCOPE(v14_ScatterNDUpdate_evaluate);
OV_OP_SCOPE(v15_ScatterNDUpdate_evaluate);
return scatter_nd_update::evaluate(this, outputs, inputs, m_reduction);
}

bool ScatterNDUpdate::has_evaluate() const {
OV_OP_SCOPE(v14_ScatterNDUpdate_has_evaluate);
OV_OP_SCOPE(v15_ScatterNDUpdate_has_evaluate);
return scatter_nd_update::has_evaluate(this);
}

Expand All @@ -195,35 +195,35 @@ void ScatterNDUpdate::set_reduction(const ScatterNDUpdate::Reduction reduction)
m_reduction = reduction;
}
bool ScatterNDUpdate::evaluate_lower(TensorVector& output_values) const {
OV_OP_SCOPE(v14_ScatterNDUpdate_evaluate_lower);
OV_OP_SCOPE(v15_ScatterNDUpdate_evaluate_lower);
return get_input_tensor(1).has_and_set_bound() && default_lower_bound_evaluator(this, output_values);
}

bool ScatterNDUpdate::evaluate_upper(TensorVector& output_values) const {
OV_OP_SCOPE(v14_ScatterNDUpdate_evaluate_upper);
OV_OP_SCOPE(v15_ScatterNDUpdate_evaluate_upper);
return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values);
}

bool ScatterNDUpdate::evaluate_symbol(TensorSymbolVector& output_symbols) const {
OV_OP_SCOPE(v14_ScatterNDUpdate_evaluate_symbol);
OV_OP_SCOPE(v15_ScatterNDUpdate_evaluate_symbol);
return default_symbol_evaluator(this, {0, 2}, output_symbols);
}

} // namespace v14
} // namespace v15
} // namespace op
std::ostream& operator<<(std::ostream& s, const op::v14::ScatterNDUpdate::Reduction& reduction) {
std::ostream& operator<<(std::ostream& s, const op::v15::ScatterNDUpdate::Reduction& reduction) {
return s << as_string(reduction);
}
template <>
OPENVINO_API EnumNames<op::v14::ScatterNDUpdate::Reduction>& EnumNames<op::v14::ScatterNDUpdate::Reduction>::get() {
OPENVINO_API EnumNames<op::v15::ScatterNDUpdate::Reduction>& EnumNames<op::v15::ScatterNDUpdate::Reduction>::get() {
static auto enum_names =
EnumNames<op::v14::ScatterNDUpdate::Reduction>("op::v14::ScatterNDUpdate::Reduction",
{{"none", op::v14::ScatterNDUpdate::Reduction::NONE},
{"sum", op::v14::ScatterNDUpdate::Reduction::SUM},
{"sub", op::v14::ScatterNDUpdate::Reduction::SUB},
{"prod", op::v14::ScatterNDUpdate::Reduction::PROD},
{"min", op::v14::ScatterNDUpdate::Reduction::MIN},
{"max", op::v14::ScatterNDUpdate::Reduction::MAX}});
EnumNames<op::v15::ScatterNDUpdate::Reduction>("op::v15::ScatterNDUpdate::Reduction",
{{"none", op::v15::ScatterNDUpdate::Reduction::NONE},
{"sum", op::v15::ScatterNDUpdate::Reduction::SUM},
{"sub", op::v15::ScatterNDUpdate::Reduction::SUB},
{"prod", op::v15::ScatterNDUpdate::Reduction::PROD},
{"min", op::v15::ScatterNDUpdate::Reduction::MIN},
{"max", op::v15::ScatterNDUpdate::Reduction::MAX}});
return enum_names;
}
} // namespace ov
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, 188},
OpsetTestParams{ov::get_opset15, 3}),
OpsetTestParams{ov::get_opset15, 4}),
OpsetTestNameGenerator{});

class MyOpOld : public ov::op::Op {
Expand Down
22 changes: 11 additions & 11 deletions src/core/tests/type_prop/scatter_nd_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,46 +247,46 @@ TYPED_TEST_P(TypePropScatterNDUpdateTest, all_dynamic_type) {
EXPECT_EQ(op->get_output_partial_shape(0), this->data_3d_dynamic);
}

TEST(type_prop, scatter_nd_update_v14_default_attribute) {
TEST(type_prop, scatter_nd_update_v15_default_attribute) {
const auto d = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{2, 3, 5, 1});
const auto i = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{1, 3});
const auto u = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{1, 1});

const auto op = std::make_shared<op::v14::ScatterNDUpdate>();
const auto op = std::make_shared<op::v15::ScatterNDUpdate>();
op->set_arguments(OutputVector{d, i, u});
op->validate_and_infer_types();

EXPECT_EQ(op->get_output_element_type(0), element::i64);
EXPECT_EQ(op->get_reduction(), op::v14::ScatterNDUpdate::Reduction::NONE);
EXPECT_EQ(op->get_reduction(), op::v15::ScatterNDUpdate::Reduction::NONE);
EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 3, 5, 1}));
EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr));
}

TEST(type_prop, scatter_nd_update_v14_attribute_setter_enum) {
TEST(type_prop, scatter_nd_update_v15_attribute_setter_enum) {
const auto d = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{2, 3, 5, 1});
const auto i = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{1, 3});
const auto u = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{1, 1});

const auto op = std::make_shared<op::v14::ScatterNDUpdate>();
const auto op = std::make_shared<op::v15::ScatterNDUpdate>();
op->set_arguments(OutputVector{d, i, u});
op->set_reduction(op::v14::ScatterNDUpdate::Reduction::PROD);
op->set_reduction(op::v15::ScatterNDUpdate::Reduction::PROD);
op->validate_and_infer_types();

EXPECT_EQ(op->get_output_element_type(0), element::i64);
EXPECT_EQ(op->get_reduction(), op::v14::ScatterNDUpdate::Reduction::PROD);
EXPECT_EQ(op->get_reduction(), op::v15::ScatterNDUpdate::Reduction::PROD);
EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 3, 5, 1}));
EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr));
}

TEST(type_prop, scatter_nd_update_v14_attribute_constructor) {
TEST(type_prop, scatter_nd_update_v15_attribute_constructor) {
const auto d = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{2, 3, 5, 1});
const auto i = std::make_shared<op::v0::Parameter>(element::i32, PartialShape{1, 3});
const auto u = std::make_shared<op::v0::Parameter>(element::i64, PartialShape{1, 1});

const auto op = std::make_shared<op::v14::ScatterNDUpdate>(d, i, u, op::v14::ScatterNDUpdate::Reduction::MAX);
const auto op = std::make_shared<op::v15::ScatterNDUpdate>(d, i, u, op::v15::ScatterNDUpdate::Reduction::MAX);

EXPECT_EQ(op->get_output_element_type(0), element::i64);
EXPECT_EQ(op->get_reduction(), op::v14::ScatterNDUpdate::Reduction::MAX);
EXPECT_EQ(op->get_reduction(), op::v15::ScatterNDUpdate::Reduction::MAX);
EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 3, 5, 1}));
EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr));
}
Expand All @@ -307,5 +307,5 @@ REGISTER_TYPED_TEST_SUITE_P(TypePropScatterNDUpdateTest,
updates_input_is_dynamic,
updates_input_is_scalar,
all_dynamic_type);
using OpVersions = ::testing::Types<op::v3::ScatterNDUpdate, op::v14::ScatterNDUpdate>;
using OpVersions = ::testing::Types<op::v3::ScatterNDUpdate, op::v15::ScatterNDUpdate>;
INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, TypePropScatterNDUpdateTest, OpVersions);
10 changes: 5 additions & 5 deletions src/core/tests/visitors/op/scatter_nd_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ TEST(attributes, scatter_nd_update) {
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
}

TEST(attributes, scatter_nd_update_v14) {
NodeBuilder::opset().insert<ov::op::v14::ScatterNDUpdate>();
TEST(attributes, scatter_nd_update_v15) {
NodeBuilder::opset().insert<ov::op::v15::ScatterNDUpdate>();

auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{1000, 256, 10, 15});
auto indices = std::make_shared<ov::op::v0::Parameter>(element::i32, Shape{25, 125, 3});
auto updates = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{25, 125, 15});

auto scatter = std::make_shared<ov::op::v14::ScatterNDUpdate>(data,
auto scatter = std::make_shared<ov::op::v15::ScatterNDUpdate>(data,
indices,
updates,
op::v14::ScatterNDUpdate::Reduction::PROD);
op::v15::ScatterNDUpdate::Reduction::PROD);
NodeBuilder builder(scatter, {data, indices, updates});
const auto g_scatter = ov::as_type_ptr<ov::op::v14::ScatterNDUpdate>(builder.create());
const auto g_scatter = ov::as_type_ptr<ov::op::v15::ScatterNDUpdate>(builder.create());

const auto expected_attr_count = 1;
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
Expand Down
Loading