This is an archive of the discontinued LLVM Phabricator instance.

[mlir][transform] Add apply_conversion_patterns op
ClosedPublic

Authored by springerm on Aug 4 2023, 8:18 AM.

Details

Summary

This transform op applies a dialect conversion to the targeted ops. Its design is similar to apply_patterns.

Patterns are specified in the first region of apply_conversion_patterns. They must implement the ConversionPatternDescriptorOpInterface. Regular rewrite patterns and dialect conversion patterns should not be mixed, so the interface is separate from the PatternDescriptorOpInterface.

The type converter is specified as the single op of the second region. It is optional; if no type converter is specified, it is expected that pattern descriptors provide their own type converters. If both the pattern descriptors and the apply_conversion_patterns op specify a type converter, the type converter of the pattern descriptor is used.

Diff Detail

Event Timeline

springerm created this revision.Aug 4 2023, 8:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 8:18 AM
springerm requested review of this revision.Aug 4 2023, 8:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 8:19 AM
nicolasvasilache accepted this revision.Aug 4 2023, 9:07 AM

Great, thank you, much better!

mlir/lib/Dialect/Transform/IR/TransformOps.cpp
526

can we hoist this out in a separate static function ?

This revision is now accepted and ready to land.Aug 4 2023, 9:07 AM
springerm added inline comments.Aug 6 2023, 11:46 PM
mlir/lib/Dialect/Transform/IR/TransformOps.cpp
526

It cannot be easily factored out because this (transform op), op and defaultTypeConverter is used. I tried it and the code doesn't look much more readable.

This revision was automatically updated to reflect the committed changes.