brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 7280ccb Raw
95 lines · plain
1// RUN: mlir-opt -transform-interpreter %s --split-input-file --allow-unregistered-dialect -verify-diagnostics | FileCheck %s2 3// CHECK:  func.func @linalg_copy_to_memref_copy(%[[INPUT:.*]]: memref<128x64xf32>, %[[OUTPUT:.*]]: memref<128x64xf32>) {4// CHECK:    memref.copy %[[INPUT]], %[[OUTPUT]] : memref<128x64xf32> to memref<128x64xf32>5// CHECK:    return6// CHECK:  }7 8func.func @linalg_copy_to_memref_copy(%input : memref<128x64xf32>, %output : memref<128x64xf32>) {9  linalg.copy ins(%input : memref<128x64xf32>) outs(%output : memref<128x64xf32>)10  return11}12 13module attributes {transform.with_named_sequence} {14  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {15    %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op16    %1 = transform.structured.linalg_copy_to_memref %0 : (!transform.any_op) -> !transform.any_op17    transform.yield18  }19}20 21// -----22 23// CHECK:  func.func @linalg_copy_to_memref_copy_strides(%[[INPUT:.*]]: memref<128x32xf32>, %[[OUTPUT:.*]]: memref<128x64xf32>) {24// CHECK:    %[[ALLOC:.*]] = memref.alloc() {alignment = 64 : i64} : memref<128x64xf32>25// CHECK:    %[[SUBVIEW:.*]] = memref.subview %[[ALLOC]][0, 32] [128, 32] [1, 1] : memref<128x64xf32> to memref<128x32xf32, strided<[64, 1], offset: 32>>26// CHECK:    memref.copy %[[INPUT]], %[[SUBVIEW]] : memref<128x32xf32> to memref<128x32xf32, strided<[64, 1], offset: 32>>27// CHECK:    return28// CHECK:  }29 30func.func @linalg_copy_to_memref_copy_strides(%input : memref<128x32xf32>, %output : memref<128x64xf32>) {31  %alloc = memref.alloc() {alignment = 64 : i64} : memref<128x64xf32>32  %subview = memref.subview %alloc[0, 32] [128, 32] [1, 1] : memref<128x64xf32> to memref<128x32xf32, strided<[64, 1], offset: 32>>33  linalg.copy ins(%input : memref<128x32xf32>) outs(%subview : memref<128x32xf32, strided<[64, 1], offset: 32>>)34  return35}36 37module attributes {transform.with_named_sequence} {38  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {39    %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op40    %1 = transform.structured.linalg_copy_to_memref %0 : (!transform.any_op) -> !transform.any_op41    transform.yield42  }43}44 45// -----46 47func.func @linalg_copy_to_memref_copy_tensors(%input : tensor<128x64xf32>, %output : tensor<128x64xf32>) -> tensor<128x64xf32> {48  // expected-note @below {{target op}}49  %0 = linalg.copy ins(%input : tensor<128x64xf32>) outs(%output : tensor<128x64xf32>) -> tensor<128x64xf32>50  return %0 : tensor<128x64xf32>51}52 53module attributes {transform.with_named_sequence} {54  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {55    %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op56    // expected-error @below {{cannot transform a linalg.copy on tensors into a memref.copy}}57    %1 = transform.structured.linalg_copy_to_memref %0 : (!transform.any_op) -> !transform.any_op58    transform.yield59  }60}61 62// -----63 64func.func @linalg_copy_to_memref_copy_different_element(%input : memref<128x64xf32>, %output : memref<128x64xf64>) {65  // expected-note @below {{target op}}66  linalg.copy ins(%input : memref<128x64xf32>) outs(%output : memref<128x64xf64>)67  return68}69 70module attributes {transform.with_named_sequence} {71  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {72    %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op73    // expected-error @below {{cannot transform a linalg.copy with different source and destination element types}}74    %1 = transform.structured.linalg_copy_to_memref %0 : (!transform.any_op) -> !transform.any_op75    transform.yield76  }77}78 79// -----80 81func.func @linalg_copy_to_memref_copy_scalar(%input : f64, %output : memref<128x64xf64>) {82  // expected-note @below {{target op}}83  linalg.copy ins(%input : f64) outs(%output : memref<128x64xf64>)84  return85}86 87module attributes {transform.with_named_sequence} {88  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {89    %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!transform.any_op) -> !transform.any_op90    // expected-error @below {{cannot transform a linalg.copy which input has no shape}}91    %1 = transform.structured.linalg_copy_to_memref %0 : (!transform.any_op) -> !transform.any_op92    transform.yield93  }94}95