1// RUN: mlir-opt %s -test-memref-stride-calculation -o /dev/null | FileCheck %s 2 3func @f(%0: index) { 4// CHECK-LABEL: Testing: f 5 %1 = memref.alloc() : memref<3x4x5xf32> 6// CHECK: MemRefType offset: 0 strides: 20, 5, 1 7 %2 = memref.alloc(%0) : memref<3x4x?xf32> 8// CHECK: MemRefType offset: 0 strides: ?, ?, 1 9 %3 = memref.alloc(%0) : memref<3x?x5xf32> 10// CHECK: MemRefType offset: 0 strides: ?, 5, 1 11 %4 = memref.alloc(%0) : memref<?x4x5xf32> 12// CHECK: MemRefType offset: 0 strides: 20, 5, 1 13 %5 = memref.alloc(%0, %0) : memref<?x4x?xf32> 14// CHECK: MemRefType offset: 0 strides: ?, ?, 1 15 %6 = memref.alloc(%0, %0, %0) : memref<?x?x?xf32> 16// CHECK: MemRefType offset: 0 strides: ?, ?, 1 17 18 %11 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i, j, k)>> 19// CHECK: MemRefType offset: 0 strides: 20, 5, 1 20 %b11 = memref.alloc() : memref<3x4x5xf32, offset: 0, strides: [20, 5, 1]> 21// CHECK: MemRefType offset: 0 strides: 20, 5, 1 22 %12 = memref.alloc(%0) : memref<3x4x?xf32, affine_map<(i, j, k)->(i, j, k)>> 23// CHECK: MemRefType offset: 0 strides: ?, ?, 1 24 %13 = memref.alloc(%0) : memref<3x?x5xf32, affine_map<(i, j, k)->(i, j, k)>> 25// CHECK: MemRefType offset: 0 strides: ?, 5, 1 26 %14 = memref.alloc(%0) : memref<?x4x5xf32, affine_map<(i, j, k)->(i, j, k)>> 27// CHECK: MemRefType offset: 0 strides: 20, 5, 1 28 %15 = memref.alloc(%0, %0) : memref<?x4x?xf32, affine_map<(i, j, k)->(i, j, k)>> 29// CHECK: MemRefType offset: 0 strides: ?, ?, 1 30 %16 = memref.alloc(%0, %0, %0) : memref<?x?x?xf32, affine_map<(i, j, k)->(i, j, k)>> 31// CHECK: MemRefType offset: 0 strides: ?, ?, 1 32 33 %21 = memref.alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + 16 * j + M * k + 1)>> 34// CHECK: MemRefType offset: 1 strides: 32, 16, ? 35 %22 = memref.alloc()[%0] : memref<3x4x5xf32, affine_map<(i, j, k)[M]->(32 * i + M * j + 16 * k + 3)>> 36// CHECK: MemRefType offset: 3 strides: 32, ?, 16 37 %b22 = memref.alloc(%0)[%0, %0] : memref<3x4x?xf32, offset: 0, strides: [?, ?, 1]> 38// CHECK: MemRefType offset: 0 strides: ?, ?, 1 39 %23 = memref.alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + 7)>> 40// CHECK: MemRefType offset: 7 strides: ?, 32, 16 41 %b23 = memref.alloc(%0)[%0] : memref<3x?x5xf32, offset: 0, strides: [?, 5, 1]> 42// CHECK: MemRefType offset: 0 strides: ?, 5, 1 43 %24 = memref.alloc(%0)[%0] : memref<3x?x5xf32, affine_map<(i, j, k)[M]->(M * i + 32 * j + 16 * k + M)>> 44// CHECK: MemRefType offset: ? strides: ?, 32, 16 45 %b24 = memref.alloc(%0)[%0, %0] : memref<3x?x5xf32, offset: ?, strides: [?, 32, 16]> 46// CHECK: MemRefType offset: ? strides: ?, 32, 16 47 %25 = memref.alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>> 48// CHECK: MemRefType offset: 1 strides: ?, ?, 1 49 %b25 = memref.alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, offset: 1, strides: [?, ?, 1]> 50// CHECK: MemRefType offset: 1 strides: ?, ?, 1 51 %26 = memref.alloc(%0)[] : memref<?xf32, affine_map<(i)[M]->(i)>> 52// CHECK: MemRefType offset: 0 strides: 1 53 %27 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(M)>> 54// CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (s0)>> cannot be converted to strided form 55 %28 = memref.alloc()[%0] : memref<5xf32, affine_map<(i)[M]->(123)>> 56// CHECK: MemRefType memref<5xf32, affine_map<(d0)[s0] -> (123)>> cannot be converted to strided form 57 %29 = memref.alloc()[%0] : memref<f32, affine_map<()[M]->(M)>> 58// CHECK: MemRefType offset: ? strides: 59 %30 = memref.alloc()[%0] : memref<f32, affine_map<()[M]->(123)>> 60// CHECK: MemRefType offset: 123 strides: 61 62 %100 = memref.alloc(%0, %0)[%0, %0] : memref<?x?x16xf32, affine_map<(i, j, k)[M, N]->(i + j, j, k)>, affine_map<(i, j, k)[M, N]->(M * i + N * j + k + 1)>> 63 // CHECK: MemRefType offset: 1 strides: ?, ?, 1 64 65 %101 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i floordiv 4 + j + k)>> 66// CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 floordiv 4 + d1 + d2)>> cannot be converted to strided form 67 %102 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i ceildiv 4 + j + k)>> 68// CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 ceildiv 4 + d1 + d2)>> cannot be converted to strided form 69 %103 = memref.alloc() : memref<3x4x5xf32, affine_map<(i, j, k)->(i mod 4 + j + k)>> 70// CHECK: MemRefType memref<3x4x5xf32, affine_map<(d0, d1, d2) -> (d0 mod 4 + d1 + d2)>> cannot be converted to strided form 71 72 %200 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * j + K * k - (M + N - 20)* i)>> 73 // CHECK: MemRefType offset: 0 strides: 20, ?, ? 74 %201 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * i + N * i + N * K * j + K * K * k - (M + N - 20) * (i + 1))>> 75 // CHECK: MemRefType offset: ? strides: 20, ?, ? 76 %202 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M * (i + 1) + j + k - M)>> 77 // CHECK: MemRefType offset: 0 strides: ?, 1, 1 78 %203 = memref.alloc()[%0, %0, %0] : memref<3x4x5xf32, affine_map<(i, j, k)[M, N, K]->(M + M * (i + N * (j + K * k)))>> 79 // CHECK: MemRefType offset: ? strides: ?, ?, ? 80 81 return 82} 83