1 // RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -lower-affine -convert-scf-to-std --convert-memref-to-llvm -convert-std-to-llvm -reconcile-unrealized-casts | \
2 // RUN: mlir-cpu-runner -e main -entry-point-result=void \
3 // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
6 // RUN: mlir-opt %s -linalg-tile="tile-sizes=0,5,5,5" -convert-linalg-to-loops -convert-scf-to-std \
7 // RUN: -convert-linalg-to-llvm -lower-affine -convert-scf-to-std --convert-memref-to-llvm -convert-std-to-llvm -reconcile-unrealized-casts | \
8 // RUN: mlir-cpu-runner -e main -entry-point-result=void \
9 // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
10 // RUN: | FileCheck %s
12 func private @print_memref_f32(memref<*xf32>)
14 // Creates and returns 5-D buffer of size (%s1, %s2, %s3, %s4, %s5) filled with the value %f
15 func @alloc_5d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %s5 : index, %f : f32) -> memref<?x?x?x?x?xf32> {
16 %buf = memref.alloc(%s1, %s2, %s3, %s4, %s5) : memref<?x?x?x?x?xf32>
17 linalg.fill(%f, %buf) : f32, memref<?x?x?x?x?xf32>
18 return %buf : memref<?x?x?x?x?xf32>
21 func @conv_3d_ndhwc_dhwcf(%arg0: memref<?x?x?x?x?xf32>, %arg1: memref<?x?x?x?x?xf32>, %arg2: memref<?x?x?x?x?xf32>) {
22 linalg.conv_3d_ndhwc_dhwcf {dilations = dense<1> : tensor<3xi64>,
23 strides = dense<1> : tensor<3xi64>}
24 ins (%arg0, %arg1: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)
25 outs (%arg2: memref<?x?x?x?x?xf32>)
31 %c0 = arith.constant 0 : index
32 %c1 = arith.constant 1 : index
33 %c3 = arith.constant 3 : index
34 %c6 = arith.constant 6 : index
35 %c8 = arith.constant 8 : index
36 %f10 = arith.constant 10.00000e+00 : f32
37 %val = arith.constant 2.00000e+00 : f32
38 %zero = arith.constant 0.00000e+00 : f32
40 %filter3D_ndhwc = call @alloc_5d_filled_f32(%c3, %c3, %c3, %c1, %c1, %val) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
41 %in3D_ndhwc = call @alloc_5d_filled_f32(%c1, %c8, %c8, %c8, %c1, %val) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
42 %out3D_ndhwc = call @alloc_5d_filled_f32(%c1, %c6, %c6, %c6, %c1, %zero) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
44 memref.store %f10, %in3D_ndhwc[%c0, %c0, %c0, %c3, %c0] : memref<?x?x?x?x?xf32>
45 call @conv_3d_ndhwc_dhwcf(%in3D_ndhwc, %filter3D_ndhwc, %out3D_ndhwc) : (memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>) -> ()
46 %out3D_ndhwc_ = memref.cast %out3D_ndhwc : memref<?x?x?x?x?xf32> to memref<*xf32>
47 call @print_memref_f32(%out3D_ndhwc_): (memref<*xf32>) -> ()
49 memref.dealloc %filter3D_ndhwc : memref<?x?x?x?x?xf32>
50 memref.dealloc %in3D_ndhwc : memref<?x?x?x?x?xf32>
51 memref.dealloc %out3D_ndhwc : memref<?x?x?x?x?xf32>
55 // CHECK: Unranked Memref {{.*}}
61 // CHECK-COUNT-3: [124],
62 // CHECK-COUNT-2: [108]
65 // CHECK-COUNT-6: [108]
68 // CHECK-COUNT-6: [108]
71 // CHECK-COUNT-6: [108]
74 // CHECK-COUNT-6: [108]
77 // CHECK-COUNT-6: [108]
82 // CHECK-COUNT-6: [108]
85 // CHECK-COUNT-6: [108]
88 // CHECK-COUNT-6: [108]
91 // CHECK-COUNT-6: [108]
94 // CHECK-COUNT-6: [108]
97 // CHECK-COUNT-6: [108]
102 // CHECK-COUNT-6: [108]
105 // CHECK-COUNT-6: [108]
108 // CHECK-COUNT-6: [108]
111 // CHECK-COUNT-6: [108]
114 // CHECK-COUNT-6: [108]
117 // CHECK-COUNT-6: [108]
122 // CHECK-COUNT-6: [108]
125 // CHECK-COUNT-6: [108]
128 // CHECK-COUNT-6: [108]
131 // CHECK-COUNT-6: [108]
134 // CHECK-COUNT-6: [108]
137 // CHECK-COUNT-6: [108]
142 // CHECK-COUNT-6: [108]
145 // CHECK-COUNT-6: [108]
148 // CHECK-COUNT-6: [108]
151 // CHECK-COUNT-6: [108]
154 // CHECK-COUNT-6: [108]
157 // CHECK-COUNT-6: [108]
162 // CHECK-COUNT-6: [108]
165 // CHECK-COUNT-6: [108]
168 // CHECK-COUNT-6: [108]
171 // CHECK-COUNT-6: [108]
174 // CHECK-COUNT-6: [108]
177 // CHECK-COUNT-6: [108]