1// RUN: mlir-opt %s -transform-interpreter -split-input-file -verify-diagnostics 2 3func.func @non_elementwise(%arg0: memref<2x3xf32>, %arg1: memref<3x4xf32>, %arg2: memref<2x4xf32>) { 4 // expected-error @below {{only elementwise flattening is supported}} 5 linalg.matmul ins(%arg0, %arg1 : memref<2x3xf32>, memref<3x4xf32>) outs(%arg2: memref<2x4xf32>) 6 return 7} 8 9module attributes {transform.with_named_sequence} { 10 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 11 %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op 12 %flattened = transform.structured.flatten_elementwise %0 13 : (!transform.any_op) -> !transform.any_op 14 transform.yield 15 } 16} 17 18// ----- 19 20func.func @unsupported_memref(%arg0: memref<32x7xf32, strided<[7, 2]>>, %arg1: memref<32x7xf32, strided<[7, 2]>>, %arg2: memref<32x7xf32, strided<[7, 2]>>) { 21 // expected-error @below {{attempted to flatten, but failed}} 22 linalg.map {arith.addf} ins(%arg0, %arg1: memref<32x7xf32, strided<[7, 2]>>, memref<32x7xf32, strided<[7, 2]>>) outs(%arg2: memref<32x7xf32, strided<[7, 2]>>) 23 return 24} 25 26module attributes {transform.with_named_sequence} { 27 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 28 %0 = transform.structured.match interface{LinalgOp} in %arg1 : (!transform.any_op) -> !transform.any_op 29 %flattened = transform.structured.flatten_elementwise %0 30 : (!transform.any_op) -> !transform.any_op 31 transform.yield 32 } 33} 34