This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Use RankedTensorType when rank is required
ClosedPublic

Authored by springerm on Mar 29 2023, 6:29 AM.

Details

Summary

RankedTensorOf and TensorRankOf (in Tablegen files) now generate code that uses RankedTensorType instead of TensorType. This gives us more accurate type information (e.g., when calling op.getType()).

Also use restrict tensor.expand_shape/tensor.collapse_shape/tensor.pad to ranked tensors. Only cast ops should deal with unranked tensors.

Also improves a few places in the code base (e.g., Toy tutorial) where a ranked tensor is assumed (e.g., because getRank is called) but a TensorType is currently used: cast to RankedTensorType directly, so that the assertion is triggered directly at the cast.

Diff Detail

Event Timeline

springerm created this revision.Mar 29 2023, 6:29 AM
springerm requested review of this revision.Mar 29 2023, 6:29 AM
rkayaith added inline comments.
mlir/include/mlir/IR/OpBase.td
796–797

can this use RankedTensorOf now?

address comments

springerm marked an inline comment as done.Mar 30 2023, 12:31 AM
rriddle accepted this revision.Apr 2 2023, 10:44 PM
This revision is now accepted and ready to land.Apr 2 2023, 10:44 PM
This revision was landed with ongoing or failed builds.Apr 5 2023, 9:27 PM
This revision was automatically updated to reflect the committed changes.