This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Add an Op util which returns its name with the dialect stripped.
ClosedPublic

Authored by lucyrfox on Jun 8 2020, 3:34 PM.

Diff Detail

Event Timeline

lucyrfox created this revision.Jun 8 2020, 3:34 PM
Herald added a project: Restricted Project. · View Herald Transcript
lucyrfox edited reviewers, added: jpienaar; removed: rriddle.Jun 8 2020, 3:35 PM
rriddle accepted this revision.Jun 8 2020, 3:37 PM
rriddle added inline comments.
mlir/include/mlir/IR/Operation.h
59 ↗(On Diff #269368)

nit: ///

61 ↗(On Diff #269368)

This won't work for 'func' and 'module' as they don't have a prefix. You need to check if .first is empty.

This revision is now accepted and ready to land.Jun 8 2020, 3:37 PM
rriddle added inline comments.Jun 8 2020, 5:00 PM
mlir/include/mlir/IR/Operation.h
61 ↗(On Diff #269368)

Oops, meant that you need to check if .second is empty.

lucyrfox updated this revision to Diff 269384.Jun 8 2020, 5:25 PM

Added a check for the case where there is no dialect prefix.

Also moved this util to be in OperationSupport alongside getDialect() because it seems to
fit better there.

lucyrfox marked 2 inline comments as done.Jun 8 2020, 5:26 PM
mehdi_amini accepted this revision.Jun 8 2020, 7:01 PM

Are there use cases in-tree that could be updated?

lucyrfox updated this revision to Diff 271226.Jun 16 2020, 3:24 PM

Add one usage of getting dialect directly.

Are there use cases in-tree that could be updated?

Most similar cases in MLIR core are operating on a StringRef instead of an OperationName. There is probably more usage downstream which can be updated incrementally. (I'll take a look separately at what can be updated within TF.)

This revision was automatically updated to reflect the committed changes.