1 //===- TestTilingInterfaceTransformOps.td -----------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef TEST_TILINGINTERFACE_TRANSFORM_OPS
10 #define TEST_TILINGINTERFACE_TRANSFORM_OPS
12 include "mlir/Dialect/SCF/IR/DeviceMappingInterface.td"
13 include "mlir/Dialect/Transform/IR/TransformDialect.td"
14 include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.td"
15 include "mlir/Dialect/Transform/IR/TransformTypes.td"
16 include "mlir/Interfaces/SideEffectInterfaces.td"
17 include "mlir/IR/OpBase.td"
19 // Those operations in this file are meant for testing the tiling interface
20 // transformations using scf operations. Over time these testing options
21 // might be useful transformations in their own right. Move these over
22 // as transform ops in the main repo (also find a proper place for them)
24 def TestFuseAndYieldOp : Op<Transform_Dialect, "test.fuse_and_yield",
25 [FunctionalStyleTransformOpTrait, MemoryEffectsOpInterface,
26 DeclareOpInterfaceMethods<TransformOpInterface>,
27 ReportTrackingListenerFailuresOpTrait]> {
29 Tiles the operations pointed to by the target handle, fuses their
30 producers greedily using the options provided as attributes.
31 It also yields some of the fused producers for testing.
33 On success returns the tiled operations as well as generated loops. Emits
34 a definite failure if tiling fails.
38 (ins TransformHandleTypeInterface:$target,
39 DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
40 DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_interchange,
41 DefaultValuedAttr<BoolAttr, "false">:$use_forall);
42 let results = (outs TransformHandleTypeInterface:$transfomed,
43 Variadic<TransformHandleTypeInterface>:$loops);
45 let assemblyFormat = [{
46 $target ($tile_sizes^)? (`interchange` $tile_interchange^)?
47 (`use_forall` $use_forall^)? attr-dict
48 `:` functional-type(operands, results)
52 def TestFuseConsumerOp : Op<Transform_Dialect, "test.fuse_consumer",
53 [DeclareOpInterfaceMethods<TransformOpInterface>,
54 DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
55 ReportTrackingListenerFailuresOpTrait]> {
57 Fuses the consumer of the operation pointed to by the target handle
58 using the options provided as attributes.
62 (ins TransformHandleTypeInterface:$target,
63 DefaultValuedAttr<I32Attr, "1">:$num_consumer_to_fuse);
64 let results = (outs TransformHandleTypeInterface:$consumer,
65 TransformHandleTypeInterface:$fused_consumer);
67 let assemblyFormat = [{
68 $target (`num_consumer_to_fuse` `=` $num_consumer_to_fuse^)?
69 attr-dict `:` functional-type(operands, results)
73 def TestTileUsingForallOp : Op<Transform_Dialect, "test.tile_using_forall",
74 [DeclareOpInterfaceMethods<TransformOpInterface>,
75 DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
76 ReportTrackingListenerFailuresOpTrait]> {
78 Test operation use to test tiling using TilingInterface and scf.forall for
79 the loop constructs. This is similar to
80 `transform.structured.tile_using_for`. Use of this operation is an
81 intermediate state and will be replaced in due course with either
82 `transform.structured.tile_using_for` or
83 `transform.structured.tile_using_forall`.
85 On success returns the tiled operations as well as generated loops. Emits
86 a definite failure if tiling fails.
89 let arguments = (ins TransformHandleTypeInterface:$target,
90 DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
91 DefaultValuedOptionalAttr<I64ArrayAttr, "{}">:$interchange,
92 OptionalAttr<DeviceMappingArrayAttr>:$mapping);
93 let results = (outs TransformHandleTypeInterface:$tiled_op,
94 Variadic<TransformHandleTypeInterface>:$loops);
96 let assemblyFormat = [{
97 $target ($tile_sizes^)? (`interchange` `=` $interchange^)?
98 (`mapping` `=` $mapping^)?
99 attr-dict `:` functional-type(operands, results)
103 def TestFuseUsingForallOp : Op<Transform_Dialect, "test.fuse_using_forall",
104 [DeclareOpInterfaceMethods<TransformOpInterface>,
105 DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
106 ReportTrackingListenerFailuresOpTrait]> {
108 Test operation to tile the operation pointed to by the target handle and
109 fuses their producers greedily using the options provided as attributes.
110 This operation uses scf.forall for the loop construct.
112 let arguments = (ins TransformHandleTypeInterface:$root_op,
113 DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
114 DefaultValuedOptionalAttr<I64ArrayAttr, "{}">:$interchange,
115 OptionalAttr<DeviceMappingArrayAttr>:$mapping);
116 let results = (outs TransformHandleTypeInterface:$tiled_ops,
117 Variadic<TransformHandleTypeInterface>:$loops);
119 let assemblyFormat = [{
120 $root_op ($tile_sizes^)? (`interchange` $interchange^)?
121 (`mapping` `=` $mapping^)?
122 attr-dict `:` functional-type(operands, results)
126 #endif // TEST_TILINGINTERFACE_TRANSFORM_OPS