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

Add scalar case if "then" and "else" subgraph output are scalar. #28444

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/core/src/op/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ static ov::PartialShape resolve_shape(const ov::PartialShape& then_pshape, const
return ov::PartialShape::dynamic();
}
if (then_rank.get_length() != else_rank.get_length()) {
auto isScalar = [](const ov::PartialShape& pshape) {
return ((pshape.rank() == 0) || (pshape.rank() == 1 && pshape.get_shape()[0] == 1));
};
praasz marked this conversation as resolved.
Show resolved Hide resolved
// Union of scalar and 1D case
if (then_rank.get_length() <= 1 && else_rank.get_length() <= 1) {
if (isScalar(then_pshape) && isScalar(else_pshape)) {
return ov::PartialShape{1};
}
return ov::PartialShape::dynamic(1);
praasz marked this conversation as resolved.
Show resolved Hide resolved
} else {
return ov::PartialShape::dynamic();
}
}
ov::PartialShape new_dims;

ov::PartialShape new_dims;
// If ranges are equal each dimension of then_body output is union with each dimension of
// else_body
for (auto then_it = then_pshape.cbegin(), else_it = else_pshape.cbegin(); then_it != then_pshape.cend();
Expand Down
Loading