This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Enhance padding LinalgOps to handle tensor.empty cases.
ClosedPublic

Authored by hanchung on Jan 31 2023, 7:25 PM.

Diff Detail

Event Timeline

hanchung created this revision.Jan 31 2023, 7:25 PM
hanchung requested review of this revision.Jan 31 2023, 7:25 PM
hanchung updated this revision to Diff 493821.Jan 31 2023, 9:39 PM

rebase and fix tests

nicolasvasilache accepted this revision.Feb 5 2023, 12:05 PM

Thanks for extending!
Could you point me to your usage of this abstraction (offline is fine)?

mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
131

Can you reshuffle this a bit to early-exit ?

auto sliceOp = dyn_cast...;
auto emptyOp = dyn_cast...;
if (!sliceOp && !emptyOp) return failure();
etc
This revision is now accepted and ready to land.Feb 5 2023, 12:05 PM

Thanks for extending!
Could you point me to your usage of this abstraction (offline is fine)?

Thanks for reviewing it!

The example is come from IREE. A tensor.empty op takes a result of affine_min after tiling: https://gist.githubusercontent.com/hanhanW/0ff19d0817b9b41b0a6a0a846db6a53d/raw

%20 = affine.min affine_map<(d0) -> (-d0 + 72, 32)>(%arg4)
%21 = tensor.empty(%20) : tensor<8x?xi32>
%22 = linalg.fill ins(%c0_i32 : i32) outs(%21 : tensor<8x?xi32>) -> tensor<8x?xi32>
%23 = linalg.matmul ins(%extracted_slice, %extracted_slice_1 : tensor<8x24xi8>, tensor<24x?xi8>) outs(%22 : tensor<8x?xi32>) -> tensor<8x?xi32>

If the source is not tensor.empty op, it will become extract_slice(%src) -- which works well with existing patterns. If the source is tensor.empty, some patterns are kicked in and create tensor.empty op that takes bounded sizes. For more details, see https://github.com/iree-org/iree/issues/11880

hanchung updated this revision to Diff 495992.Feb 8 2023, 5:48 PM

address comments