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] Add patterns to convert complex conversions to bitcasts #19396

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qedawkins
Copy link
Contributor

The torch.view_as_complex and torch.view_as_real ops are better suited to be represented as bitcasts, however there isn't a suitable bitcast op upstream. Currently torch-mlir lowers to a difficult to analyze linalg.generic, but in IREE we can instead lower to flow.tensor.bitcast.

The `torch.view_as_complex` and `torch.view_as_real` ops are better
suited to be represented as bitcasts, however there isn't a suitable
bitcast op upstream. Currently torch-mlir lowers to a difficult to
analyze linalg.generic, but in IREE we can instead lower to
`flow.tensor.bitcast`.
Copy link
Contributor

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

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

Do we want to convert it to bitcasts? I am asking cause I am guessing you are planning to fuse across these bitcasts into a dispatch. Cant do that with flow.tensor.bitcast. From previous conversation tensor.bitcast wont cut it/needs to be adapted. To avoid protracted discussion upstream on bitcast semantics maybe we add a util.tensor.bitcast which we can chose to fuse into dispatches if needed.

Copy link
Contributor

@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.

I don't see anything wrong about the code or tests here, but I don't have enough context to know if this is the right approach overall. In my opinion, anything is better than linalg.generic ops that use tensor.extract instead of iterating over the input tensor (which is the case for Aten::ViewAsComplexOp).

Regarding the comment by Mahesh, why can't the flow tensor bitcast ops be fused into a dispatch?

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.

3 participants