[Mlir-commits] [mlir] [mlir][vector] Add verification for incorrect vector.extract (PR #115824)

Diego Caballero llvmlistbot at llvm.org
Sat Nov 16 13:01:47 PST 2024


================
@@ -178,31 +178,110 @@ func.func @extract_precise_position_overflow(%arg0: vector<4x8x16xf32>) {
 
 // -----
 
-func.func @extract_0d(%arg0: vector<f32>) {
-  // expected-error at +1 {{expected position attribute of rank no greater than vector rank}}
+func.func @extract_from_0d_to_scalar_wrong_index(%arg0: vector<f32>) {
+  // expected-error at +1 {{expected a number of indices no greater than the indexed vector rank}}
   %1 = vector.extract %arg0[0] : f32 from vector<f32>
 }
 
 // -----
 
+func.func @extract_from_0d_to_0d_wrong_index(%arg0: vector<f32>) {
+  // expected-error at +1 {{expected a number of indices no greater than the indexed vector rank}}
+  %2 = vector.extract %arg0[0] : vector<f32> from vector<f32>
+}
+
+// -----
+
+func.func @extract_from_0d_to_1d_wrong_index(%arg0: vector<f32>) {
+  // expected-error at +1 {{expected a number of indices no greater than the indexed vector rank}}
+  %3 = vector.extract %arg0[0] : vector<1xf32> from vector<f32>
+}
+
+// -----
+
+func.func @extract_from_1d_to_scalar_wrong_index(%arg0: vector<1xf32>) {
+  // expected-error at +1 {{expected indexed vector rank to match the number of indices for scalar cases}}
+  %1 = vector.extract %arg0[] : f32 from vector<1xf32>
----------------
dcaballe wrote:

> does using vector<1xf32> instead of vector<4xf32> create any new special case

Yes, these tests and PR is focused on the interaction among scalar, 0-D and vector<1xf32> types so that's the reason.

https://github.com/llvm/llvm-project/pull/115824


More information about the Mlir-commits mailing list