I am writing a conversion pass which lowers MLIR ops to a custom dialect while changing the types ops operate on. I can write a conversion pattern that extends from
OpConversionPattern and pass it a
TypeConverter and that seems to do what I want.
I was hoping to use tablegen to create the conversion patterns using the same type converter. My pattern looks something like this:
def : Pat<(Torch_AtenMulScalarOp $src, (Torch_ConstantIntOp $value)), (MyDialect_ScaleOp $src, $value)>;
Pat patterns in tablegen create patterns that extend from
RewritePattern and I haven’t been able to find a way to pass a type converter. Without it, source type (Torch tensor) will not be getting converted. I am seeing an error along the lines of:
error: 'mydialect.scale' op operand #0 must be Multi-dimensional array with a fixed number of dimensions, but got '!torch.vtensor<[2,2],f32>'
Am I out of luck? Is there an API or a workaround I can use to introduce a
TypeConverter for generated conversion patterns?