[Mlir-commits] [mlir] [mlir][vector] Add verification for incorrect vector.extract (PR #115824)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Thu Nov 21 07:00:00 PST 2024
================
@@ -259,16 +343,86 @@ func.func @insert_precise_position_overflow(%a: f32, %b: vector<4x8x16xf32>) {
// -----
-func.func @insert_0d(%a: vector<f32>, %b: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected position attribute rank + source rank to match dest vector rank}}
- %1 = vector.insert %a, %b[2, 6] : vector<f32> into vector<4x8x16xf32>
+func.func @insert_scalar_into_0d_wrong_index(%arg0: f32, %arg1: vector<f32>) {
+ // expected-error at +1 {{'vector.insert' op expected a number of indices no greater than the destination vector rank}}
+ %1 = vector.insert %arg0, %arg1[0] : f32 into vector<f32>
+}
+
+// -----
+
+func.func @insert_0d_into_0d_wrong_index(%arg0: vector<f32>, %arg1: vector<f32>) {
+ // expected-error at +1 {{'vector.insert' op expected a number of indices no greater than the destination vector rank}}
+ %2 = vector.insert %arg0, %arg1[0] : vector<f32> into vector<f32>
+}
+
+// -----
+
+func.func @insert_1d_into_0d_wrong_index(%arg0: vector<1xf32>, %arg1: vector<f32>) {
+ // expected-error at +1 {{'vector.insert' op expected a number of indices no greater than the destination vector rank}}
+ %3 = vector.insert %arg0, %arg1[0] : vector<1xf32> into vector<f32>
+}
+
+// -----
+
+func.func @insert_scalar_into_1d_wrong_index(%arg0: f32, %arg1: vector<1xf32>) {
+ // expected-error at +1 {{'vector.insert' op expected destination vector rank to match the number of indices for scalar cases}}
+ %1 = vector.insert %arg0, %arg1[] : f32 into vector<1xf32>
+}
+
+// -----
+
+func.func @insert_0d_into_1d_wrong_index(%arg0: vector<f32>, %arg1: vector<1xf32>) {
+ // expected-error at +1 {{'vector.insert' op expected source and destination vectors with different number of elements}}
+ %2 = vector.insert %arg0, %arg1[] : vector<f32> into vector<1xf32>
+}
+
+// -----
+
+func.func @insert_0d_into_1d(%arg0: vector<f32>, %arg1: vector<1xf32>) {
+ // expected-error at +1 {{'vector.insert' op expected source and destination vectors with different number of elements}}
+ %4 = vector.insert %arg0, %arg1[0] : vector<f32> into vector<1xf32>
+}
+
+// -----
+
+func.func @insert_1d_into_0d(%arg0: vector<1xf32>, %arg1: vector<f32>) {
----------------
banach-space wrote:
```suggestion
func.func @insert_1d_with_1_elem_into_0d(%arg0: vector<1xf32>, %arg1: vector<f32>) {
```
https://github.com/llvm/llvm-project/pull/115824
More information about the Mlir-commits
mailing list