[Mlir-commits] [mlir] [mlir][vector] Add verification for incorrect vector.extract (PR #115824)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Wed Nov 13 04:48:31 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>
+}
+
+// -----
+
+func.func @extract_from_1d_to_0d_wrong_index(%arg0: vector<1xf32>) {
+ // expected-error at +1 {{'vector.extract' op expected indexed vector rank minus number of indices to match the rank of the non-indexed vector rank}}
+ %2 = vector.extract %arg0[] : vector<f32> from vector<1xf32>
+}
+
+// -----
+
+func.func @extract_from_1d_to_0d(%arg0: vector<1xf32>) {
+ // expected-error at +2 {{'vector.extract' op inferred type(s) 'f32' are incompatible with return type(s) of operation 'vector<f32>'}}
+ // expected-error at +1 {{failed to infer returned types}}
+ %4 = vector.extract %arg0[0] : vector<f32> from vector<1xf32>
+}
+
+// -----
+
+func.func @extract_from_2d_to_scalar(%arg0: vector<4x1xf32>) {
+ // expected-error at +1 {{'vector.extract' op expected indexed vector rank to match the number of indices for scalar cases}}
+ %6 = vector.extract %arg0[2] : f32 from vector<4x1xf32>
+}
+
+// -----
+
+func.func @extract_from_2d_to_0d(%arg0: vector<4x1xf32>) {
+ // expected-error at +1 {{'vector.extract' op expected indexed vector rank minus number of indices to match the rank of the non-indexed vector rank}}
+ %7 = vector.extract %arg0[2] : vector<f32> from vector<4x1xf32>
+}
+
+// -----
+
+func.func @extract_from_2d_to_scalar_wrong_index(%arg0: vector<4x8xf32>) {
----------------
banach-space wrote:
How is this different to `@extract_from_2d_to_scalar`?
https://github.com/llvm/llvm-project/pull/115824
More information about the Mlir-commits
mailing list