Index: mlir/include/mlir/Dialect/Vector/VectorOps.td =================================================================== --- mlir/include/mlir/Dialect/Vector/VectorOps.td +++ mlir/include/mlir/Dialect/Vector/VectorOps.td @@ -468,33 +468,17 @@ Similarly to vector.tuple_get, this operation is used for progressive lowering and should be folded away before converting to LLVM. - - For instance, the following code: - ```mlir - %a = vector.transfer_read %A[%c0]: memref<32xf32>, vector<32xf32> - %b = vector.transfer_read %B[%c0]: memref<32xf32>, vector<32xf32> - %c = addf %a, %b: vector<32xf32> - vector.transfer_write %c, %C[%c0]: memref<32xf32>, vector<32xf32> + For instance: ``` - can be rewritten to: - ```mlir - %a = vector.transfer_read %A[%c0]: memref<32xf32>, vector<32xf32> - %b = vector.transfer_read %B[%c0]: memref<32xf32>, vector<32xf32> - %ea = vector.extract_map %a[%id : 32] : vector<32xf32> to vector<1xf32> - %eb = vector.extract_map %b[%id : 32] : vector<32xf32> to vector<1xf32> - %ec = addf %ea, %eb : vector<1xf32> - %c = vector.insert_map %ec, %id, 32 : vector<1xf32> to vector<32xf32> - vector.transfer_write %c, %C[%c0]: memref<32xf32>, vector<32xf32> - ``` - - Where %id can be an induction variable or an SPMD id going from 0 to 31. - - And then be rewritten to: - ```mlir - %a = vector.transfer_read %A[%id]: memref<32xf32>, vector<1xf32> - %b = vector.transfer_read %B[%id]: memref<32xf32>, vector<1xf32> - %c = addf %a, %b: vector<1xf32> - vector.transfer_write %c, %C[%id]: memref<32xf32>, vector<1xf32> + // dynamic computation producing the value 0 of index type + %idx0 = ... : index + // dynamic computation producing the value 1 of index type + %idx1 = ... : index + %0 = constant dense<0, 1, 2, 3>: vector<4xi32> + // extracts values [0, 1] + %1 = vector.extract_map %0[%idx0 : 2] : vector<4xi32> to vector<2xi32> + // extracts values [1, 2] + %2 = vector.extract_map %0[%idx1 : 2] : vector<4xi32> to vector<2xi32> ``` Example: @@ -708,8 +692,23 @@ lowering and should be folded away before converting to LLVM. This operations is meant to be used in combination with vector.extract_map. - See example in extract.map description. + For instance: + ``` + // dynamic computation producing the value 0 of index type + %idx0 = ... : index + // dynamic computation producing the value 1 of index type + %idx1 = ... : index / + %0 = constant dense<0, 1, 2, 3>: vector<4xi32> + // extracts values [0, 1] + %1 = vector.extract_map %0[%idx0 : 2] : vector<4xi32> to vector<2xi32> + // extracts values [1, 2] + %2 = vector.extract_map %0[%idx1 : 2] : vector<4xi32> to vector<2xi32> + // insert [0, 1] into [x, x, x, x] and produce [0, 1, x, x] + %3 = vector.insert_map %1, %idx0, 2 : vector<2xi32> to vector<4xi32> + // insert [1, 2] into [x, x, x, x] and produce [x, 1, 2, x] + %4 = vector.insert_map %2, %idx1 : 2 : vector<2xi32> to vector<4xi32> + ``` Example: ```mlir