-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dialects: (vector) Add vector.insertelement and vector.extractelement (…
…#3649) Added "vector.insertelement" and "vector.extractelement" ops
- Loading branch information
1 parent
d5dd188
commit 0e1cec0
Showing
6 changed files
with
311 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/filecheck/dialects/vector/vector_extractelement_verify.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: xdsl-opt --split-input-file --verify-diagnostics %s | filecheck %s | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<index>, index) | ||
|
||
%0 = "vector.extractelement"(%vector, %i0) : (vector<index>, index) -> index | ||
// CHECK: Expected position to be empty with 0-D vector. | ||
|
||
// ----- | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<4x4xindex>, index) | ||
|
||
%0 = "vector.extractelement"(%vector, %i0) : (vector<4x4xindex>, index) -> index | ||
// CHECK: Operation does not verify: Unexpected >1 vector rank. | ||
|
||
// ----- | ||
|
||
%vector, %i0= "test.op"() : () -> (vector<4xindex>, index) | ||
|
||
%0 = "vector.extractelement"(%vector, %i0) : (vector<4xindex>, index) -> f64 | ||
// CHECK: Expected result type to match element type of vector operand. | ||
|
||
// ----- | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<1xindex>, index) | ||
|
||
%1 = "vector.extractelement"(%vector) : (vector<1xindex>) -> index | ||
// CHECK: Expected position for 1-D vector. |
34 changes: 34 additions & 0 deletions
34
tests/filecheck/dialects/vector/vector_insertelement_verify.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// RUN: xdsl-opt --split-input-file --verify-diagnostics %s | filecheck %s | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<index>, index) | ||
|
||
%0 = "vector.insertelement"(%i0, %vector, %i0) : (index, vector<index>, index) -> vector<index> | ||
// CHECK: Expected position to be empty with 0-D vector. | ||
|
||
// ----- | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<1xindex>, index) | ||
|
||
%1 = "vector.insertelement"(%i0, %vector) : (index, vector<1xindex>) -> vector<1xindex> | ||
// CHECK: Expected position for 1-D vector. | ||
|
||
// ----- | ||
|
||
%vector, %i0, %f0 = "test.op"() : () -> (vector<4xindex>, index, f64) | ||
|
||
%0 = "vector.insertelement"(%f0, %vector, %i0) : (f64, vector<4xindex>, index) -> vector<4xindex> | ||
// CHECK: Expected source operand type to match element type of dest operand. | ||
|
||
// ----- | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<4xindex>, index) | ||
|
||
%0 = "vector.insertelement"(%i0, %vector, %i0) : (index, vector<4xindex>, index) -> vector<3xindex> | ||
// CHECK: Expected dest operand and result to have matching types. | ||
|
||
// ----- | ||
|
||
%vector, %i0 = "test.op"() : () -> (vector<4x4xindex>, index) | ||
|
||
%0 = "vector.insertelement"(%i0, %vector, %i0) : (index, vector<4x4xindex>, index) -> vector<4x4xindex> | ||
// CHECK: Operation does not verify: Unexpected >1 vector rank. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/filecheck/mlir-conversion/with-mlir/dialects/vector/ops.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: xdsl-opt --print-op-generic %s | mlir-opt --mlir-print-op-generic | xdsl-opt --print-op-generic | filecheck %s | ||
|
||
builtin.module{ | ||
|
||
%vector0, %vector1, %i0 = "test.op"() : () -> (vector<index>, vector<3xindex>, index) | ||
// CHECK: %0, %1, %2 = "test.op"() : () -> (vector<index>, vector<3xindex>, index) | ||
|
||
%0 = "vector.insertelement"(%i0, %vector0) : (index, vector<index>) -> vector<index> | ||
// CHECK-NEXT: %3 = "vector.insertelement"(%2, %0) : (index, vector<index>) -> vector<index> | ||
|
||
%1 = "vector.insertelement"(%i0, %vector1, %i0) : (index, vector<3xindex>, index) -> vector<3xindex> | ||
// CHECK-NEXT: %4 = "vector.insertelement"(%2, %1, %2) : (index, vector<3xindex>, index) -> vector<3xindex> | ||
|
||
%2 = "vector.extractelement"(%vector1, %i0) : (vector<3xindex>, index) -> index | ||
// CHECK-NEXT: %5 = "vector.extractelement"(%1, %2) : (vector<3xindex>, index) -> index | ||
|
||
%3 = "vector.extractelement"(%vector0) : (vector<index>) -> index | ||
// CHECK-NEXT: %6 = "vector.extractelement"(%0) : (vector<index>) -> index | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters