Files
clang-p2996/mlir/test/Dialect/Transform/ops.mlir
srcarroll 2c1c67674c [mlir][transform] Consistent linalg transform op syntax for dynamic index lists (#90897)
This patch is a first pass at making consistent syntax across the
`LinalgTransformOp`s that use dynamic index lists for size parameters.
Previously, there were two different forms: inline types in the list, or
place them in the functional style tuple. This patch goes for the
latter.

In order to do this, the `printPackedOrDynamicIndexList`,
`printDynamicIndexList` and their `parse` counterparts were modified so
that the types can be optionally provided to the corresponding custom
directives.

All affected ops now use tablegen `assemblyFormat`, so custom
`parse`/`print` functions have been removed. There are a couple ops that
will likely add dynamic size support, and once that happens it should be
made sure that the assembly remains consistent with the changes in this
patch.

The affected ops are as follows: `pack`, `pack_greedily`,
`tile_using_forall`. The `tile_using_for` and `vectorize` ops already
used this syntax, but their custom assembly was removed.

---------

Co-authored-by: Oleksandr "Alex" Zinenko <ftynse@gmail.com>
2024-05-08 09:11:53 -05:00

125 lines
5.1 KiB
MLIR

// RUN: mlir-opt %s | mlir-opt | FileCheck %s
// CHECK: transform.sequence
// CHECK: ^{{.+}}(%{{.+}}: !transform.any_op):
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op):
// CHECK: sequence %{{.+}} : !transform.any_op
// CHECK: ^{{.+}}(%{{.+}}: !transform.any_op):
sequence %arg0 : !transform.any_op failures(propagate) {
^bb1(%arg1: !transform.any_op):
}
}
// CHECK: transform.with_pdl_patterns
// CHECK: ^{{.+}}(%[[ARG:.+]]: !transform.any_op):
transform.with_pdl_patterns {
^bb0(%arg0: !transform.any_op):
// CHECK: sequence %[[ARG]] : !transform.any_op
sequence %arg0 : !transform.any_op failures(propagate) {
^bb1(%arg1: !transform.any_op):
}
}
// Using the same value multiple times without consuming it is fine.
// CHECK: transform.sequence
// CHECK: %[[V:.+]] = sequence %{{.*}} : !transform.any_op -> !transform.any_op
// CHECK: sequence %[[V]]
// CHECK: sequence %[[V]]
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op):
%0 = transform.sequence %arg0 : !transform.any_op -> !transform.any_op failures(propagate) {
^bb1(%arg1: !transform.any_op):
yield %arg1 : !transform.any_op
}
transform.sequence %0 : !transform.any_op failures(propagate) {
^bb2(%arg2: !transform.any_op):
}
transform.sequence %0 : !transform.any_op failures(propagate) {
^bb3(%arg3: !transform.any_op):
}
}
// CHECK: transform.sequence failures(propagate)
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
// CHECK: sequence %{{.*}}, %{{.*}}, %{{.*}} : (!transform.any_op, !transform.any_op, !transform.any_op) failures(propagate)
transform.sequence %arg0, %arg1, %arg2 : !transform.any_op, !transform.any_op, !transform.any_op failures(propagate) {
^bb0(%arg3: !transform.any_op, %arg4: !transform.any_op, %arg5: !transform.any_op):
}
}
// CHECK: transform.sequence failures(propagate)
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
// CHECK: sequence %{{.*}}, %{{.*}}, %{{.*}} : (!transform.any_op, !transform.any_op, !transform.any_op) failures(propagate)
transform.sequence %arg0, %arg1, %arg2 : (!transform.any_op, !transform.any_op, !transform.any_op) failures(propagate) {
^bb0(%arg3: !transform.any_op, %arg4: !transform.any_op, %arg5: !transform.any_op):
}
}
// CHECK: transform.sequence failures(propagate)
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
// CHECK: sequence %{{.*}}, %{{.*}}, %{{.*}} : (!transform.any_op, !transform.any_op, !transform.any_op) failures(propagate)
transform.sequence %arg0, %arg1, %arg2 : (!transform.any_op, !transform.any_op, !transform.any_op) failures(propagate) {
^bb0(%arg3: !transform.any_op, %arg4: !transform.any_op, %arg5: !transform.any_op):
}
}
// CHECK: transform.sequence
// CHECK: foreach
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op):
transform.foreach %arg0 : !transform.any_op {
^bb1(%arg1: !transform.any_op):
}
}
// CHECK: transform.sequence
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op):
// CHECK: cast %{{.*}} : !transform.any_op to !transform.any_op
%0 = cast %arg0: !transform.any_op to !transform.any_op
// CHECK: cast %{{.*}} : !transform.any_op to !transform.op<"builtin.module">
%1 = cast %0: !transform.any_op to !transform.op<"builtin.module">
}
// CHECK: transform.sequence
// CHECK-COUNT-9: print
transform.sequence failures(propagate) {
^bb0(%arg0: !transform.any_op):
transform.print %arg0 : !transform.any_op
transform.print
transform.print %arg0 {name = "test"} : !transform.any_op
transform.print {name = "test"}
transform.print {name = "test", assume_verified}
transform.print %arg0 {assume_verified} : !transform.any_op
transform.print %arg0 {use_local_scope} : !transform.any_op
transform.print %arg0 {skip_regions} : !transform.any_op
transform.print %arg0 {assume_verified, use_local_scope, skip_regions} : !transform.any_op
}
// CHECK: transform.sequence
// CHECK: transform.structured.tile_using_for %0 tile_sizes [4, 4, [4]]
transform.sequence failures(propagate) {
^bb0(%arg1: !transform.any_op):
%0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op
transform.structured.tile_using_for %0 tile_sizes [4, 4, [4]] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
}
// CHECK: transform.sequence
// CHECK: transform.structured.tile_using_for %0 tile_sizes {{\[}}[2], 4, 8]
transform.sequence failures(propagate) {
^bb0(%arg1: !transform.any_op):
%0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op
transform.structured.tile_using_for %0 tile_sizes [[2], 4, 8] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
}
// CHECK: transform.sequence
// CHECK: transform.param.constant "example_string
transform.sequence failures(propagate) {
^bb0(%arg1: !transform.any_op):
transform.param.constant "example_string" -> !transform.any_param
}