This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Use ReifyRankedShapedTypeOpInterface for pad transforms.
ClosedPublic

Authored by hanchung on May 9 2023, 2:31 PM.

Details

Summary

The information is not tied to tensor.empty op and tensor.extract_slice
op. We can infer smallest static bounding box for pad transform if
they implement ReifyRankedShapedTypeOpInterface. The revision extends
the usability for downstream projects. No tests are added because the
existing tests cover the change, and most of MLIR
ReifyRankedShapedTypeOpInterface ops are covered in the tests, except
tensor.generate and bufferization.alloc_tensor ops.

Diff Detail

Event Timeline

hanchung created this revision.May 9 2023, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2023, 2:31 PM
hanchung requested review of this revision.May 9 2023, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2023, 2:31 PM
mravishankar accepted this revision.May 10 2023, 4:24 PM

I think this looks right to me. Not sure why the droppedDims were there to begin with. Whats done here should make it unnecessary.

This revision is now accepted and ready to land.May 10 2023, 4:24 PM

I think this looks right to me. Not sure why the droppedDims were there to begin with. Whats done here should make it unnecessary.

The droppedDims was needed because of tensor.extract_slice op. If it is a rank-reduced op, the number of elements in sizes does not match the rank of result type. The previous implementations uses getMixedSizes() and droppedDims to model it. Today the extract_slice op implements ReifyRankedShapedTypeOpInterface, so we can get the result sizes from the reifyResultShapes method. The logic is considered in ExtractSliceOp::reifyResultShapes, so we no longer need it.

https://github.com/llvm/llvm-project/blob/f85a8456f114d071fb5985ef2c4cd922ba8f29cf/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp#L1848-L1860