Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate nop Convert at the beginning of the MOC pipeline #26872

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ bool ov::pass::MOCTransformations::run_on_model(const std::shared_ptr<ov::Model>
// In particular, if zero dim tensor is consumed in body of MultiSubGraphOp
// RemoveConcatZeroDimInput and RemoveMultiSubGraphOpDanglingParamsResults should be called together.
using namespace ov::pass;
REGISTER_PASS(manager, EliminateConvert)
REGISTER_PASS(manager, EliminateScatterUpdate)
REGISTER_PASS(manager, RemoveConcatZeroDimInput)
REGISTER_PASS(manager, EliminateLoopInputsOutputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ TEST(TransformationTests, TestModelTensorsConsistencyUseShapesTrue) {
EXPECT_TRUE(model->outputs()[0].get_names() == new_tensors);
}

TEST(TransformationTests, MOCConvertElimination) {
auto input = std::make_shared<opset12::Parameter>(element::f32, Shape{1});
auto const_val = opset12::Constant::create(element::f32, Shape{1}, {2});

auto add1 = std::make_shared<opset12::Add>(input, const_val);
auto convert_fp32 = std::make_shared<opset12::Convert>(const_val, element::f32);
auto mul = std::make_shared<opset12::MatMul>(add1, convert_fp32);

auto model = std::make_shared<Model>(NodeVector{mul}, ParameterVector{input});
ov::pass::Manager m;
m.register_pass<ov::pass::MOCTransformations>(false);
m.run_passes(model);

EXPECT_EQ(count_ops_of_type<opset12::Constant>(model), 1);
}

TEST(TransformationTests, TestModelTensorsConsistencyUseShapesFalse) {
auto input = std::make_shared<opset12::Parameter>(element::f32, Shape{1});
auto const1 = opset12::Constant::create(element::f32, Shape{1}, {1});
Expand Down
Loading