Repository navigation
[Dispatch Creation] Drop unit dims from tensor.extract ops - #22503
Conversation
Signed-off-by: Ian Wood <[email protected]>
Signed-off-by: Ian Wood <[email protected]>
There was a problem hiding this comment.
No opinion on this, but I wonder if a better way to handle this is actually to have a collapse/expand -> extract folding pattern just like we do for FoldMemrefAliasOps. It's effectively the same thing. It would handle things more generally and would ensure we always remove reshapes for tensor.extract.
I don't have a strong opinion here either but here are some thoughts: First, this pattern is more "active". It doesn't require an directly adjacent reshape to remove the unit dims from the op. If every op only folded with collapse/expand ops, we wouldn’t be able to eliminate unit dims in cases where the reshape isn’t the immediate producer. That’s partly why the existing patterns in this pass are structured as they are. Second, having a |
When I say folding pattern I didn't mean a "canonicalization folder", sorry for mis communicating that. I just meant a pattern that you can run. Either is okay with me, I'm mainly offering another solution. Feel free to land what you think is better. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Does this work for rank-reducing extract slices? The base logic should cause you are using just the source type and offsets/sizes. Just need to check the new operation created is valid.
Are you referring to adding a different pattern with similar logic as this one but for extract_slices? I think that would work with some small changes. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
I didnt realize this is tensor.extract. That is strange that we have a tensor.extract outside of a linalg op. Whats the source of this error.
|
I didn't put the I can add a test with the |
I was just curious. I already approved the PR. |
…22503) Adds pattern for `tensor.extract` to fold unit dimensions. Without this pattern there will be reshapes left in the program which may re-introduce the unit dims when propagated. The added xfail already has an issue iree-org#20011. --------- Signed-off-by: Ian Wood <[email protected]>
…22503) Adds pattern for `tensor.extract` to fold unit dimensions. Without this pattern there will be reshapes left in the program which may re-introduce the unit dims when propagated. The added xfail already has an issue iree-org#20011. --------- Signed-off-by: Ian Wood <[email protected]>
Adds pattern for
tensor.extractto fold unit dimensions. Without this pattern there will be reshapes left in the program which may re-introduce the unit dims when propagated.The added xfail already has an issue #20011.