1// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
2// RUN: mlir-cpu-runner -e main -entry-point-result=void \
3// RUN:   -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
4// RUN: | FileCheck %s
5
6// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,5,5,5" -convert-linalg-to-loops \
7// RUN:   -convert-linalg-to-llvm -convert-std-to-llvm | \
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
11
12// RUN: mlir-opt %s -test-conv-vectorization="tile-sizes=1,1,1,1,1,3,3,3,3" -convert-linalg-to-llvm | \
13// RUN: mlir-cpu-runner -e main -entry-point-result=void \
14// RUN:   -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
15// RUN: | FileCheck %s
16
17// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,5,5,5" \
18// RUN:   -test-conv-vectorization="tile-sizes=1,1,1,1,1,3,3,3,3" -convert-linalg-to-llvm | \
19// RUN: mlir-cpu-runner -e main -entry-point-result=void \
20// RUN:   -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
21// RUN: | FileCheck %s
22
23func private @print_memref_f32(memref<*xf32>)
24
25// Creates and returns 5-D buffer of size (%s1, %s2, %s3, %s4, %s5) filled with the value %f
26func @alloc_5d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %s5 : index, %f : f32) -> memref<?x?x?x?x?xf32> {
27  %buf = alloc(%s1, %s2, %s3, %s4, %s5) : memref<?x?x?x?x?xf32>
28  linalg.fill(%buf, %f) : memref<?x?x?x?x?xf32>, f32
29  return %buf : memref<?x?x?x?x?xf32>
30}
31
32func @conv_3d_ncdhw(%arg0: memref<?x?x?x?x?xf32>, %arg1: memref<?x?x?x?x?xf32>, %arg2: memref<?x?x?x?x?xf32>) {
33  linalg.conv_3d_ncdhw ins (%arg0, %arg1: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)
34                      outs (%arg2: memref<?x?x?x?x?xf32>)
35  return
36}
37
38func @main() {
39  %c0 = constant 0 : index
40  %c1 = constant 1 : index
41  %c3 = constant 3 : index
42  %c6 = constant 6 : index
43  %c8 = constant 8 : index
44  %f10 = constant 10.00000e+00 : f32
45  %val = constant 2.00000e+00 : f32
46  %zero = constant 0.00000e+00 : f32
47
48  %filter3D_ncdhw = call @alloc_5d_filled_f32(%c1, %c1, %c3, %c3, %c3, %val) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
49  %in3D_ncdhw = call @alloc_5d_filled_f32(%c1, %c1, %c8, %c8, %c8, %val) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
50  %out3D_ncdhw = call @alloc_5d_filled_f32(%c1, %c1, %c6, %c6, %c6, %zero) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
51
52  store %f10, %in3D_ncdhw[%c0, %c0, %c0, %c0, %c3] : memref<?x?x?x?x?xf32>
53  call @conv_3d_ncdhw(%in3D_ncdhw, %filter3D_ncdhw, %out3D_ncdhw) : (memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>) -> ()
54  %out3D_ncdhw_ = memref_cast %out3D_ncdhw : memref<?x?x?x?x?xf32> to memref<*xf32>
55  call @print_memref_f32(%out3D_ncdhw_): (memref<*xf32>) -> ()
56
57  dealloc %filter3D_ncdhw : memref<?x?x?x?x?xf32>
58  dealloc %in3D_ncdhw : memref<?x?x?x?x?xf32>
59  dealloc %out3D_ncdhw : memref<?x?x?x?x?xf32>
60  return
61}
62
63// CHECK:       Unranked Memref {{.*}}
64// CHECK-NEXT:  [
65// CHECK-SAME:   [
66// CHECK-SAME:    [
67// CHECK-SAME:     [
68// CHECK-SAME:      [108,      124,      124,      124,      108,      108],
69// CHECK-COUNT-5:   [108,      108,      108,      108,      108,      108]
70// CHECK-SAME:     ],
71// CHECK-NEXT:     [
72// CHECK-COUNT-6:   [108,      108,      108,      108,      108,      108]
73// CHECK-SAME:     ],
74// CHECK-NEXT:     [
75// CHECK-COUNT-6:   [108,      108,      108,      108,      108,      108]
76// CHECK-SAME:     ],
77// CHECK-NEXT:     [
78// CHECK-COUNT-6:   [108,      108,      108,      108,      108,      108]
79// CHECK-SAME:     ],
80// CHECK-NEXT:     [
81// CHECK-COUNT-6:   [108,      108,      108,      108,      108,      108]
82// CHECK-SAME:     ],
83// CHECK-NEXT:     [
84// CHECK-COUNT-6:   [108,      108,      108,      108,      108,      108]
85// CHECK-SAME:     ]
86// CHECK-SAME:    ]
87// CHECK-SAME:   ]
88// CHECK-SAME:  ]
89