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 canonicalize pattern for aten.mul.int and aten.floordiv.int #3680

Merged
merged 11 commits into from
Sep 3, 2024

Conversation

zezhang
Copy link
Collaborator

@zezhang zezhang commented Aug 30, 2024

This PR add floordiv to the PY_BUILTIN_TO_TORCH_OP. For aten.mul.int and aten.floordiv.int ops, we add new Canonicalization Patterns as follow:

%1 = torch.aten.mul.int %input, %const-5
%2 = torch.aten.mul.int %1, %const-6

Will be replaced by

torch.aten.mul.int %input, %const-30

And

%1 = torch.aten.mul.int %input, %const-5
%2 = torch.aten.floordiv.int %1, %const-5

Will directly return %input

This PR also relaxes the float type constraint in TorchToTosa for the AtenRsubScalarOp conversion.

To test:

cmake --build build --target check-torch-mlir-all

Copy link
Member

@sjain-stanford sjain-stanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zezhang zezhang merged commit b3942ff into llvm:main Sep 3, 2024
3 checks passed
@zezhang zezhang deleted the zezhang/mul_floor_int_opt branch September 3, 2024 16:19
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