brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · f6bdca7 Raw
62 lines · plain
1// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries" -split-input-file | FileCheck %s2 3// Run fuzzer with different seeds.4// RUN: mlir-opt %s -one-shot-bufferize="test-analysis-only analysis-heuristic=fuzzer analysis-fuzzer-seed=23 bufferize-function-boundaries" -split-input-file -o /dev/null5// RUN: mlir-opt %s -one-shot-bufferize="test-analysis-only analysis-heuristic=fuzzer analysis-fuzzer-seed=59 bufferize-function-boundaries" -split-input-file -o /dev/null6// RUN: mlir-opt %s -one-shot-bufferize="test-analysis-only analysis-heuristic=fuzzer analysis-fuzzer-seed=91 bufferize-function-boundaries" -split-input-file -o /dev/null7 8// Test bufferization using memref types that have no layout map.9// RUN: mlir-opt %s -one-shot-bufferize="unknown-type-conversion=identity-layout-map function-boundary-type-conversion=identity-layout-map bufferize-function-boundaries" -split-input-file -o /dev/null10 11// CHECK-LABEL: func @write_to_select_op_source12//  CHECK-SAME:     %[[t1:.*]]: memref<?xf32, strided{{.*}}>, %[[t2:.*]]: memref<?xf32, strided{{.*}}>13func.func @write_to_select_op_source(14    %t1 : tensor<?xf32> {bufferization.writable = true},15    %t2 : tensor<?xf32> {bufferization.writable = true},16    %c : i1)17  -> (tensor<?xf32>, tensor<?xf32>)18{19  %cst = arith.constant 0.0 : f3220  %idx = arith.constant 0 : index21  // CHECK: %[[alloc:.*]] = memref.alloc22  // CHECK: memref.copy %[[t1]], %[[alloc]]23  // CHECK: memref.store %{{.*}}, %[[alloc]]24  %w = tensor.insert %cst into %t1[%idx] : tensor<?xf32>25  // CHECK: %[[select:.*]] = arith.select %{{.*}}, %[[t1]], %[[t2]]26  %s = arith.select %c, %t1, %t2 : tensor<?xf32>27  // CHECK: return %[[select]], %[[alloc]]28  return %s, %w : tensor<?xf32>, tensor<?xf32>29}30 31// -----32 33// Due to the out-of-place bufferization of %t1, buffers with different layout34// maps are passed to arith.select. A cast must be inserted.35 36// CHECK-LABEL: func @write_after_select_read_one37//  CHECK-SAME:     %[[t1:.*]]: memref<?xf32, strided{{.*}}>, %[[t2:.*]]: memref<?xf32, strided{{.*}}>38func.func @write_after_select_read_one(39    %t1 : tensor<?xf32> {bufferization.writable = true},40    %t2 : tensor<?xf32> {bufferization.writable = true},41    %c : i1)42  -> (f32, tensor<?xf32>)43{44  %cst = arith.constant 0.0 : f3245  %idx = arith.constant 0 : index46 47  // CHECK: %[[alloc:.*]] = memref.alloc48  // CHECK-DAG: %[[casted:.*]] = memref.cast %[[alloc]]49  // CHECK-DAG: memref.copy %[[t1]], %[[alloc]]50  // CHECK: %[[select:.*]] = arith.select %{{.*}}, %[[casted]], %[[t2]]51  %s = arith.select %c, %t1, %t2 : tensor<?xf32>52 53  // CHECK: memref.store %{{.*}}, %[[select]]54  %w = tensor.insert %cst into %s[%idx] : tensor<?xf32>55 56  // CHECK: %[[f:.*]] = memref.load %[[t1]]57  %f = tensor.extract %t1[%idx] : tensor<?xf32>58 59  // CHECK: return %[[f]], %[[select]]60  return %f, %w : f32, tensor<?xf32>61}62