This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tensor] Insert explicit tensor.cast ops for insert_slice src
ClosedPublic

Authored by springerm on Aug 24 2021, 12:18 AM.

Details

Summary

If additional static type information can be deduced from a insert_slice's size operands, insert an explicit cast of the op's source operand.

This enables other canonicalization patterns that are matching for tensor_cast ops such as ForOpTensorCastFolder in SCF.

Diff Detail

Event Timeline

springerm created this revision.Aug 24 2021, 12:18 AM
springerm requested review of this revision.Aug 24 2021, 12:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2021, 12:18 AM
herhut accepted this revision.Aug 24 2021, 2:55 AM
This revision is now accepted and ready to land.Aug 24 2021, 2:55 AM
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
1174

Note, all OpWithOffsetSizesAndStrides may take only a subset of
leading values (and auto complete the remaining ones to the canonical expected offsets/sizes/strides); as a consequence this may overflow.

Sending a bugfix for this but FYI there may be other occurrences.
One easy way to track them down could be to force the verifier to specify everyhing and run tests (but that will catch false rank-reducing positives; still it should help).

@springerm if you get to it first.