[Mlir-commits] [mlir] 923f824 - [mlir][Linalg] Move verification of block arguments back.
Adrian Kuegel
llvmlistbot at llvm.org
Mon Aug 29 03:12:33 PDT 2022
Author: Adrian Kuegel
Date: 2022-08-29T12:12:16+02:00
New Revision: 923f824fe104b79503a172ebdeef27916c6b7ced
URL: https://github.com/llvm/llvm-project/commit/923f824fe104b79503a172ebdeef27916c6b7ced
DIFF: https://github.com/llvm/llvm-project/commit/923f824fe104b79503a172ebdeef27916c6b7ced.diff
LOG: [mlir][Linalg] Move verification of block arguments back.
DestinationStyleOpInterface should be possible to use for ops that don't
have regions. Therefore the check for block arguments should be done in
verifyStructedOpInterface.
Differential Revision: https://reviews.llvm.org/D132836
Added:
Modified:
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
index d2d800309e870..c30f3575e22af 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
@@ -749,6 +749,33 @@ LogicalResult mlir::linalg::detail::verifyStructuredOpInterface(Operation *op) {
}
}
+ // Check the region has exactly one block.
+ if (linalgOp->getNumRegions() != 1 ||
+ !llvm::hasSingleElement(linalgOp->getRegion(0)))
+ return op->emitOpError("expects to have 1 region with 1 block");
+
+ // Simplifying assumption: bbargs match 1-1 with shape operands elemental
+ // types.
+ // TODO: once ranked shape types are plugged in, we may want to drop the
+ // corresponding bbargs, that can never be read from. This will be subject to
+ // consistency discussions (i.e. what to do with output tensors whose bbarg is
+ // not used).
+ Block &block = linalgOp->getRegion(0).front();
+
+ if (linalgOp.getNumInputsAndOutputs() != block.getNumArguments())
+ return op->emitOpError("expected as many non-induction variable region "
+ "arguments as the number of input/output operands");
+
+ for (OpOperand *opOperand : linalgOp.getInputAndOutputOperands()) {
+ Type elementType = getElementTypeOrSelf(opOperand->get());
+ Type argType = block.getArgument(opOperand->getOperandNumber()).getType();
+ if (elementType != argType)
+ return op->emitOpError("expected type of bb argument #")
+ << opOperand->getOperandNumber() << " (" << argType << ")"
+ << " to match element or self type of the corresponding operand ("
+ << elementType << ")";
+ }
+
return success();
}
@@ -794,32 +821,5 @@ mlir::linalg::detail::verifyDestinationStyleOpInterface(Operation *op) {
<< ")";
}
- // Check the region has exactly one block.
- if (dstStyleOp->getNumRegions() != 1 ||
- !llvm::hasSingleElement(dstStyleOp->getRegion(0)))
- return op->emitOpError("expects to have 1 region with 1 block");
-
- // Simplifying assumption: bbargs match 1-1 with shape operands elemental
- // types.
- // TODO: once ranked shape types are plugged in, we may want to drop the
- // corresponding bbargs, that can never be read from. This will be subject to
- // consistency discussions (i.e. what to do with output tensors whose bbarg is
- // not used).
- Block &block = dstStyleOp->getRegion(0).front();
-
- if (dstStyleOp.getNumInputsAndOutputs() != block.getNumArguments())
- return op->emitOpError("expected as many non-induction variable region "
- "arguments as the number of input/output operands");
-
- for (OpOperand *opOperand : dstStyleOp.getInputAndOutputOperands()) {
- Type elementType = getElementTypeOrSelf(opOperand->get());
- Type argType = block.getArgument(opOperand->getOperandNumber()).getType();
- if (elementType != argType)
- return op->emitOpError("expected type of bb argument #")
- << opOperand->getOperandNumber() << " (" << argType << ")"
- << " to match element or self type of the corresponding operand ("
- << elementType << ")";
- }
-
return success();
}
More information about the Mlir-commits
mailing list