This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Handle fusion on tensors for projected permutation.
ClosedPublic

Authored by hanchung on Dec 2 2020, 12:46 AM.

Details

Summary

In the past, the reshape op can be folded only if the indexing map is
permutation in consumer's usage. We can relax to condition to be projected
permutation.

This patch still limits the fusion for scalar cases. Scalar case is a corner
case, because we need to decide where to put extra dims.

Diff Detail

Event Timeline

hanchung created this revision.Dec 2 2020, 12:46 AM
hanchung requested review of this revision.Dec 2 2020, 12:46 AM
mravishankar requested changes to this revision.Dec 2 2020, 5:56 AM

THanks Hanhan! Just one minor suggestion.

mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
426

I think this can be folded into the condition above by checking all indexing maps are projected permutations?

This revision now requires changes to proceed.Dec 2 2020, 5:56 AM
hanchung updated this revision to Diff 308970.Dec 2 2020, 7:54 AM

Remove dup check

hanchung marked an inline comment as done.Dec 2 2020, 7:54 AM
hanchung added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
426

Ah, I didn't notice that, good catch!

mravishankar requested changes to this revision.Dec 2 2020, 10:14 AM
mravishankar added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
426

The condition above is checking only the inputs. Thats not enough. You need to check all the indexing_maps, i.e. remove the take_front at line 421

This revision now requires changes to proceed.Dec 2 2020, 10:14 AM
hanchung updated this revision to Diff 309008.Dec 2 2020, 10:43 AM
hanchung marked an inline comment as done.

Check all the indexing maps.

hanchung marked an inline comment as done.Dec 2 2020, 10:44 AM
hanchung added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
426

okay, I think I need to add another test for {generic, reshape} case.

hanchung updated this revision to Diff 309011.Dec 2 2020, 10:57 AM

Add a test

mravishankar accepted this revision.Dec 3 2020, 1:53 PM

(Sorry for delay. Forgot to hit submit)

This revision is now accepted and ready to land.Dec 3 2020, 1:53 PM
This revision was landed with ongoing or failed builds.Dec 3 2020, 11:11 PM
This revision was automatically updated to reflect the committed changes.