[Mlir-commits] [mlir] edf2442 - [mlir][Linalg] Integration tests for convolutions added.
Jakub Lichman
llvmlistbot at llvm.org
Wed Sep 9 04:38:05 PDT 2020
Author: Jakub Lichman
Date: 2020-09-09T11:37:28Z
New Revision: edf244217a48b91c8e9c860848885106fbcc5c4b
URL: https://github.com/llvm/llvm-project/commit/edf244217a48b91c8e9c860848885106fbcc5c4b
DIFF: https://github.com/llvm/llvm-project/commit/edf244217a48b91c8e9c860848885106fbcc5c4b.diff
LOG: [mlir][Linalg] Integration tests for convolutions added.
This commit introduces end-to-end integration tests for
convolutions that test multiple ways of ConvOps lowering.
Differential Revision: https://reviews.llvm.org/D87277
Added:
mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-ncw-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-nwc-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nchw-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nhwc-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ncdhw-call.mlir
mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ndhwc-call.mlir
Modified:
Removed:
################################################################################
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-call.mlir
new file mode 100644
index 000000000000..1b3ee65f13d9
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-call.mlir
@@ -0,0 +1,65 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=4" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=4" -linalg-tile="linalg-tile-sizes=1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns a 1-D buffer of size %s1 filled with the value %f
+func @alloc_1d_filled_f32(%s1 : index, %f : f32) -> memref<?xf32> {
+ %buf = alloc(%s1) : memref<?xf32>
+ linalg.fill(%buf, %f) : memref<?xf32>, f32
+ return %buf : memref<?xf32>
+}
+
+func @conv_1d(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: memref<?xf32>) {
+ linalg.conv_1d %arg0, %arg1, %arg2 : (memref<?xf32>, memref<?xf32>, memref<?xf32>)
+ return
+}
+
+func @main() {
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter1D = call @alloc_1d_filled_f32(%c3, %val) : (index, f32) -> (memref<?xf32>)
+ %in1D = call @alloc_1d_filled_f32(%c8, %val) : (index, f32) -> (memref<?xf32>)
+ %out1D = call @alloc_1d_filled_f32(%c6, %zero) : (index, f32) -> (memref<?xf32>)
+
+ store %f10, %in1D[%c3] : memref<?xf32>
+ call @conv_1d(%in1D, %filter1D, %out1D) : (memref<?xf32>, memref<?xf32>, memref<?xf32>) -> ()
+ %out1D_ = memref_cast %out1D : memref<?xf32> to memref<*xf32>
+ call @print_memref_f32(%out1D_): (memref<*xf32>) -> ()
+
+ dealloc %filter1D : memref<?xf32>
+ dealloc %in1D : memref<?xf32>
+ dealloc %out1D : memref<?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [12, 28, 28, 28, 12, 12]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-ncw-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-ncw-call.mlir
new file mode 100644
index 000000000000..2647ee3d663c
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-ncw-call.mlir
@@ -0,0 +1,71 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,4" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,4" -linalg-tile="linalg-tile-sizes=1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 3-D buffer of size (%s1, %s2, %s3) filled with the value %f
+func @alloc_3d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %f : f32) -> memref<?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3) : memref<?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?xf32>, f32
+ return %buf : memref<?x?x?xf32>
+}
+
+func @conv_1d_ncw(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {
+ linalg.conv_1d_ncw %arg0, %arg1, %arg2 : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter1D_ncw = call @alloc_3d_filled_f32(%c1, %c1, %c3, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %in1D_ncw = call @alloc_3d_filled_f32(%c1, %c1, %c8, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %out1D_ncw = call @alloc_3d_filled_f32(%c1, %c1, %c6, %zero) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+
+ store %f10, %in1D_ncw[%c0, %c0, %c3] : memref<?x?x?xf32>
+ call @conv_1d_ncw(%in1D_ncw, %filter1D_ncw, %out1D_ncw) : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>) -> ()
+ %out1D_ncw_ = memref_cast %out1D_ncw : memref<?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out1D_ncw_): (memref<*xf32>) -> ()
+
+ dealloc %filter1D_ncw : memref<?x?x?xf32>
+ dealloc %in1D_ncw : memref<?x?x?xf32>
+ dealloc %out1D_ncw : memref<?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [12, 28, 28, 28, 12, 12]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-nwc-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-nwc-call.mlir
new file mode 100644
index 000000000000..5cc4de3844aa
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-1d-nwc-call.mlir
@@ -0,0 +1,82 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,4" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,4" -linalg-tile="linalg-tile-sizes=1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 3-D buffer of size (%s1, %s2, %s3) filled with the value %f
+func @alloc_3d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %f : f32) -> memref<?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3) : memref<?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?xf32>, f32
+ return %buf : memref<?x?x?xf32>
+}
+
+func @conv_1d_nwc(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {
+ linalg.conv_1d_nwc %arg0, %arg1, %arg2 : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter1D_nwc = call @alloc_3d_filled_f32(%c1, %c3, %c1, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %in1D_nwc = call @alloc_3d_filled_f32(%c3, %c8, %c1, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %out1D_nwc = call @alloc_3d_filled_f32(%c3, %c6, %c1, %zero) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+
+ store %f10, %in1D_nwc[%c0, %c3, %c0] : memref<?x?x?xf32>
+ call @conv_1d_nwc(%in1D_nwc, %filter1D_nwc, %out1D_nwc) : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>) -> ()
+ %out1D_nwc_ = memref_cast %out1D_nwc : memref<?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out1D_nwc_): (memref<*xf32>) -> ()
+
+ dealloc %filter1D_nwc : memref<?x?x?xf32>
+ dealloc %in1D_nwc : memref<?x?x?xf32>
+ dealloc %out1D_nwc : memref<?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [12],
+// CHECK-COUNT-3: [28],
+// CHECK-NEXT: [12],
+// CHECK-NEXT: [12]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-5: [12],
+// CHECK-NEXT: [12]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-5: [12],
+// CHECK-NEXT: [12]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-call.mlir
new file mode 100644
index 000000000000..38420974ad98
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-call.mlir
@@ -0,0 +1,70 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,2" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,2" -linalg-tile="linalg-tile-sizes=1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns a 2-D buffer of size (%s1, %s2) filled with the value %f
+func @alloc_2d_filled_f32(%s1 : index, %s2 : index, %f : f32) -> memref<?x?xf32> {
+ %buf = alloc(%s1, %s2) : memref<?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?xf32>, f32
+ return %buf : memref<?x?xf32>
+}
+
+func @conv_2d(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {
+ linalg.conv_2d %arg0, %arg1, %arg2 : (memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter2D = call @alloc_2d_filled_f32(%c3, %c3, %val) : (index, index, f32) -> (memref<?x?xf32>)
+ %in2D = call @alloc_2d_filled_f32(%c8, %c8, %val) : (index, index, f32) -> (memref<?x?xf32>)
+ %out2D = call @alloc_2d_filled_f32(%c6, %c6, %zero) : (index, index, f32) -> (memref<?x?xf32>)
+
+ store %f10, %in2D[%c0, %c3] : memref<?x?xf32>
+ call @conv_2d(%in2D, %filter2D, %out2D) : (memref<?x?xf32>, memref<?x?xf32>, memref<?x?xf32>) -> ()
+ %out2D_ = memref_cast %out2D : memref<?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out2D_): (memref<*xf32>) -> ()
+
+ dealloc %filter2D : memref<?x?xf32>
+ dealloc %in2D : memref<?x?xf32>
+ dealloc %out2D : memref<?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [36, 52, 52, 52, 36, 36],
+// CHECK-COUNT-5: [36, 36, 36, 36, 36, 36]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nchw-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nchw-call.mlir
new file mode 100644
index 000000000000..fbd831f6801a
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nchw-call.mlir
@@ -0,0 +1,84 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,0,4,4" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,0,4,4" -linalg-tile="linalg-tile-sizes=1,1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 4-D buffer of size (%s1, %s2, %s3, %s4) filled with the value %f
+func @alloc_4d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %f : f32) -> memref<?x?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3, %s4) : memref<?x?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?x?xf32>, f32
+ return %buf : memref<?x?x?x?xf32>
+}
+
+func @conv_2d_nchw(%arg0: memref<?x?x?x?xf32>, %arg1: memref<?x?x?x?xf32>, %arg2: memref<?x?x?x?xf32>) {
+ linalg.conv_2d_nchw %arg0, %arg1, %arg2 : (memref<?x?x?x?xf32>, memref<?x?x?x?xf32>, memref<?x?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter2D_nchw = call @alloc_4d_filled_f32(%c1, %c1, %c3, %c3, %val) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+ %in2D_nchw = call @alloc_4d_filled_f32(%c3, %c1, %c8, %c8, %val) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+ %out2D_nchw = call @alloc_4d_filled_f32(%c3, %c1, %c6, %c6, %zero) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+
+ store %f10, %in2D_nchw[%c0, %c0, %c0, %c3] : memref<?x?x?x?xf32>
+ call @conv_2d_nchw(%in2D_nchw, %filter2D_nchw, %out2D_nchw) : (memref<?x?x?x?xf32>, memref<?x?x?x?xf32>, memref<?x?x?x?xf32>) -> ()
+ %out2D_nchw_ = memref_cast %out2D_nchw : memref<?x?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out2D_nchw_): (memref<*xf32>) -> ()
+
+ dealloc %filter2D_nchw : memref<?x?x?x?xf32>
+ dealloc %in2D_nchw : memref<?x?x?x?xf32>
+ dealloc %out2D_nchw : memref<?x?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [36, 52, 52, 52, 36, 36],
+// CHECK-COUNT-5: [36, 36, 36, 36, 36, 36]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [36, 36, 36, 36, 36, 36]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [36, 36, 36, 36, 36, 36]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nhwc-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nhwc-call.mlir
new file mode 100644
index 000000000000..422720da429e
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-2d-nhwc-call.mlir
@@ -0,0 +1,130 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,3,3,2" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,3,3,2" -linalg-tile="linalg-tile-sizes=1,1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 4-D buffer of size (%s1, %s2, %s3, %s4) filled with the value %f
+func @alloc_4d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %f : f32) -> memref<?x?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3, %s4) : memref<?x?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?x?xf32>, f32
+ return %buf : memref<?x?x?x?xf32>
+}
+
+func @conv_2d_nhwc(%arg0: memref<?x?x?x?xf32>, %arg1: memref<?x?x?x?xf32>, %arg2: memref<?x?x?x?xf32>) {
+ linalg.conv_2d_nhwc %arg0, %arg1, %arg2 : (memref<?x?x?x?xf32>, memref<?x?x?x?xf32>, memref<?x?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter2D_nhwc = call @alloc_4d_filled_f32(%c1, %c3, %c3, %c3, %val) :(index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+ %in2D_nhwc = call @alloc_4d_filled_f32(%c3, %c8, %c8, %c3, %val) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+ %out2D_nhwc = call @alloc_4d_filled_f32(%c3, %c6, %c6, %c1, %zero) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>)
+
+ store %f10, %in2D_nhwc[%c0, %c0, %c3, %c0] : memref<?x?x?x?xf32>
+ call @conv_2d_nhwc(%in2D_nhwc, %filter2D_nhwc, %out2D_nhwc) : (memref<?x?x?x?xf32>, memref<?x?x?x?xf32>, memref<?x?x?x?xf32>) -> ()
+ %out2D_nhwc_ = memref_cast %out2D_nhwc : memref<?x?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out2D_nhwc_): (memref<*xf32>) -> ()
+
+ dealloc %filter2D_nhwc : memref<?x?x?x?xf32>
+ dealloc %in2D_nhwc : memref<?x?x?x?xf32>
+ dealloc %out2D_nhwc : memref<?x?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [108],
+// CHECK-COUNT-3: [124],
+// CHECK-COUNT-2: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-call.mlir
new file mode 100644
index 000000000000..8f38962acf8b
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-call.mlir
@@ -0,0 +1,87 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,2,2" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,2,2" -linalg-tile="linalg-tile-sizes=1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 3-D buffer of size (%s1, %s2, %s3) filled with the value %f
+func @alloc_3d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %f : f32) -> memref<?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3) : memref<?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?xf32>, f32
+ return %buf : memref<?x?x?xf32>
+}
+
+func @conv_3d(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {
+ linalg.conv_3d %arg0, %arg1, %arg2 : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter3D = call @alloc_3d_filled_f32(%c3, %c3, %c3, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %in3D = call @alloc_3d_filled_f32(%c8, %c8, %c8, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+ %out3D = call @alloc_3d_filled_f32(%c6, %c6, %c6, %zero) : (index, index, index, f32) -> (memref<?x?x?xf32>)
+
+ store %f10, %in3D[%c0, %c0, %c3] : memref<?x?x?xf32>
+ call @conv_3d(%in3D, %filter3D, %out3D) : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>) -> ()
+ %out3D_ = memref_cast %out3D : memref<?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out3D_): (memref<*xf32>) -> ()
+
+ dealloc %filter3D : memref<?x?x?xf32>
+ dealloc %in3D : memref<?x?x?xf32>
+ dealloc %out3D : memref<?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [108, 124, 124, 124, 108, 108],
+// CHECK-COUNT-5: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ncdhw-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ncdhw-call.mlir
new file mode 100644
index 000000000000..2ad2b4fc3465
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ncdhw-call.mlir
@@ -0,0 +1,91 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,5,5,5" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,5,5,5" -linalg-tile="linalg-tile-sizes=1,1,1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 5-D buffer of size (%s1, %s2, %s3, %s4, %s5) filled with the value %f
+func @alloc_5d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %s5 : index, %f : f32) -> memref<?x?x?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3, %s4, %s5) : memref<?x?x?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?x?x?xf32>, f32
+ return %buf : memref<?x?x?x?x?xf32>
+}
+
+func @conv_3d_ncdhw(%arg0: memref<?x?x?x?x?xf32>, %arg1: memref<?x?x?x?x?xf32>, %arg2: memref<?x?x?x?x?xf32>) {
+ linalg.conv_3d_ncdhw %arg0, %arg1, %arg2 : (memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)
+ return
+}
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %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>)
+ %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>)
+ %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>)
+
+ store %f10, %in3D_ncdhw[%c0, %c0, %c0, %c0, %c3] : memref<?x?x?x?x?xf32>
+ 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>) -> ()
+ %out3D_ncdhw_ = memref_cast %out3D_ncdhw : memref<?x?x?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out3D_ncdhw_): (memref<*xf32>) -> ()
+
+ dealloc %filter3D_ncdhw : memref<?x?x?x?x?xf32>
+ dealloc %in3D_ncdhw : memref<?x?x?x?x?xf32>
+ dealloc %out3D_ncdhw : memref<?x?x?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [108, 124, 124, 124, 108, 108],
+// CHECK-COUNT-5: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
diff --git a/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ndhwc-call.mlir b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ndhwc-call.mlir
new file mode 100644
index 000000000000..4f1392363bb2
--- /dev/null
+++ b/mlir/integration_test/Dialect/Linalg/Conv/test-conv-3d-ndhwc-call.mlir
@@ -0,0 +1,193 @@
+// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,5,5,5" -convert-linalg-to-loops \
+// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=1,1,1,1,1" -test-conv-vectorization \
+// RUN: -convert-linalg-to-loops -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,5,5,5" -linalg-tile="linalg-tile-sizes=1,1,1,1,1" \
+// RUN: -test-conv-vectorization -convert-linalg-to-loops \
+// RUN: -test-vector-contraction-conversion=vector-outerproduct=0 \
+// RUN: -convert-vector-to-scf -convert-linalg-to-llvm | \
+// RUN: mlir-cpu-runner -e main -entry-point-result=void \
+// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
+// RUN: | FileCheck %s
+
+func @print_memref_f32(memref<*xf32>)
+
+// Creates and returns 5-D buffer of size (%s1, %s2, %s3, %s4, %s5) filled with the value %f
+func @alloc_5d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %s5 : index, %f : f32) -> memref<?x?x?x?x?xf32> {
+ %buf = alloc(%s1, %s2, %s3, %s4, %s5) : memref<?x?x?x?x?xf32>
+ linalg.fill(%buf, %f) : memref<?x?x?x?x?xf32>, f32
+ return %buf : memref<?x?x?x?x?xf32>
+}
+
+func @conv_3d_ndhwc(%arg0: memref<?x?x?x?x?xf32>, %arg1: memref<?x?x?x?x?xf32>, %arg2: memref<?x?x?x?x?xf32>) {
+ linalg.conv_3d_ndhwc %arg0, %arg1, %arg2 : (memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)
+ return
+}
+
+
+func @main() {
+ %c0 = constant 0 : index
+ %c1 = constant 1 : index
+ %c3 = constant 3 : index
+ %c6 = constant 6 : index
+ %c8 = constant 8 : index
+ %f10 = constant 10.00000e+00 : f32
+ %val = constant 2.00000e+00 : f32
+ %zero = constant 0.00000e+00 : f32
+
+ %filter3D_ndhwc = call @alloc_5d_filled_f32(%c1, %c3, %c3, %c3, %c1, %val) : (index, index, index, index, index, f32) -> (memref<?x?x?x?x?xf32>)
+ %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>)
+ %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>)
+
+ store %f10, %in3D_ndhwc[%c0, %c0, %c0, %c3, %c0] : memref<?x?x?x?x?xf32>
+ call @conv_3d_ndhwc(%in3D_ndhwc, %filter3D_ndhwc, %out3D_ndhwc) : (memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>) -> ()
+ %out3D_ndhwc_ = memref_cast %out3D_ndhwc : memref<?x?x?x?x?xf32> to memref<*xf32>
+ call @print_memref_f32(%out3D_ndhwc_): (memref<*xf32>) -> ()
+
+ dealloc %filter3D_ndhwc : memref<?x?x?x?x?xf32>
+ dealloc %in3D_ndhwc : memref<?x?x?x?x?xf32>
+ dealloc %out3D_ndhwc : memref<?x?x?x?x?xf32>
+ return
+}
+
+// CHECK: Unranked Memref {{.*}}
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [
+// CHECK-SAME: [108],
+// CHECK-COUNT-3: [124],
+// CHECK-COUNT-2: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-SAME: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ],
+// CHECK-NEXT: [
+// CHECK-COUNT-6: [108]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
+// CHECK-SAME: ]
More information about the Mlir-commits
mailing list