[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>
----------------
banach-space wrote:
IMHO, using "non-trivial" 1D vectors would make this easier to follow (e.g. `vector<1xf32>` -> `vector<4xf32>`).
As in, use 1D vectors with more than one element (0D vectors _always_ hold exactly 1 element). This way it's clearer what the difference between 1D and 0D vectors is.
Now, does using `vector<1xf32>` instead of `vector<4xf32>` create any new special case? If yes then that could be a dedicated test case.
https://github.com/llvm/llvm-project/pull/115824
More information about the Mlir-commits
mailing list