This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Interfaces] ReifyRankedShapedTypeOpInterface returns OpFoldResults
ClosedPublic

Authored by springerm on Mar 3 2023, 8:53 AM.

Details

Summary

reifyResultShapes now returns OpFoldResults instead of Values. This is often more efficient because many transformations immediately attempt to extract a constant from the reified values.

Diff Detail

Event Timeline

springerm created this revision.Mar 3 2023, 8:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 8:53 AM
springerm requested review of this revision.Mar 3 2023, 8:53 AM
mravishankar accepted this revision.Mar 3 2023, 10:35 AM

Awesome! Thanks!

This revision is now accepted and ready to land.Mar 3 2023, 10:35 AM

Should this be renamed now? E.g., reifyResultShapes now only sometimes reify. (I think folks are also reaching here for something closer to what onnx-mlir and others are doing)

Should this be renamed now? E.g., reifyResultShapes now only sometimes reify. (I think folks are also reaching here for something closer to what onnx-mlir and others are doing)

Maybe, depending on what "reification" means. If you interpret it as "building some handle that you can pass around in C++" (Value or Attribute), the name is still correct.

Btw, I am preparing additional changes to this interface that would allow users to reify specific dimensions and populate a FlatAffineValueConstraints (so that the "reification results" of multiple chained ops can be combined and analyzed).

Should this be renamed now? E.g., reifyResultShapes now only sometimes reify. (I think folks are also reaching here for something closer to what onnx-mlir and others are doing)

Maybe, depending on what "reification" means. If you interpret it as "building some handle that you can pass around in C++" (Value or Attribute), the name is still correct.

Btw, I am preparing additional changes to this interface that would allow users to reify specific dimensions and populate a FlatAffineValueConstraints (so that the "reification results" of multiple chained ops can be combined and analyzed).

That sounds similar to what onnx-mlir does, have you looked at what they are doing? ( https://github.com/onnx/onnx-mlir/blob/main/src/Interface/ShapeHelperOpInterface.hpp may be good entry).

That sounds similar to what onnx-mlir does, have you looked at what they are doing? ( https://github.com/onnx/onnx-mlir/blob/main/src/Interface/ShapeHelperOpInterface.hpp may be good entry).

Thx for the pointer, it definitely looks similar. My approach is a bit different because we want to support lower/upper bounds in addition to EQ bounds. I posted an RFC on Discourse as this may be interesting for various downstream projects.