forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tj/core/serialize-validation
- Loading branch information
Showing
19 changed files
with
403 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...rmations/include/transformations/op_conversions/convert_scatter_nd_update15_downgrade.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "openvino/pass/graph_rewrite.hpp" | ||
#include "transformations_visibility.hpp" | ||
|
||
namespace ov { | ||
namespace pass { | ||
/** | ||
* @ingroup ov_transformation_common_api | ||
* @brief Converts ScatterNDUpdate version 15 to ScatterNDUpdate version 3 if ScatterNDUpdate reduction attribute is set | ||
* to None. | ||
*/ | ||
class TRANSFORMATIONS_API ConvertScatterNDUpdate15ToScatterNDUpdate3 : public MatcherPass { | ||
public: | ||
OPENVINO_RTTI("ConvertScatterNDUpdate15ToScatterNDUpdate3", "0"); | ||
ConvertScatterNDUpdate15ToScatterNDUpdate3(); | ||
}; | ||
|
||
} // namespace pass | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...nsformations/src/transformations/op_conversions/convert_scatter_nd_update15_downgrade.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "transformations/op_conversions/convert_scatter_nd_update15_downgrade.hpp" | ||
|
||
#include "itt.hpp" | ||
#include "openvino/core/rt_info.hpp" | ||
#include "openvino/op/scatter_nd_update.hpp" | ||
#include "openvino/pass/pattern/op/wrap_type.hpp" | ||
#include "transformations/utils/utils.hpp" | ||
|
||
ov::pass::ConvertScatterNDUpdate15ToScatterNDUpdate3::ConvertScatterNDUpdate15ToScatterNDUpdate3() { | ||
MATCHER_SCOPE(ConvertScatterNDUpdate15ToScatterNDUpdate3); | ||
|
||
const auto scatter_v15_pattern = pattern::wrap_type<ov::op::v15::ScatterNDUpdate>(); | ||
|
||
const matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) { | ||
const auto scatter_v15 = std::dynamic_pointer_cast<ov::op::v15::ScatterNDUpdate>(m.get_match_root()); | ||
if (!scatter_v15 || transformation_callback(scatter_v15)) { | ||
return false; | ||
} | ||
if (scatter_v15->get_reduction() != ov::op::v15::ScatterNDUpdate::Reduction::NONE) { | ||
return false; | ||
} | ||
const auto scatter_v3 = std::make_shared<ov::op::v3::ScatterNDUpdate>(scatter_v15->input_value(0), | ||
scatter_v15->input_value(1), | ||
scatter_v15->input_value(2)); | ||
|
||
scatter_v3->set_friendly_name(scatter_v15->get_friendly_name()); | ||
copy_runtime_info(scatter_v15, scatter_v3); | ||
replace_node(scatter_v15, scatter_v3); | ||
|
||
return true; | ||
}; | ||
|
||
auto m = std::make_shared<pattern::Matcher>(scatter_v15_pattern, matcher_name); | ||
register_matcher(m, callback); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ommon/transformations/tests/op_conversions/convert_scatter_nd_update15_downgrade_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "transformations/op_conversions/convert_scatter_nd_update15_downgrade.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
|
||
#include "common_test_utils/ov_test_utils.hpp" | ||
#include "openvino/opsets/opset15.hpp" | ||
#include "openvino/opsets/opset4.hpp" | ||
#include "openvino/pass/manager.hpp" | ||
#include "transformations/utils/utils.hpp" | ||
using namespace ov; | ||
using namespace testing; | ||
|
||
namespace { | ||
using Reduction = ov::opset15::ScatterNDUpdate::Reduction; | ||
|
||
std::shared_ptr<ov::Model> create_v15_model(const Reduction reduction_type) { | ||
const auto data = std::make_shared<ov::opset15::Parameter>(ov::element::f32, ov::Shape{1000, 256, 10, 15}); | ||
const auto indices = std::make_shared<ov::opset15::Parameter>(ov::element::i32, ov::Shape{25, 125, 3}); | ||
const auto updates = std::make_shared<ov::opset15::Parameter>(ov::element::f32, ov::Shape{25, 125, 15}); | ||
const auto scatter_nd = std::make_shared<ov::opset15::ScatterNDUpdate>(data, indices, updates, reduction_type); | ||
scatter_nd->set_friendly_name("scatter_nd15"); | ||
return std::make_shared<ov::Model>(scatter_nd->outputs(), ov::ParameterVector{data, indices, updates}); | ||
} | ||
|
||
std::shared_ptr<ov::Model> create_v3_model() { | ||
const auto data = std::make_shared<ov::opset15::Parameter>(ov::element::f32, ov::Shape{1000, 256, 10, 15}); | ||
const auto indices = std::make_shared<ov::opset15::Parameter>(ov::element::i32, ov::Shape{25, 125, 3}); | ||
const auto updates = std::make_shared<ov::opset15::Parameter>(ov::element::f32, ov::Shape{25, 125, 15}); | ||
const auto scatter_nd = std::make_shared<ov::opset4::ScatterNDUpdate>(data, indices, updates); | ||
scatter_nd->set_friendly_name("scatter_nd15"); | ||
|
||
return std::make_shared<ov::Model>(scatter_nd->outputs(), ov::ParameterVector{data, indices, updates}); | ||
} | ||
|
||
} // namespace | ||
|
||
TEST_F(TransformationTestsF, ConvertScatterNDUpdate15ToScatterNDUpdate3_no_reduction) { | ||
manager.register_pass<ov::pass::ConvertScatterNDUpdate15ToScatterNDUpdate3>(); | ||
model = create_v15_model(Reduction::NONE); | ||
model_ref = create_v3_model(); | ||
comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); | ||
comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); | ||
} | ||
|
||
TEST_F(TransformationTestsF, ConvertScatterNDUpdate15ToScatterNDUpdate3_reduction) { | ||
manager.register_pass<ov::pass::ConvertScatterNDUpdate15ToScatterNDUpdate3>(); | ||
model = create_v15_model(Reduction::PROD); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.