2021-02-04 18:53:10 +08:00
|
|
|
// RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -convert-std-to-llvm | mlir-cpu-runner -e print_0d -entry-point-result=void -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext | FileCheck %s --check-prefix=PRINT-0D
|
|
|
|
// RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -convert-std-to-llvm | mlir-cpu-runner -e print_1d -entry-point-result=void -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext | FileCheck %s --check-prefix=PRINT-1D
|
|
|
|
// RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -convert-std-to-llvm | mlir-cpu-runner -e print_3d -entry-point-result=void -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext | FileCheck %s --check-prefix=PRINT-3D
|
|
|
|
// RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -convert-std-to-llvm | mlir-cpu-runner -e vector_splat_2d -entry-point-result=void -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext | FileCheck %s --check-prefix=PRINT-VECTOR-SPLAT-2D
|
2019-10-08 00:06:08 +08:00
|
|
|
|
|
|
|
func @print_0d() {
|
|
|
|
%f = constant 2.00000e+00 : f32
|
2021-02-18 19:49:52 +08:00
|
|
|
%A = alloc() : memref<f32>
|
|
|
|
store %f, %A[]: memref<f32>
|
|
|
|
%U = memref_cast %A : memref<f32> to memref<*xf32>
|
2019-12-06 05:12:50 +08:00
|
|
|
call @print_memref_f32(%U): (memref<*xf32>) -> ()
|
2021-02-18 19:49:52 +08:00
|
|
|
dealloc %A : memref<f32>
|
2019-10-08 00:06:08 +08:00
|
|
|
return
|
|
|
|
}
|
[MLIR] Helper class referencing MemRefType to unify runner implementations.
Summary:
Add DynamicMemRefType which can reference one of the statically ranked StridedMemRefType or a UnrankedMemRefType so that runner utils only need to be implemented once.
There is definitely room for more clean up and unification, but I will keep that for follow-ups.
Reviewers: nicolasvasilache
Reviewed By: nicolasvasilache
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80513
2020-05-25 18:05:57 +08:00
|
|
|
// PRINT-0D: Unranked Memref base@ = {{.*}} rank = 0 offset = 0 sizes = [] strides = [] data =
|
2019-12-12 23:32:36 +08:00
|
|
|
// PRINT-0D: [2]
|
2019-10-08 00:06:08 +08:00
|
|
|
|
|
|
|
func @print_1d() {
|
|
|
|
%f = constant 2.00000e+00 : f32
|
2021-02-18 19:49:52 +08:00
|
|
|
%A = alloc() : memref<16xf32>
|
|
|
|
%B = memref_cast %A: memref<16xf32> to memref<?xf32>
|
2019-10-08 00:06:08 +08:00
|
|
|
linalg.fill(%B, %f) : memref<?xf32>, f32
|
2021-02-18 19:49:52 +08:00
|
|
|
%U = memref_cast %B : memref<?xf32> to memref<*xf32>
|
2019-12-06 05:12:50 +08:00
|
|
|
call @print_memref_f32(%U): (memref<*xf32>) -> ()
|
2021-02-18 19:49:52 +08:00
|
|
|
dealloc %A : memref<16xf32>
|
2019-10-08 00:06:08 +08:00
|
|
|
return
|
|
|
|
}
|
[MLIR] Helper class referencing MemRefType to unify runner implementations.
Summary:
Add DynamicMemRefType which can reference one of the statically ranked StridedMemRefType or a UnrankedMemRefType so that runner utils only need to be implemented once.
There is definitely room for more clean up and unification, but I will keep that for follow-ups.
Reviewers: nicolasvasilache
Reviewed By: nicolasvasilache
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80513
2020-05-25 18:05:57 +08:00
|
|
|
// PRINT-1D: Unranked Memref base@ = {{.*}} rank = 1 offset = 0 sizes = [16] strides = [1] data =
|
2019-11-20 03:51:53 +08:00
|
|
|
// PRINT-1D-NEXT: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
|
2019-10-08 00:06:08 +08:00
|
|
|
|
|
|
|
func @print_3d() {
|
|
|
|
%f = constant 2.00000e+00 : f32
|
|
|
|
%f4 = constant 4.00000e+00 : f32
|
2021-02-18 19:49:52 +08:00
|
|
|
%A = alloc() : memref<3x4x5xf32>
|
|
|
|
%B = memref_cast %A: memref<3x4x5xf32> to memref<?x?x?xf32>
|
2019-10-08 00:06:08 +08:00
|
|
|
linalg.fill(%B, %f) : memref<?x?x?xf32>, f32
|
|
|
|
|
|
|
|
%c2 = constant 2 : index
|
2021-02-18 19:49:52 +08:00
|
|
|
store %f4, %B[%c2, %c2, %c2]: memref<?x?x?xf32>
|
|
|
|
%U = memref_cast %B : memref<?x?x?xf32> to memref<*xf32>
|
2019-12-06 05:12:50 +08:00
|
|
|
call @print_memref_f32(%U): (memref<*xf32>) -> ()
|
2021-02-18 19:49:52 +08:00
|
|
|
dealloc %A : memref<3x4x5xf32>
|
2019-10-08 00:06:08 +08:00
|
|
|
return
|
|
|
|
}
|
[MLIR] Helper class referencing MemRefType to unify runner implementations.
Summary:
Add DynamicMemRefType which can reference one of the statically ranked StridedMemRefType or a UnrankedMemRefType so that runner utils only need to be implemented once.
There is definitely room for more clean up and unification, but I will keep that for follow-ups.
Reviewers: nicolasvasilache
Reviewed By: nicolasvasilache
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80513
2020-05-25 18:05:57 +08:00
|
|
|
// PRINT-3D: Unranked Memref base@ = {{.*}} rank = 3 offset = 0 sizes = [3, 4, 5] strides = [20, 5, 1] data =
|
2019-10-08 00:06:08 +08:00
|
|
|
// PRINT-3D-COUNT-4: {{.*[[:space:]].*}}2, 2, 2, 2, 2
|
|
|
|
// PRINT-3D-COUNT-4: {{.*[[:space:]].*}}2, 2, 2, 2, 2
|
|
|
|
// PRINT-3D-COUNT-2: {{.*[[:space:]].*}}2, 2, 2, 2, 2
|
|
|
|
// PRINT-3D-NEXT: 2, 2, 4, 2, 2
|
|
|
|
// PRINT-3D-NEXT: 2, 2, 2, 2, 2
|
2019-10-15 21:52:24 +08:00
|
|
|
|
2020-11-14 05:04:53 +08:00
|
|
|
func private @print_memref_f32(memref<*xf32>) attributes { llvm.emit_c_interface }
|
2019-11-20 03:51:53 +08:00
|
|
|
|
2019-10-15 21:52:24 +08:00
|
|
|
!vector_type_C = type vector<4x4xf32>
|
|
|
|
!matrix_type_CC = type memref<1x1x!vector_type_C>
|
|
|
|
func @vector_splat_2d() {
|
|
|
|
%c0 = constant 0 : index
|
|
|
|
%f10 = constant 10.0 : f32
|
|
|
|
%vf10 = splat %f10: !vector_type_C
|
2021-02-18 19:49:52 +08:00
|
|
|
%C = alloc() : !matrix_type_CC
|
|
|
|
store %vf10, %C[%c0, %c0]: !matrix_type_CC
|
2019-10-15 21:52:24 +08:00
|
|
|
|
2021-02-18 19:49:52 +08:00
|
|
|
%CC = memref_cast %C: !matrix_type_CC to memref<?x?x!vector_type_C>
|
2019-10-15 21:52:24 +08:00
|
|
|
call @print_memref_vector_4x4xf32(%CC): (memref<?x?x!vector_type_C>) -> ()
|
|
|
|
|
2021-02-18 19:49:52 +08:00
|
|
|
dealloc %C : !matrix_type_CC
|
2019-10-15 21:52:24 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// PRINT-VECTOR-SPLAT-2D: Memref base@ = {{.*}} rank = 2 offset = 0 sizes = [1, 1] strides = [1, 1] data =
|
2019-11-20 03:51:53 +08:00
|
|
|
// PRINT-VECTOR-SPLAT-2D-NEXT: [((10, 10, 10, 10), (10, 10, 10, 10), (10, 10, 10, 10), (10, 10, 10, 10))]
|
2019-10-15 21:52:24 +08:00
|
|
|
|
2020-11-14 05:04:53 +08:00
|
|
|
func private @print_memref_vector_4x4xf32(memref<?x?x!vector_type_C>) attributes { llvm.emit_c_interface }
|