1// RUN: mlir-opt %s --one-shot-bufferize="dialect-filter=vector,bufferization copy-before-write unknown-type-conversion=identity-layout-map" -split-input-file | FileCheck %s 2 3// CHECK-LABEL: func @transfer_read( 4// CHECK-SAME: %[[t:.*]]: tensor<?x?xf32>, %[[o1:.*]]: index, %[[o2:.*]]: index, %[[pad:.*]]: f32) 5// CHECK: %[[m:.*]] = bufferization.to_memref %[[t]] : tensor<?x?xf32> to memref<?x?xf32> 6// CHECK: %[[r:.*]] = vector.transfer_read %[[m]][%[[o1]], %[[o2]]], %[[pad]] {in_bounds = [true, false]} : memref<?x?xf32>, vector<5x6xf32> 7// CHECK: return %[[r]] 8func.func @transfer_read(%t: tensor<?x?xf32>, %o1: index, 9 %o2: index, %pad: f32) -> vector<5x6xf32> { 10 %0 = vector.transfer_read %t[%o1, %o2], %pad {in_bounds = [true, false]} 11 : tensor<?x?xf32>, vector<5x6xf32> 12 return %0 : vector<5x6xf32> 13} 14 15// ----- 16 17// CHECK-LABEL: func @transfer_write( 18// CHECK-SAME: %[[t:.*]]: tensor<?x?xf32>, %[[o1:.*]]: index, %[[o2:.*]]: index, %[[vec:.*]]: vector<5x6xf32>, %[[mask:.*]]: vector<5x6xi1>) 19// CHECK: %[[m:.*]] = bufferization.to_memref %[[t]] : tensor<?x?xf32> to memref<?x?xf32> 20// CHECK: %[[alloc:.*]] = memref.alloc(%{{.*}}, %{{.*}}) {{.*}} : memref<?x?xf32> 21// CHECK: memref.copy %[[m]], %[[alloc]] 22// CHECK: vector.transfer_write %[[vec]], %[[alloc]][%[[o1]], %[[o2]]], %[[mask]] {in_bounds = [true, false]} : vector<5x6xf32>, memref<?x?xf32> 23// CHECK: %[[r:.*]] = bufferization.to_tensor %[[alloc]] : memref<?x?xf32> 24// CHECK: return %[[r]] 25func.func @transfer_write(%t: tensor<?x?xf32>, %o1: index, 26 %o2: index, %vec: vector<5x6xf32>, 27 %mask: vector<5x6xi1>) -> tensor<?x?xf32> { 28 %0 = vector.transfer_write %vec, %t[%o1, %o2], %mask {in_bounds = [true, false]} 29 : vector<5x6xf32>, tensor<?x?xf32> 30 return %0 : tensor<?x?xf32> 31} 32 33// ----- 34 35// CHECK-LABEL: func @gather( 36// CHECK-SAME: %[[base:.*]]: tensor<?x?xf32>, %[[v:.*]]: vector<16xi32>, 37// CHECK-SAME: %[[mask:.*]]: vector<16xi1>, %[[pass_thru:.*]]: vector<16xf32>) 38// CHECK: %[[m:.*]] = bufferization.to_memref %[[base]] : tensor<?x?xf32> to memref<?x?xf32> 39// CHECK: %[[c0:.*]] = arith.constant 0 : index 40// CHECK: %[[out:.*]] = vector.gather %[[m]][%[[c0]], %[[c0]]] [%[[v]]], %[[mask]], %[[pass_thru]] : memref<?x?xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32> 41func.func @gather(%base: tensor<?x?xf32>, %v: vector<16xi32>, %mask: vector<16xi1>, %pass_thru: vector<16xf32>) -> vector<16xf32> { 42 %c0 = arith.constant 0 : index 43 %0 = vector.gather %base[%c0, %c0][%v], %mask, %pass_thru : tensor<?x?xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32> 44 return %0 : vector<16xf32> 45} 46 47// TODO: Add test case for vector.mask. The masked op can currently not 48// bufferize out-of-place, so the only test case is in one-shot-bufferize.mlir. 49