brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · b52612d Raw
70 lines · plain
1// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline='builtin.module(test.symbol_scope_isolated(test-one-shot-module-bufferize))' -split-input-file | FileCheck %s2 3"test.symbol_scope_isolated"() ({4  // CHECK-LABEL: func @inner_func(5  //  CHECK-SAME:     %[[arg0:.*]]: memref<?xf326  func.func @inner_func(%t: tensor<?xf32>) -> (tensor<?xf32>, f32) {7    // CHECK-NOT: copy8    %f = arith.constant 1.0 : f329    %c0 = arith.constant 0 : index10    %c1 = arith.constant 1 : index11    // CHECK: memref.store %{{.*}}, %[[arg0]]12    %0 = tensor.insert %f into %t[%c0] : tensor<?xf32>13    // CHECK: %[[load:.*]] = memref.load %[[arg0]]14    %1 = tensor.extract %0[%c1] : tensor<?xf32>15    // CHECK: return %[[arg0]], %[[load]] : memref<?xf32{{.*}}>, f3216    return %0, %1 : tensor<?xf32>, f3217  }18 19  // CHECK-LABEL: func @call_func_with_non_tensor_return(20  //  CHECK-SAME:     %[[arg0:.*]]: memref<?xf3221  func.func @call_func_with_non_tensor_return(22      %t0: tensor<?xf32> {bufferization.writable = true}) -> (f32, tensor<?xf32>) {23    // CHECK-NOT: alloc24    // CHECK-NOT: copy25    // CHECK: %[[call:.*]]:2 = call @inner_func(%[[arg0]])26    %0, %1 = call @inner_func(%t0) : (tensor<?xf32>) -> (tensor<?xf32>, f32)27    // CHECK: return %[[call]]#1, %[[call]]#0 : f32, memref<?xf32{{.*}}>28    return %1, %0 : f32, tensor<?xf32>29  }30  "test.finish" () : () -> ()31}) : () -> ()32 33// -----34 35#enc1 = #test.tensor_encoding<"hello">36#enc2 = #test.tensor_encoding<"not hello">37 38"test.symbol_scope_isolated"() ({39  // CHECK: func @inner_func(40  // CHECK-SAME:  %[[arg0:.*]]: memref<?xf32, #test.memref_layout<"hello">>)41  // CHECK-SAME:  -> memref<?xf32, #test.memref_layout<"hello">>42  func.func @inner_func(%t: tensor<?xf32, #enc1>)43      -> tensor<?xf32, #enc1> {44    // CHECK: return %[[arg0]]45    return %t : tensor<?xf32, #enc1>46  }47 48  // CHECK: func @outer_func(49  // CHECK-SAME:  %[[arg0:.*]]: memref<?xf32, #test.memref_layout<"hello">>)50  // CHECK-SAME:  -> (memref<?xf32, #test.memref_layout<"hello">>,51  // CHECK-SAME:      memref<?xf32, #test.memref_layout<"not hello">>)52  func.func @outer_func(%t0: tensor<?xf32, #enc1>)53      -> (tensor<?xf32, #enc1>, tensor<?xf32, #enc2>) {54    // CHECK: %[[call:.*]] = call @inner_func(%[[arg0]])55    %0 = call @inner_func(%t0)56      : (tensor<?xf32, #enc1>) -> (tensor<?xf32, #enc1>)57 58    // CHECK: %[[local:.*]] = "test.create_memref_op"() : ()59    // CHECK-SAME:  -> memref<?xf32, #test.memref_layout<"not hello">>60    %local = "test.create_tensor_op"() : () -> tensor<?xf32, #enc2>61    // CHECK: %[[dummy:.*]] = "test.dummy_memref_op"(%[[local]])62    %1 = "test.dummy_tensor_op"(%local) : (tensor<?xf32, #enc2>)63      -> tensor<?xf32, #enc2>64 65    // CHECK: return %[[call]], %[[dummy]]66    return %0, %1 : tensor<?xf32, #enc1>, tensor<?xf32, #enc2>67  }68  "test.finish" () : () -> ()69}) : () -> ()70