1// RUN: mlir-opt %s -test-transform-dialect-interpreter -split-input-file -verify-diagnostics | FileCheck %s
2
3//       CHECK: #[[$MAP:.*]] = affine_map<(d0, d1) -> (d1, d0)>
4
5// CHECK-LABEL: @interchange_generic
6func.func @interchange_generic(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>) -> tensor<?x?xf32> {
7
8  //      CHECK:   linalg.generic
9  // CHECK-SAME:   indexing_maps = [#[[$MAP]], #[[$MAP]]
10  %0 = linalg.generic {
11    indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>],
12    iterator_types = ["parallel", "parallel"]
13  } ins(%arg0 : tensor<?x?xf32>) outs(%arg1 : tensor<?x?xf32>) {
14  ^bb0(%arg2: f32, %arg3: f32):
15    %1 = math.exp %arg2 : f32
16    linalg.yield %1 : f32
17  } -> tensor<?x?xf32>
18  return %0 : tensor<?x?xf32>
19}
20
21transform.with_pdl_patterns {
22^bb0(%arg0: !pdl.operation):
23  transform.sequence %arg0 {
24  ^bb1(%arg1: !pdl.operation):
25    %0 = transform.structured.match ops{["linalg.generic"]} in %arg1
26    transform.structured.interchange %0 { iterator_interchange = [1, 0]}
27  }
28}
29
30// -----
31
32func.func @interchange_matmul(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>, %arg2: tensor<?x?xf32>) -> tensor<?x?xf32> {
33  // expected-note @below {{when applied to this op}}
34  %0 = linalg.matmul ins(%arg0, %arg1 : tensor<?x?xf32>, tensor<?x?xf32>) outs(%arg2 : tensor<?x?xf32>) -> tensor<?x?xf32>
35  return %0 : tensor<?x?xf32>
36}
37
38transform.with_pdl_patterns {
39^bb0(%arg0: !pdl.operation):
40  transform.sequence %arg0 {
41  ^bb1(%arg1: !pdl.operation):
42    %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1
43    // expected-error @below {{transform applied to the wrong op kind}}
44    transform.structured.interchange %0 { iterator_interchange = [1, 0]}
45  }
46}
47