This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Fix bug in InferStaticShapeOfOperands pattern
ClosedPublic

Authored by vinograd47 on Nov 10 2022, 2:29 AM.

Details

Summary

The pattern tries to deduce static shape from tensor.cast producer of linalg operation operands.
The original code unconditionally casts type of the tensor.cast source to RankedTensorType.
But the tensor.cast can also operate on UnrankedTensorType, so this cast either fail on assertion
in debug build or introduce UB in release build.

The patch replaces unconditional cast with dyn_cast and check for the cast result.

Diff Detail

Event Timeline

vinograd47 created this revision.Nov 10 2022, 2:29 AM
vinograd47 requested review of this revision.Nov 10 2022, 2:29 AM
mravishankar accepted this revision.Nov 16 2022, 12:12 AM
This revision is now accepted and ready to land.Nov 16 2022, 12:12 AM