Hi, I’m new to MLIR and followed the toy language tutorial, in which a constant op with affine lowering is defined. I tried to add a subop for subtraction using the tosa dialect by creating a rewrite pattern:
struct SubOpLowering : public mlir::OpRewritePattern<SubOp> {
using OpRewritePattern<SubOp>::OpRewritePattern;
mlir::LogicalResult matchAndRewrite(SubOp op,
mlir::PatternRewriter &rewritter) const final {
auto output_type = op.getResult().getType().dyn_cast<RankedTensorType>();
if (!output_type) {
return failure();
}
rewritter.replaceOpWithNewOp<mlir::tosa::SubOp>(op, output_type, op.getOperand(0), op.getOperand(1));
return mlir::success();
}
};
but got an error:
error: 'tosa.sub' op operand #0 must be 0D/1D/2D/3D/4D tensor of number values, but got 'tensor<2x3xf64>'
On the first look, it seems to be tosa dialect doesn’t recognize the tensor created by the constant op defined in the toy tutorial? Could you please provide some guidance and examples on how to mix these tensor types? I read Dialect Conversion - MLIR but it doesn’t provide much details.