Skip to content

Commit 4c70195

Browse files
[mlir][transform] Fix ch2 and additional documentation (#148407)
Fixed error code in example.In addition to this, the content in the documentation has been improved by adding links to the code repository.
1 parent 8b06814 commit 4c70195

File tree

1 file changed

+16
-14
lines changed
  • mlir/docs/Tutorials/transform

1 file changed

+16
-14
lines changed

mlir/docs/Tutorials/transform/Ch2.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ This will generate two files, `MyExtension.h.inc` and `MyExtension.cpp.inc`, tha
133133
```c++
134134
// In MyExtension.cpp.
135135

136+
#include "MyExtension.h"
137+
136138
#define GET_OP_CLASSES
137139
#include "MyExtension.cpp.inc"
138140

@@ -283,7 +285,7 @@ void registerMyExtension(::mlir::DialectRegistry &registry) {
283285
}
284286
```
285287
286-
After registering the extension, it becomes possible to use our new operation in the Transform dialect interpreter. The upstream testing pass can be used as is.
288+
After registering the extension, it becomes possible to use our new operation in the Transform dialect interpreter. The upstream testing pass can be used as is. It actually exists in `mlir/test/Examples/transform/Ch2/sequence.mlir`, which contains the `microkernel` implementation.
287289
288290
```mlir
289291
module attributes {transform.with_named_sequence} {
@@ -300,7 +302,7 @@ module attributes {transform.with_named_sequence} {
300302
301303
// The actual tiling transformation takes tile sizes as attributes. It
302304
// produces a handle to the loop generated during tiling.
303-
%loop, %tiled = transform.structured.tile_using_forall %max
305+
%tiled, %loop = transform.structured.tile_using_forall %max
304306
tile_sizes [8, 32]
305307
: (!transform.any_op) -> (!transform.any_op, !transform.any_op)
306308
@@ -311,32 +313,32 @@ module attributes {transform.with_named_sequence} {
311313
// a single handle to all operations and give it to
312314
// `fuse_into_containing_op` that would take care of the ordering in this
313315
// case.
314-
%add_fused = transform.structured.fuse_into_containing_op %add into %loop
315-
: (!transform.any_op, !transform.any_op) -> !transform.any_op
316-
%matmul_fused = transform.structured.fuse_into_containing_op %arg1
317-
into %loop
316+
%add_fused, %loop2 = transform.structured.fuse_into_containing_op %add into %loop
317+
: (!transform.any_op, !transform.any_op) -> (!transform.any_op, !transform.any_op)
318+
%matmul_fused, %loop3 = transform.structured.fuse_into_containing_op %arg1
319+
into %loop2
318320
: (!transform.op<"linalg.matmul">, !transform.any_op)
319-
-> !transform.any_op
321+
-> (!transform.any_op, !transform.any_op)
320322
321323
// Tile again to get the desired size. Note that this time this tiles the
322324
// "add" operation and fuses matmul into the loop, but doesn't affect the
323325
// "max" operation. This illustrates the precise targeting with the
324326
// transform dialect. Otherwise, it is difficult to differentiate "add" and
325327
// "max", both of which having the same kind.
326-
%loop_2, %tiled_2 = transform.structured.tile_using_forall %add_fused
328+
%tiled_second, %loop_second = transform.structured.tile_using_forall %add_fused
327329
tile_sizes [4, 4]
328330
: (!transform.any_op) -> (!transform.any_op, !transform.any_op)
329-
%matmul_fused_2 = transform.structured.fuse_into_containing_op %matmul_fused
330-
into %loop_2
331-
: (!transform.any_op, !transform.any_op) -> !transform.any_op
331+
%matmul_fused_2, %loop_second_2 = transform.structured.fuse_into_containing_op %matmul_fused
332+
into %loop_second
333+
: (!transform.any_op, !transform.any_op) -> (!transform.any_op, !transform.any_op)
332334
333335
// Since outlining is currently only implemented for region-holding
334336
// operations such as loops, use tiling to size 1 to materialize the outer
335337
// loop that is going to be outlined.
336-
%outline_target, %_ = transform.structured.tile_using_forall %tiled_2 tile_sizes [1]
338+
%_0, %loop_third = transform.structured.tile_using_forall %tiled_second tile_sizes [1]
337339
: (!transform.any_op) -> (!transform.any_op, !transform.any_op)
338-
transform.structured.fuse_into_containing_op %matmul_fused_2 into %outline_target
339-
: (!transform.any_op, !transform.any_op) -> !transform.any_op
340+
%_1, %outline_target = transform.structured.fuse_into_containing_op %matmul_fused_2 into %loop_third
341+
: (!transform.any_op, !transform.any_op) -> (!transform.any_op, !transform.any_op)
340342
%func, %call = transform.loop.outline %outline_target
341343
{func_name = "outlined"}
342344
: (!transform.any_op) -> (!transform.any_op, !transform.any_op)

0 commit comments

Comments
 (0)