brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 3fb89aa Raw
37 lines · plain
1// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries=1 no-analysis-func-filter=contains_to_buffer_op" -drop-equivalent-buffer-results --split-input-file | FileCheck %s2 3// ToMemref ops do not pass analysis step. CopyBeforeWrite will be true only for the4// FuncOp "contains_to_buffer_op" since it is specified in no-analysis-func-filter.5 6// RUN: mlir-opt %s -one-shot-bufferize="bufferize-function-boundaries=1 copy-before-write=1" -drop-equivalent-buffer-results --split-input-file | FileCheck %s --check-prefix=CHECK_COPY7 8// Show that memref.copy appear in both functions when CopyBeforeWrite is true.9 10module {11  // CHECK-LABEL:   func.func @foo(12  // CHECK-NOT:       memref.copy13 14  // CHECK_COPY-LABEL:   func.func @foo(15  // CHECK_COPY:           memref.copy16 17  func.func @foo(%arg0: tensor<?xf32>) -> tensor<?xf32> {18    %cst = arith.constant 1.000000e+00 : f3219    %c0 = arith.constant 0 : index20    %inserted = tensor.insert %cst into %arg0[%c0] : tensor<?xf32>21    return %inserted : tensor<?xf32>22  }23 24  // CHECK-LABEL:   func.func @contains_to_buffer_op(25  // CHECK:           memref.copy26 27  // CHECK_COPY-LABEL:   func.func @contains_to_buffer_op(28  // CHECK_COPY:           memref.copy29 30  func.func @contains_to_buffer_op(%arg0: tensor<?xf32> {bufferization.writable = true}, %arg1: index) -> vector<5xf32> {31    %0 = bufferization.to_buffer %arg0 : tensor<?xf32> to memref<?xf32>32    %cst = arith.constant 0.000000e+00 : f3233    %1 = vector.transfer_read %0[%arg1], %cst : memref<?xf32>, vector<5xf32>34    return %1 : vector<5xf32>35  }36}37