This is an archive of the discontinued LLVM Phabricator instance.

Support tile-and-pad when padding doesn't span all dimension
AbandonedPublic

Authored by asaadaldien on Feb 17 2021, 12:28 PM.

Details

Summary
  • Note: This only works if untiled dims are static. Otherwise we need to change the semantics of PadOp to accept [%size...] attributes.

Diff Detail

Event Timeline

asaadaldien created this revision.Feb 17 2021, 12:28 PM
asaadaldien requested review of this revision.Feb 17 2021, 12:28 PM
asaadaldien retitled this revision from Support tile-and-pad when padding doesn't all dimension to Support tile-and-pad when padding doesn't span all dimension.Feb 17 2021, 12:34 PM
asaadaldien edited the summary of this revision. (Show Details)
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
276–277

This revision breaks this invariant, why ?

mlir/test/Dialect/Linalg/tile-and-pad-tensors.mlir
46

This does not check = instead of -.
Also, CHECK-NOT: scf.for ?

mlir/test/lib/Transforms/TestLinalgTransforms.cpp
87

tile-sizes is a bit too generic for this very specialized test.
Rename to tile-sizes-for-padding ?

asaadaldien added inline comments.Feb 22 2021, 5:54 PM
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
276–277

To alter the marker in any case otherwise this pattern will be stuck in in an infinite loop of tile -> pad -> fail -> tile -> pad -> fail -> ...
You can repro this by running only tile with 2 dims without this revision.

mlir/test/lib/Transforms/TestLinalgTransforms.cpp
87

make sense! will change the name in the next revision

Use tile-sizes-for-padding test argument

hanchung accepted this revision.Feb 26 2021, 12:10 AM

Otherwise we need to change the semantics of PadOp to accept [%size...] attributes.

I think the pad op can accept [%size ...] ? See https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/Linalg/roundtrip.mlir#L30-L37

func @pad_dynamic(%arg0: tensor<1x2x2x?xf32>, %low: index, %high: index,
                  %pad_value: f32) -> tensor<6x?x?x?xf32> {
  %0 = linalg.pad_tensor %arg0 low[2, %low, 3, 3] high[3, 3, %high, 2] {
    ^bb0(%arg1: index, %arg2: index, %arg3: index, %arg4: index):
      linalg.yield %pad_value : f32
    } : tensor<1x2x2x?xf32> to tensor<6x?x?x?xf32>
  return %0 : tensor<6x?x?x?xf32>
}
This revision is now accepted and ready to land.Feb 26 2021, 12:10 AM

I didn't intend to click approval...

mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
276–277

Ok, then this deserves a separate commit and a test case that exhibits the behavior, independently of your current CL (which is otherwise good to go from my perspective).

asaadaldien added inline comments.Mar 1 2021, 12:39 PM
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
276–277

done in https://reviews.llvm.org/D97720, retire this diff now..

asaadaldien abandoned this revision.Mar 1 2021, 12:40 PM

split into others started( https://reviews.llvm.org/D97720)