This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Transform] Add `updateConversionTarget` to `ConversionPatternDescriptorOpInterface`
ClosedPublic

Authored by christopherbate on Aug 23 2023, 1:59 PM.

Details

Summary

This change adds a method to modify the ConversionTarget used during
transform.apply_conversion_patterns to the
ConversionPatternDescriptorOpInterface. This is needed when the TypeConverter
is used to dictate the dynamic legality of operations, as in "structural"
conversion patterns present in, for example, the SCF and func dialects.

As a first use case/test, this change also adds a
transform.apply_patterns.scf.structural_conversions operation to the SCF
dialect.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 1:59 PM
christopherbate requested review of this revision.Aug 23 2023, 1:59 PM

Add missing check statements

springerm accepted this revision.Aug 24 2023, 12:47 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.td
338–339

I'd mention structural type conversions as an example use case here. Mention that type converters are set up such that legal types are converted to themselves and an op is considered illegal (a property of the conversion target) if one of its result/operand types maps to a type different from itself. (To clarify the connection between the conversion target and the type converter; at first glance they seem unrelated.)

342

nit: I'd call it populateConversionTargetRules. (update may sound like the existing rules are overwritten)

343

Let's use a const reference here.

mlir/test/Dialect/SCF/transform-ops.mlir
310

new line missing

This revision is now accepted and ready to land.Aug 24 2023, 12:47 AM
mlir/test/Dialect/SCF/transform-ops.mlir
288

hmm I am a bit confused, what triggers a tensor -> memref conversion here ?

springerm added inline comments.Aug 30 2023, 1:47 AM
mlir/test/Dialect/SCF/transform-ops.mlir
288

The TestTypeConverter in the test case does that.

addConversion([](RankedTensorType type) -> Type {
  return MemRefType::get(type.getShape(), type.getElementType());
});
christopherbate marked 4 inline comments as done.

Address review comments

This revision was landed with ongoing or failed builds.Sep 14 2023, 10:40 AM
This revision was automatically updated to reflect the committed changes.