This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Canonicalize duplicate args.
ClosedPublic

Authored by silvas on Nov 4 2020, 6:56 PM.

Details

Summary

I ran into this pattern when converting elementwise ops like
addf %arg0, %arg : tensor<?xf32> to linalg. Redundant arguments can
also easily arise from linalg-fusion-for-tensor-ops.

Also, fix some small bugs in the logic in
LinalgStructuredOpsInterface.td.

Diff Detail

Event Timeline

silvas created this revision.Nov 4 2020, 6:56 PM
silvas requested review of this revision.Nov 4 2020, 6:56 PM
silvas updated this revision to Diff 303010.Nov 4 2020, 6:57 PM

remove some stray WIP comments

Looks good, thanks @silvas!
Approving conditioned on the {base, base + getNumInitTensors()} change.
If that happens to not work we should dig deeper, some of the helper functions need to be extended for more init_args use cases.

mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
416

I would avoid spreading the implicit logic.
As we discussed offline, tile on tensors will require putting even pointwise ops in "init_tensor form".
Would {base, base + getNumInitTensors()} work?

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
1712

getOutputIndexingMap to avoid leaking internal assumptions?

nicolasvasilache accepted this revision.Nov 6 2020, 9:18 AM
This revision is now accepted and ready to land.Nov 6 2020, 9:18 AM
silvas updated this revision to Diff 303555.Nov 6 2020, 2:39 PM
silvas marked an inline comment as done.

address comments

silvas added inline comments.Nov 6 2020, 2:41 PM
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
416

Done! So obvious in hindsight :)

This revision was landed with ongoing or failed builds.Nov 6 2020, 2:44 PM
This revision was automatically updated to reflect the committed changes.