-
Notifications
You must be signed in to change notification settings - Fork 6
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 unsqueeze and transpose patterns #178
Conversation
SmallVector<ReassociationIndices> expand_groups; | ||
ReassociationIndices group = ReassociationIndices(); | ||
SmallVector<int64_t> shape(coords.size() + ov_input_shape.rank().get_length()); | ||
for (size_t input_idx = 0, coord_idx = 0, i = 0; i < shape.size(); ++i) { | ||
group.push_back(i); | ||
if (coord_idx < coords.size() && i == coords[coord_idx]) { | ||
shape[i] = 1; | ||
coord_idx++; | ||
} else { | ||
const auto& dim = ov_input_shape[input_idx]; | ||
shape[i] = dim.is_dynamic() ? ShapedType::kDynamic : dim.get_length(); | ||
input_idx++; | ||
expand_groups.push_back(group); | ||
group = ReassociationIndices(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cannot we just take it as node->get_output_partial_shape(0)
? I believe the shape in MLIR should match the shape from OV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be always available? (dynamic shapes?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still need to generate the reassociation groups anyway though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still need to generate the reassociation groups anyway though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_output_partial_shape
always returns shape, including dynamic shapes, which means a part of the dimensions can be dynamic and you already know how to detect them -- dim.is_dynamic()
. But I agree that you still need to build reassociation groups.
Both rely on the second input to be a constant.
Depends on #177