iree icon indicating copy to clipboard operation
iree copied to clipboard

[WIP] Remove `tensor.empty` for fusion cases.

Open MaheshRavishankar opened this issue 2 years ago • 4 comments

For a dispatch of the form

tensor.empty -> linalg.fill -> linalg.matmul -> linalg.generic

in some cases, the tensor.empty can be replaced with using the output of the linalg.generic directly if the result of the linalg.matmul has the same type as the result of linalg.generic. This transformation already existed in the ConvertToDestinationPassingStyle pass but was removed since the assumption was that after vectorization the tensor.empty would be dead. Adding this back since for non-vectorization cases this will result in an unnecessary stack allocation.

Fixes #14316, #14305

MaheshRavishankar avatar Jul 12 '23 02:07 MaheshRavishankar

FYI, @hanhanW and @dcaballe . I think this enables the removal of tensor.empty with ConvertToDestinationPassingStyle pass. I am just leaving this as a draft for now. If you want you can cherry-pick this on your PRs and try.

MaheshRavishankar avatar Jul 12 '23 02:07 MaheshRavishankar

I haven't had time to look into this but, before it gets stale, would it make sense to merge it?

dcaballe avatar Aug 08 '23 22:08 dcaballe

I haven't had time to look into this but, before it gets stale, would it make sense to merge it?

I think I can merge it.... let me rebase.

MaheshRavishankar avatar Aug 08 '23 23:08 MaheshRavishankar

@MaheshRavishankar this has two issues attached to it - is this something you want to rebase/land or should we close them all?

benvanik avatar May 14 '24 16:05 benvanik

(closing as stale)

benvanik avatar Apr 29 '25 22:04 benvanik