xref: /llvm-project/mlir/test/Dialect/Linalg/transform-ops.mlir (revision 618f231a6d3ef41d231e2a4d1e2eca4c0d709802)
1// RUN: mlir-opt %s --split-input-file | mlir-opt | FileCheck %s
2
3transform.sequence failures(propagate) {
4^bb1(%arg0: !transform.any_op):
5  // CHECK: %{{.*}}, %{{.*}}:2 = transform.structured.tile
6  %0, %1:2 = transform.structured.tile_using_for %arg0 tile_sizes [2, 0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
7}
8
9// check that the Attributes of `tile_using_for` are preserved through printing
10// and parsing with and without use of the optional `interchange` Attribute.
11transform.sequence failures(propagate) {
12^bb1(%arg0: !transform.any_op):
13  // CHECK: %{{.*}}, %{{.*}}:2 = transform.structured.tile_using_for %arg0 tile_sizes [2, 0, 3] interchange = [2, 1] {test_attr1 = 1 : i64, test_attr2}
14  %0, %1:2 = transform.structured.tile_using_for %arg0 tile_sizes [2, 0, 3] interchange = [2, 1] {test_attr1 = 1 : i64, test_attr2}: (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
15  // CHECK: %{{.*}}, %{{.*}}:2 = transform.structured.tile_using_for %tiled_linalg_op tile_sizes [0, 5, 3] {test_attr3 = 1 : i64, test_attr4}
16  %2, %3:2 = transform.structured.tile_using_for %0 tile_sizes [0, 5, 3] {test_attr3 = 1 : i64, test_attr4}: (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
17}
18
19transform.sequence failures(propagate) {
20^bb1(%arg0: !transform.any_op):
21  %t = transform.structured.split %arg0 after 42 { dimension = 0 } : !transform.any_op
22  %0:2 = transform.split_handle %t : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
23  transform.structured.split %0#0 after %0#1 { dimension = 1 } : !transform.any_op, !transform.any_op
24}
25
26//===----------------------------------------------------------------------===//
27// Check that operations are registered correctly through the extension
28// mechanism. Their syntax is generated and requires no additional testing since
29// we test the generator.
30//===----------------------------------------------------------------------===//
31
32transform.sequence failures(propagate) {
33^bb1(%arg0: !transform.any_op):
34  // CHECK: transform.structured.pad
35  %0, %1, %2 = transform.structured.pad %arg0 : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
36}
37
38transform.sequence failures(propagate) {
39^bb1(%arg0: !transform.any_op):
40  // CHECK: transform.structured.interchange
41  %0 = transform.structured.interchange %arg0 : (!transform.any_op) -> !transform.any_op
42}
43
44transform.sequence failures(propagate) {
45^bb1(%arg0: !transform.any_op):
46  // CHECK: transform.structured.scalarize
47  %0 = transform.structured.scalarize %arg0 : (!transform.any_op) -> !transform.any_op
48}
49
50// Check that the second argument of `fuse_into_containing_op` is not consumed
51// (if it had been, we would have seen a diagnostic about multiple consumers).
52transform.sequence failures(propagate) {
53^bb1(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
54  %loop = transform.structured.match ops{["scf.forall"]} in %arg0
55    : (!transform.any_op) -> !transform.any_op
56  %0:2 = transform.structured.fuse_into_containing_op %arg1 into %loop
57    : (!transform.any_op, !transform.any_op) -> (!transform.any_op, !transform.any_op)
58  %1:2 = transform.structured.fuse_into_containing_op %arg2 into %loop
59    : (!transform.any_op, !transform.any_op) -> (!transform.any_op, !transform.any_op)
60}
61
62// -----
63
64transform.sequence failures(propagate) {
65^bb0(%arg0: !transform.any_op):
66  // CHECK: transform.structured.vectorize %arg0 : !transform.any_op
67  transform.structured.vectorize %arg0 vector_sizes [] : !transform.any_op
68
69}
70