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

[Torch Dialect] Allow simplification of shape calculations of aten.tile, col2im, aten.stft #3785

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

giacs-epic
Copy link
Contributor

  • Add aten.mul.left_t (+ canonicalizer) to allow simplification of aten.tile.
  • Change syntax of the computation of col2im shape to allow the use of an already existing canonicalization pattern (for aten.add.t) for its simplification.
  • Add aten.eq.bool ( + folder) to allow simplification of aten.stft.

Copy link
Collaborator

@zjgarvey zjgarvey left a 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.

lib/Dialect/Torch/IR/TorchOps.cpp Outdated Show resolved Hide resolved
lib/Dialect/Torch/IR/TorchOps.cpp Outdated Show resolved Hide resolved
@zjgarvey zjgarvey self-requested a review November 12, 2024 19:09
Copy link
Collaborator

@zjgarvey zjgarvey left a 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.

Comment on lines +762 to +767
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);
Copy link
Collaborator

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());

@zjgarvey
Copy link
Collaborator

Might also need to re-run the build_tools/update_abstract_interp_lib.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants