This is an archive of the discontinued LLVM Phabricator instance.

[mlir] [linalg] Only promote selected buffers.
ClosedPublic

Authored by poechsel on Apr 20 2020, 8:20 AM.

Details

Summary

The promotion transformation is promoting all input and output buffers of the transformed op. The user might want to only promote some of these buffers.

Diff Detail

Event Timeline

poechsel created this revision.Apr 20 2020, 8:20 AM
poechsel updated this revision to Diff 258755.Apr 20 2020, 8:22 AM

Clang formatting suggestions.

Harbormaster completed remote builds in B53970: Diff 258755.
ftynse added a subscriber: ftynse.Apr 20 2020, 8:50 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
124

Please document this function

mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
342

Please reserve the space before populating a vector in a loop

343

int64_t i = 0, e = linOp.getNumInputsAndOutputBuffers(); i < e; ++i) is a common LLVM pattern that avoids calling the function in a loop

376

Nit: !linalgMarker.empty() may be more efficient

mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td
153

I don't follow this. The test name suggests you promote the _first_ view, but the list contains operands with indices 0 and 1... The .mlir file also seems to check only for one copy. Consider using only [0] here and CHECK-NOT for extra copies before matmul.

poechsel updated this revision to Diff 258787.Apr 20 2020, 10:23 AM

Address comments

poechsel marked 5 inline comments as done.Apr 20 2020, 10:33 AM
poechsel added inline comments.
mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td
153

Nice catch!

I believe there is a problem with test/Dialect/Linalg/transform-patterns.mlir and that the test is passing even when it should fail:

  • in my case I should have had a fallback on line 439 where I'm checking the ssa address of arg1 with the one it should have if no promotion happens.
  • since D77676 promotion shouldn't generate linalg.slice operations but this test is still checking for their presence (ex: line 393).
ftynse accepted this revision.Apr 21 2020, 2:43 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
127

Nit: typo "successful". And grammo: put a comma after an if-clause.

mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td
153

Indeed, after further investigation, the test above uses wrong syntax for FileCheck. There must be no spaces between CHECK and : @nicolasvasilache.

This revision is now accepted and ready to land.Apr 21 2020, 2:43 AM
rriddle added inline comments.Apr 21 2020, 3:03 AM
mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td
119

Please wrap this at 80 characters, it seems to be edging over here.

mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
345

nit: You could use std::iota here.

This revision was automatically updated to reflect the committed changes.
thopre added a subscriber: thopre.Apr 6 2021, 6:56 AM
thopre added inline comments.
mlir/test/Dialect/Linalg/transform-patterns.mlir
439–446

These checks do not work because they refer to undefined variables because each CHECK-NOT is checked independently. Since these are patterns that should not occur the variables defined in them have nothing to be set to.

Currently these will always succeed because the use of an undefined variable is interpreted by FileCheck as being a failure to match, and thus those CHECK-NOT are satisfied. I'd suggest replacing them with CHECK-NEXT as generated by update_test_checks.py. Alternatively you could join all CHECK-NOT in a CHECK-NOT block with {{(.*[[:space:]])+}} but that would become quite unreadable.

Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 6:56 AM