Hi,
I am a beginner trying to make a new dialect with MLIR. I followed the " Defining Dialect Attributes and Types" tutorial to define new types, but when the new types are used in newly defined ops, the error is reported:
error: type of result #0, named ‘res’, is not buildable and a buildable type cannot be inferred
But I have provided the customed builder for the new type, why is this error reported?
Here is the code for defining a new type
def AccTensorType : AccTensor_Type<"AccTensorType", "tensor"> {
let summary = "Tensor type for accelerators";
let description = [{
Tensor type for accelerators.
}];
let parameters = (ins "Type":$addr,
"Type":$bound,
"Type":$step);
let assemblyFormat = "`<` $addr `,` $bound `,` $step `>`";
let genVerifyDecl = 1;
let skipDefaultBuilders = 1;
let builders = [
TypeBuilderWithInferredContext<(ins "Type":$addr,
"Type":$bound,
"Type":$step), [{
return Base::get(addr.getContext(), addr, bound, step);
}]>
];
}
Here is the code for defining the new op:
def AccTensor_Sum : AccTensor_Op<"sum", [NoSideEffect,
SameOperandsAndResultType]> {
let summary = "Sum the sub-tensors";
let description = [{
Sum the sub-tensors.
}];
let arguments = (ins AccTensorType:$input1,
AccTensorType:$input2);
let results = (outs AccTensorType:$res);
let assemblyFormat = "$input1 `,` $input2 attr-dict" ;
}