This is an archive of the discontinued LLVM Phabricator instance.

[mlir][IR] Improve `clone` function return type of shaped types
ClosedPublic

Authored by springerm on May 18 2023, 5:38 AM.

Details

Summary

There are clone overloads that take a shape as a parameter. These overloads are guaranteed to return a ranked shaped type.

TensorType::clone/BaseMemRefType::clone used to always return a TensorType/BaseMemRefType. The variants that take a shape parameter now return a RankedTensorType/MemRefType. Better static type information can make extra casts at the call site obsolete.

E.g.:

{TensorType/RankedTensorType} t;
t.clone({1, 2})  // now returns RankedTensorType instead of TensorType

Also improve documentation for clone.

Diff Detail

Event Timeline

springerm created this revision.May 18 2023, 5:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2023, 5:38 AM
springerm requested review of this revision.May 18 2023, 5:39 AM
rriddle accepted this revision.May 24 2023, 9:51 AM
This revision is now accepted and ready to land.May 24 2023, 9:51 AM