brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 77c9d4a Raw
62 lines · plain
1// RUN: mlir-opt %s -convert-linalg-to-std -split-input-file | FileCheck %s2 3func.func private @printMemrefF32(memref<*xf32>)4 5// CHECK:  func private @linalg_fill_f32_viewsxsxf32(f32, memref<?x?xf32, {{.*}}>) attributes {llvm.emit_c_interface}6// CHECK:  func private @linalg_matmul_viewsxsxf32_viewsxsxf32_viewsxsxf32(memref<?x?xf32, {{.*}}>, memref<?x?xf32, {{.*}}>, memref<?x?xf32, {{.*}}>) attributes {llvm.emit_c_interface}7 8func.func @matmul(%A: memref<?x?xf32>, %B: memref<?x?xf32>) -> (memref<?x?xf32>) {9  %c0 = arith.constant 0 : index10  %c1 = arith.constant 1 : index11  %f0 = arith.constant 0.0 : f3212  %x = memref.dim %A, %c0 : memref<?x?xf32>13  %y = memref.dim %B, %c1 : memref<?x?xf32>14  %C = memref.alloc(%x, %y) : memref<?x?xf32>15 16  // CHECK: call @linalg_fill_f32_viewsxsxf32({{.*}}) : (f32, memref<?x?xf32, {{.*}}>)17  linalg.fill ins(%f0 : f32) outs(%C : memref<?x?xf32>)18 19  // CHECK:  call @linalg_matmul_viewsxsxf32_viewsxsxf32_viewsxsxf32({{.*}}) : (memref<?x?xf32, {{.*}}>, memref<?x?xf32, {{.*}}>, memref<?x?xf32, {{.*}}>) -> ()20  linalg.matmul ins(%A, %B: memref<?x?xf32>, memref<?x?xf32>)21                outs(%C: memref<?x?xf32>)22  return %C : memref<?x?xf32>23}24 25// -----26 27#accesses = [28        affine_map<(d0) -> (d0)>,29        affine_map<(d0) -> (d0)>,30        affine_map<(d0) -> (d0)>31    ]32#trait = {33    doc = "...",34    indexing_maps = #accesses,35    library_call = "test",36    iterator_types = ["parallel"]37}38 39// CHECK: func.func private @linalg_copy_view32xf16as1_view32xf16as6(memref<32xf16, strided<[?], offset: ?>, 1>, memref<32xf16, strided<[?], offset: ?>, 6>) attributes {llvm.emit_c_interface}40// CHECK: func.func private @linalg_copy_view32xf16as6_view32xf16as1(memref<32xf16, strided<[?], offset: ?>, 6>, memref<32xf16, strided<[?], offset: ?>, 1>) attributes {llvm.emit_c_interface}41 42module {43  func.func @helper(%arg7: memref<32xf16, 1>, %arg8: memref<32xf16, 1>, %arg9: memref<32xf16, 1>) {44    %localA = memref.alloca() : memref<32xf16, 6>45    %localB = memref.alloca() : memref<32xf16, 6>46    %localOut = memref.alloca() : memref<32xf16, 6>47    linalg.copy ins(%arg8 : memref<32xf16, 1>) outs(%localA : memref<32xf16, 6>)48    linalg.copy ins(%arg9 : memref<32xf16, 1>) outs(%localB : memref<32xf16, 6>)49 50    linalg.generic #trait51    ins(%localA, %localB : memref<32xf16, 6>, memref<32xf16, 6>)52    outs(%localOut : memref<32xf16, 6>) {53      ^bb0(%0: f16, %1: f16, %2: f16) :54        %e = arith.addf %1, %0: f1655        linalg.yield %e : f1656    }57 58    linalg.copy ins(%localOut : memref<32xf16, 6>) outs(%arg7 : memref<32xf16, 1>)59    return60  }61}62