diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -261,7 +261,8 @@ // Output arg Variadic:$inits, - DenseI64ArrayAttr:$dimensions + ConfinedAttr]>:$dimensions ); let results = (outs Variadic); let regions = (region SizedRegion<1>:$combiner); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1340,20 +1340,12 @@ auto initType = getInits()[0].getType().cast(); DenseSet dimensionsToReduce; - int64_t lastDimension = -1; for (int64_t dimension : dimensionsRef) { if (dimension < 0 || dimension >= inputType.getRank()) { return emitOpError() << "dimensions for reduction should be in the range [0, " << inputType.getRank() - 1 << "]."; } - if (dimension <= lastDimension) { - return emitOpError() - << "reduction dimensions are not in increasing order: " - << dimensionsRef; - } - - lastDimension = dimension; dimensionsToReduce.insert(dimension); } diff --git a/mlir/test/Dialect/Linalg/invalid.mlir b/mlir/test/Dialect/Linalg/invalid.mlir --- a/mlir/test/Dialect/Linalg/invalid.mlir +++ b/mlir/test/Dialect/Linalg/invalid.mlir @@ -426,7 +426,7 @@ func.func @reduce_duplicate_dimensions(%input: tensor<16x32x64xf32>, %init: tensor<16xf32>) -> tensor<16xf32> { - // expected-error @+1 {{'linalg.reduce' op reduction dimensions are not in increasing order: 1, 1}} + // expected-error @+1 {{'linalg.reduce' op attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute should be in increasing order}} %reduce = linalg.reduce ins(%input:tensor<16x32x64xf32>) outs(%init:tensor<16xf32>) @@ -442,7 +442,7 @@ func.func @reduce_non_increasing_dimensions(%input: tensor<16x32x64xf32>, %init: tensor<16xf32>) -> tensor<16xf32> { - // expected-error @+1 {{'linalg.reduce' op reduction dimensions are not in increasing order: 2, 1}} + // expected-error @+1 {{'linalg.reduce' op attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute should be in increasing order}} %reduce = linalg.reduce ins(%input:tensor<16x32x64xf32>) outs(%init:tensor<16xf32>)