-
Notifications
You must be signed in to change notification settings - Fork 506
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
[Torch Dialect] Allow simplification of shape calculations of aten.tile, col2im, aten.stft #3785
base: main
Are you sure you want to change the base?
[Torch Dialect] Allow simplification of shape calculations of aten.tile, col2im, aten.stft #3785
Conversation
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.
Thanks! A small change and I think this is good to go.
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.
A small nitpick if you think it would look better. If you like the folder as-is, I don't have any complaints and we can merge as-is.
bool a, b; | ||
if (!matchPattern(getOperand(0), m_TorchConstantBool(&a))) | ||
return nullptr; | ||
if (!matchPattern(getOperand(1), m_TorchConstantBool(&b))) | ||
return nullptr; | ||
return IntegerAttr::get(IntegerType::get(getContext(), 1), a == b); |
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.
This might be a bit of a nitpick, but we should be able to use the adaptor
here instead of matching against constants.
E.g., something like:
auto aIntAttr = dyn_cast_or_null<IntegerAttr>(adaptor.getA());
auto bIntAttr = dyn_cast_or_null<IntegerAttr>(adaptor.getB());
if (!aIntAttr || !bIntAttr)
return nullptr;
return IntegerAttr::get(IntegerType::get(getContext(), 1), aIntAttr.getValue() == bIntAttr.getValue());
Might also need to re-run the |
aten.mul.left_t
(+ canonicalizer) to allow simplification of aten.tile.aten.add.t
) for its simplification.aten.eq.bool
( + folder) to allow simplification of aten.stft.