From 4a8c70c3194aeeb286b4bea1666168f710cbe04f Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Tue, 6 Oct 2020 07:59:02 +0000 Subject: [PATCH] [mlir][Linalg] Reintroduced missing verification check A verification check on the number of indexing maps seems to have dropped inadvertently. Also update the relevant roundtrip tests. --- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 6 ++++++ mlir/test/Dialect/Linalg/roundtrip.mlir | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 26aa759..082078d 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -398,6 +398,12 @@ static LogicalResult verifyGenericOp(GenericOpType op) { expectedNumSymbols = op.getShapedType(index).getRank(); } + if (op.indexing_maps().size() != op.getNumInputsAndOutputs()) + return op.emitOpError("expected the number of indexing_map (") + << op.indexing_maps().size() + << ") to be equal to the number of inputs and outputs (" + << op.getNumInputsAndOutputs() << ")"; + SmallVector indexingMaps; indexingMaps.reserve(op.indexing_maps().size()); for (auto en : llvm::enumerate(op.indexing_maps())) { diff --git a/mlir/test/Dialect/Linalg/roundtrip.mlir b/mlir/test/Dialect/Linalg/roundtrip.mlir index 868cabb..b4347ca 100644 --- a/mlir/test/Dialect/Linalg/roundtrip.mlir +++ b/mlir/test/Dialect/Linalg/roundtrip.mlir @@ -343,6 +343,7 @@ func @generic_with_tensor_input(%arg0: tensor>, #accesses = [ affine_map<(i, j, k) -> (j, i)>, + affine_map<(i, j, k) -> (i, k, i + j)>, affine_map<(i, j, k) -> (i, k, i + j)> ] @@ -377,6 +378,7 @@ func @generic_with_tensor_input_and_output( #accesses = [ affine_map<(i, j, k) -> (j, i)>, + affine_map<(i, j, k) -> (i, k, i + j)>, affine_map<(i, j, k) -> (i, k, i + j)> ] -- 2.7.4