Skip to content

Commit 3d79b27

Browse files
committed
[mlir][VectorOps] Add deinterleave operation to vector dialect
The deinterleave operation constructs two vectors from a single input vector. Each new vector is the collection of even and odd elements from the input, respectively. This is essentially the inverse of an interleave operation. Each output's size is half of the input vector's trailing dimension for the n-D case and only dimension for 1-D cases. It is not possible to conduct the operation on 0-D inputs or vectors where the size of the (trailing) dimension is 1. The operation supports scalable vectors. Example: ```mlir %0 = vector.deinterleave %a : vector<[4]xi32> -> vector<[2]xi32> %1 = vector.deinterleave %b : vector<8xi8> -> vector<4xi8> %2 = vector.deinterleave %c : vector<2x8xf32> -> vector<2x4xf32> %3 = vector.deinterleave %d : vector<2x4x[6]xf64> -> vector<2x4x[3]xf64> ```
1 parent 11dc393 commit 3d79b27

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.td

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,12 @@ class ResultIsHalfSourceVectorType<string result> : TypesMatchWith<
561561

562562
def SourceVectorEvenElementCount : PredOpTrait<
563563
"the trailing dimension of the source vector has an even number of elements",
564-
CPred<[{
565-
[&](){
566-
auto srcVec = getSourceVectorType();
567-
return srcVec.getDimSize(srcVec.getRank() - 1) % 2 == 0;
568-
}()
569-
}]>
564+
CPred<[{
565+
[&](){
566+
auto srcVec = getSourceVectorType();
567+
return srcVec.getDimSize(srcVec.getRank() - 1) % 2 == 0;
568+
}()
569+
}]>
570570
>;
571571

572572
def Vector_DeinterleaveOp :
@@ -592,16 +592,16 @@ def Vector_DeinterleaveOp :
592592
Example:
593593
```mlir
594594
%0, %1 = vector.deinterleave %a
595-
:vector<8xi8> -> vector<4xi8>
595+
: vector<8xi8> -> vector<4xi8>
596596
%2, %3 = vector.deinterleave %b
597597
: vector<2x8xi8> -> vector<2x4xi8>
598-
%4, %5 = vector.deinterleave %b
598+
%4, %5 = vector.deinterleave %c
599599
: vector<2x8x4xi8> -> vector<2x8x2xi8>
600-
%6, %7 = vector.deinterleave %c
600+
%6, %7 = vector.deinterleave %d
601601
: vector<[8]xf32> -> vector<[4]xf32>
602-
%8, %9 = vector.deinterleave %d
602+
%8, %9 = vector.deinterleave %e
603603
: vector<2x[6]xf64> -> vector<2x[3]xf64>
604-
%10, %11 = vector.deinterleave %d
604+
%10, %11 = vector.deinterleave %f
605605
: vector<2x4x[6]xf64> -> vector<2x4x[3]xf64>
606606
```
607607
}];

0 commit comments

Comments
 (0)