This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Make Elementwise op fusion return a map from existing values to values in the fused op.
ClosedPublic

Authored by mravishankar on Jan 29 2023, 1:59 PM.

Details

Summary

This replacement can be used to eliminate all uses of the
producer/consumer for case where producer/consumer has other uses
outside of the producer/consumer pair. This makes the
producer/consumer dead.

Add test and minor fixup to the test harness.

Diff Detail

Event Timeline

mravishankar created this revision.Jan 29 2023, 1:59 PM
mravishankar requested review of this revision.Jan 29 2023, 1:59 PM
hanchung added inline comments.Jan 29 2023, 6:32 PM
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
165–171

The comment above is for the fuseElementwiseOps method, maybe we can move the struct above the comment?

mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
427–428

It is assuming that all replacements are appending to the result of fused op, which is fragile. Should we take replacements from fusionResult?

mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
69–76

style nit: we dont need braces for single if statements.

mravishankar marked 2 inline comments as done.

Address comments.

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
165–171

I think its just easier to keep it here. Really its part of the function ABI.

hanchung accepted this revision.Jan 30 2023, 4:22 PM
This revision is now accepted and ready to land.Jan 30 2023, 4:22 PM