Page MenuHomePhabricator

[MLIR] Fix memref get constant bound size and shape method
ClosedPublic

Authored by bondhugula on Jun 29 2021, 10:20 PM.

Details

Summary

Fix FlatAffineConstraints::getConstantBoundOnDimSize to ensure that
returned bounds on dim size are always non-negative regardless of the
constraints on that dimension. Add an assertion at the user.

Diff Detail

Event Timeline

bondhugula created this revision.Jun 29 2021, 10:20 PM
bondhugula requested review of this revision.Jun 29 2021, 10:20 PM

Drop blank line. Update comment.

vinayaka-polymage accepted this revision.Jul 5 2021, 9:32 AM

It seems correct to me, that the constant bound is non-negative always, on principle. Was this bound being negative creating any problem in some cases ? If yes, it might be useful to mention that in comments.

This revision is now accepted and ready to land.Jul 5 2021, 9:32 AM

It seems correct to me, that the constant bound is non-negative always, on principle. Was this bound being negative creating any problem in some cases ? If yes, it might be useful to mention that in comments.

Yes, for any user of that method, a negative bound would be problematic and wrong by definition. For eg. MemRefRegion::getConstantBoundingSizeAndShape is in turn used by memref region compute, which is in turn used by many things including affineDataCopyGenerate. Since this is a lower-level API, we'd like to avoid referring to its users - since the latter change. By design/definition this bound has to be non-negative.