[mlir][Linalg] NFC - Add isOutputTensor to LinalgInterfaces.td

This commit is contained in:
Nicolas Vasilache 2021-03-04 12:19:44 +00:00
parent 3ea0e119b9
commit 05882157db

View File

@ -677,6 +677,22 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
return false;
}]
>,
InterfaceMethod<
/*desc=*/[{
Return true if `opOperand` is an output tensor.
}],
/*retTy=*/"bool",
/*methodName=*/"isOutputTensor",
/*args=*/(ins "OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
if (!opOperand->get().getType().template isa<RankedTensorType>())
return false;
if (opOperand->getOperandNumber() >= $_op.getNumInputs())
return true;
return false;
}]
>,
InterfaceMethod<
/*desc=*/[{
Return true if `opOperand` is an init tensor. This is true when it is
@ -687,9 +703,7 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
/*args=*/(ins "OpOperand *":$opOperand),
/*methodBody=*/"",
/*defaultImplementation=*/[{
if (!opOperand->get().getType().template isa<RankedTensorType>())
return false;
if (opOperand->getOperandNumber() < $_op.getNumInputs())
if (!$_op.isOutputTensor(opOperand))
return false;
return payloadUsesValueFromOpOperand(opOperand);
}]