1 // RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(convert-vector-to-scf{full-unroll=true lower-tensors=true}))" -split-input-file -allow-unregistered-dialect | FileCheck %s
3 // CHECK-LABEL: func @transfer_read_2d(
4 // CHECK: %[[V_INIT:.*]] = arith.constant dense<-4.200000e+01> : vector<4x9xf32>
5 // CHECK: %[[V0:.*]] = vector.transfer_read %{{.*}}[{{.*}}], %{{.*}} {in_bounds = [true]} : tensor<?x?xf32>, vector<9xf32>
6 // CHECK: %[[I0:.*]] = vector.insert %[[V0]], %[[V_INIT]] [0] : vector<9xf32> into vector<4x9xf32>
7 // CHECK: %[[V1:.*]] = vector.transfer_read %{{.*}}[{{.*}}], %{{.*}} {in_bounds = [true]} : tensor<?x?xf32>, vector<9xf32>
8 // CHECK: %[[I1:.*]] = vector.insert %[[V1]], %[[I0]] [1] : vector<9xf32> into vector<4x9xf32>
9 // CHECK: %[[V2:.*]] = vector.transfer_read %{{.*}}[{{.*}}], %{{.*}} {in_bounds = [true]} : tensor<?x?xf32>, vector<9xf32>
10 // CHECK: %[[I2:.*]] = vector.insert %[[V2]], %[[I1]] [2] : vector<9xf32> into vector<4x9xf32>
11 // CHECK: %[[V3:.*]] = vector.transfer_read %{{.*}}[{{.*}}], %{{.*}} {in_bounds = [true]} : tensor<?x?xf32>, vector<9xf32>
12 // CHECK: %[[I3:.*]] = vector.insert %[[V3]], %[[I2]] [3] : vector<9xf32> into vector<4x9xf32>
13 // CHECK: return %[[I3]] : vector<4x9xf32>
14 func.func @transfer_read_2d(%A : tensor<?x?xf32>, %base1 : index, %base2 : index)
16 %p = arith.constant -42.0: f32
17 %f = vector.transfer_read %A[%base1, %base2], %p {in_bounds = [true, true]}
18 : tensor<?x?xf32>, vector<4x9xf32>
19 return %f : vector<4x9xf32>
24 // CHECK-LABEL: func @transfer_write_2d(
25 // CHECK: %[[V0:.*]] = vector.extract %{{.*}}[0] : vector<3xf32> from vector<2x3xf32>
26 // CHECK: %[[T0:.*]] = vector.transfer_write %[[V0]], %{{.*}}[{{.*}}] {in_bounds = [true]} : vector<3xf32>, tensor<?x?xf32>
27 // CHECK: %[[V1:.*]] = vector.extract %{{.*}}[1] : vector<3xf32> from vector<2x3xf32>
28 // CHECK: %[[T1:.*]] = vector.transfer_write %[[V1]], %[[T0]][{{.*}}] {in_bounds = [true]} : vector<3xf32>, tensor<?x?xf32>
29 // CHECK: return %[[T1]] : tensor<?x?xf32>
30 func.func @transfer_write_2d(%A : tensor<?x?xf32>, %vec : vector<2x3xf32>,
31 %base1 : index, %base2 : index) -> (tensor<?x?xf32>) {
32 %t = vector.transfer_write %vec, %A[%base1, %base2] {in_bounds = [true, true]}
33 : vector<2x3xf32>, tensor<?x?xf32>
34 return %t : tensor<?x?xf32>