This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Shape] Add canonicalization pattern for `shape.rank`
ClosedPublic

Authored by frgossen on Jun 18 2020, 2:52 AM.

Details

Summary

Replace any rank(shape_of(tensor)) that relies on a ranked tensor with the
corresponding constant const_size.

Depends On D82076

Diff Detail

Event Timeline

frgossen created this revision.Jun 18 2020, 2:52 AM
Herald added a reviewer: silvas. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
silvas accepted this revision.Jun 18 2020, 9:45 AM

Awesome, thanks!

mlir/lib/Dialect/Shape/IR/Shape.cpp
465

nit: getDefiningOp<ShapeOfOp>()

rriddle added inline comments.Jun 18 2020, 10:09 AM
mlir/lib/Dialect/Shape/IR/Shape.cpp
369

nit: inline this variable into its only use.

459

Can you documentation to this pattern? Even just a little code block of the transformation being performed.

frgossen updated this revision to Diff 272060.Jun 19 2020, 7:08 AM
frgossen marked 3 inline comments as done.

Address comments

frgossen retitled this revision from [MLIR][Shape] Add canonicalization pattern for `shape.get_size` to [MLIR][Shape] Add canonicalization pattern for `shape.rank` .Jun 19 2020, 7:09 AM
frgossen edited the summary of this revision. (Show Details)
frgossen retitled this revision from [MLIR][Shape] Add canonicalization pattern for `shape.rank` to [MLIR][Shape] Add canonicalization pattern for `shape.rank`.
pifon2a accepted this revision.Jun 19 2020, 9:27 AM
jpienaar accepted this revision.Jun 22 2020, 2:43 PM

Nice, thanks

mlir/lib/Dialect/Shape/IR/Shape.cpp
465

Is there a : missing before tensor<...> ?

This revision is now accepted and ready to land.Jun 22 2020, 2:43 PM
rriddle added inline comments.Jun 22 2020, 2:45 PM
mlir/lib/Dialect/Shape/IR/Shape.cpp
458

Please use /// for top-level comments.

frgossen updated this revision to Diff 273250.Jun 25 2020, 1:37 AM
frgossen marked 2 inline comments as done.

Address comments

This revision was automatically updated to reflect the committed changes.