[Mlir-commits] [mlir] [mlir][linalg] raise generic to named ops. (PR #110421)
Andrzej Warzyński
llvmlistbot at llvm.org
Mon Oct 7 06:21:15 PDT 2024
================
@@ -49,18 +50,41 @@ bool linalg::detail::canOpOperandsBeDroppedImpl(
return inversePermutation(concatAffineMaps(indexingMaps)) != AffineMap();
}
+// Returns true if all loops of the linalgOp are parallel
+static bool isAllParallel(LinalgOp op) {
+ return op.getNumParallelLoops() == op.getNumLoops();
+}
+
+// Returns true if and only if linalgOp takes one input and one init.
+static bool isSingleInputOutput(LinalgOp op) {
+ return op.getNumDpsInputs() == 1 && op.getNumDpsInits() == 1;
+}
+// Returns true if genericOp body is just a yieldOp that yields
+// input operand as result.
+static bool isSingleYieldOp(GenericOp op) {
+ if (op.getNumDpsInputs() != 1 || op.getNumDpsInits() != 1)
+ return false;
+
+ Block *body = op.getBody();
+ if (body->getOperations().size() != 1)
+ return false;
+
+ auto yieldOp = dyn_cast<linalg::YieldOp>(body->back());
+ if (!yieldOp || yieldOp.getNumOperands() != 1 ||
+ yieldOp->getOperand(0) != body->getArgument(0))
+ return false;
+ return true;
+}
+
//===----------------------------------------------------------------------===//
// CopyOpInterface implementation
//===----------------------------------------------------------------------===//
bool linalg::isaCopyOpInterface(LinalgOp linalgOp) {
- // Structural.
- if (linalgOp.getNumParallelLoops() != linalgOp.getNumLoops())
+ // Structural and operands
----------------
banach-space wrote:
[nit] I don't understand this comment :) appreciate that you are effectively inheriting this, but let's clarify. Does "Structural and operands" mean "Check the structure (no parallel dims?) and the operands (single input/output?)".
Also trying to make sure I understand 😅
https://github.com/llvm/llvm-project/pull/110421
More information about the Mlir-commits
mailing list