This is an archive of the discontinued LLVM Phabricator instance.

[mlir][transform] Add TrackingListener
ClosedPublic

Authored by springerm on Mar 28 2023, 3:54 AM.

Details

Summary

This change makes it possible to use a greedy pattern rewrite as part of a transform op, even if the transform op does not invalidate the target handle (in particular transform ops without FunctionalStyleTransformOpTrait) and the targeted op is not isolated from above.

The listener API allows us to track replacements of ops with values, but not ops with ops. Therefore, the TrackingListener is conservative: If an op is replaced with values that all have the same defining op and the defining op is of the same type as the original op, it is safe to assume that the op was replaced with an equivalent op. Otherwise, the op mapping is dropped. When this is not good enough, transforms can track values instead or provide a custom findReplacementOp function.

Depends On: D147038

Diff Detail

Event Timeline

springerm created this revision.Mar 28 2023, 3:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 3:54 AM
springerm requested review of this revision.Mar 28 2023, 3:54 AM

Note: This listener can be used as a replacement for the TrackingListener in IREE. (It passes the CI.)

nicolasvasilache accepted this revision.Mar 28 2023, 4:57 AM
This revision is now accepted and ready to land.Mar 28 2023, 4:57 AM
This revision was automatically updated to reflect the committed changes.