This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Shape] Lower `shape_of` to `dynamic_tensor_from_elements`
ClosedPublic

Authored by frgossen on Sep 1 2020, 6:29 AM.

Details

Summary

Take advantage of the new dynamic_tensor_from_elements operation in std.
Instead of stack-allocated memory, we can now lower directly to a single std
operation.

Depends On D86779

Diff Detail

Event Timeline

frgossen created this revision.Sep 1 2020, 6:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2020, 6:29 AM
frgossen requested review of this revision.Sep 1 2020, 6:29 AM
herhut requested changes to this revision.Sep 1 2020, 8:49 AM

Mostly nits. Thanks for adding this!

mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
460

not: iv or idx? Could also use dim as this is what this value represents.

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
1704

result.regions.front()?

1705

Maybe use b.createBlock and a SmallVector to represent the index types?

1714

createBlock would do this for you, so you have to move the guard in front of it.

This revision now requires changes to proceed.Sep 1 2020, 8:49 AM
jpienaar requested changes to this revision.Sep 1 2020, 9:32 AM
jpienaar added inline comments.
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
1509

Nit: could you add a comment here? (just basic tblgen one as I don't think we have way to generate comments in C++ from here yet)

mlir/lib/Conversion/ShapeToStandard/ShapeToStandard.cpp
460

Could args.front() be used?

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
1708

Is this verified so that we can just cast here?

frgossen updated this revision to Diff 290306.Sep 7 2020, 9:34 AM
frgossen marked 7 inline comments as done.

Address comments

mlir/lib/Dialect/StandardOps/IR/Ops.cpp
1708

Yes, result type is AnyRankedTensor.

herhut accepted this revision.Sep 8 2020, 3:28 AM

Thanks!

This revision was not accepted when it landed; it landed in state Needs Review.Sep 9 2020, 12:55 AM
This revision was automatically updated to reflect the committed changes.