From cb037ede6e991d7f1984bae872b3f97f1690b56c Mon Sep 17 00:00:00 2001 From: Andrzej Warzynski Date: Wed, 27 Nov 2024 10:51:56 +0000 Subject: [PATCH] [mlir][vector] Disable `from_elements` for scalable vectors Disables `vector.from_elements` for scalable vectors. Given that the length of scalable vectors is unknown at compile time, the semantics of this Op are unclear in this context. --- mlir/include/mlir/Dialect/Vector/IR/VectorOps.td | 4 +++- mlir/test/Dialect/Vector/invalid.mlir | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td index 88c1b94412241..a1c2dad8c2b8b 100644 --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -806,10 +806,12 @@ def Vector_FromElementsOp : Vector_Op<"from_elements", [ // [[[%f1, %f2]], [[%f3, %f4]], [[%f5, %f6]]] %3 = vector.from_elements %f1, %f2, %f3, %f4, %f5, %f6 : vector<3x1x2xf32> ``` + + Note, scalable vectors are not supported. }]; let arguments = (ins Variadic:$elements); - let results = (outs AnyVectorOfAnyRank:$result); + let results = (outs AnyFixedVectorOfAnyRank:$result); let assemblyFormat = "$elements attr-dict `:` type($result)"; let hasCanonicalizer = 1; } diff --git a/mlir/test/Dialect/Vector/invalid.mlir b/mlir/test/Dialect/Vector/invalid.mlir index 00aea3b42841a..c244fe7df3e94 100644 --- a/mlir/test/Dialect/Vector/invalid.mlir +++ b/mlir/test/Dialect/Vector/invalid.mlir @@ -1803,6 +1803,14 @@ func.func @invalid_from_elements(%a: f32, %b: i32) { // ----- +func.func @invalid_from_elements_scalable(%a: f32, %b: i32) { + // expected-error @+1 {{'result' must be fixed-length vector of any type values, but got 'vector<[2]xf32>'}} + vector.from_elements %a, %b : vector<[2]xf32> + return +} + +// ----- + func.func @invalid_step_0d() { // expected-error @+1 {{vector.step' op result #0 must be vector of index values of ranks 1, but got 'vector'}} vector.step : vector