I want to use
linalg-strategy-tile-and-fuse-pass for a linalg.generic op, but it did not change the mlir it.
mlir-opt ./fusion.mlir --linalg-strategy-tile-and-fuse-pass=“anchor-func=filter”
The debug output shows that this pass matched the generic op but failed because
expect #tile sizes >= #loops
this link shows there was a tile-sizes option for a similar pass
--linalg-tile-and-fuse-tensor-ops but now it seems removed, and I also cannot find
Is there any way to solve it?
linalg-strategy-tile-and-fuse-pass is used internally by CodeGenStragey and there is indeed no command line option to set the tile sizes (AFAIK). If you use the pass programmatically the tile sizes can be set.
The easiest way to do tile and fuse is currently the CodeGenStrategy test pass:
-test-linalg-codegen-strategy="anchor-op=linalg.generic fuse tile-sizes=5,4,7"
I took the example from the following test:
// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-op=linalg.matmul fuse tile-sizes=5,4,7 tile-interchange=1,0,2 run-enable-pass=false" -cse -split-input-file | FileCheck --check-prefix=MATMUL %s
// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-op=linalg.generic fuse tile-sizes=5,4,7 tile-interchange=1,0,2 run-enable-pass=false" -cse -split-input-file | FileCheck --check-prefix=GENERIC %s
// MATMUL-DAG: #[[MAP0:.*]] = affine_map<(d0) -> (-d0 + 24, 5)>
// MATMUL-DAG: #[[MAP1:.*]] = affine_map<(d0) -> (-d0 + 12, 7)>
// MATMUL-DAG: #[[MAP2:.*]] = affine_map<(d0, d1) -> (-d1 + 24, d0)>
// MATMUL-DAG: #[[MAP3:.*]] = affine_map<(d0, d1) -> (-d1 + 12, d0)>
// MATMUL: fuse_input
// MATMUL-SAME: %[[ARG0:[0-9a-zA-Z]*]]: tensor<24x12xf32>
func.func @fuse_input(%arg0: tensor<24x12xf32>,
CodeGenStrategy is actually quite complex and does multiple things at once. It is thus not easy to use and most likely will be replaced by something better in the near future. However, currently it is probably the way to go if you want to experiment with Linalg transformations.
Thanks a lot for your reply! This really solves my problem.
BTW, there are now three ways to use multiple passes (AFAIK):
chain many passes like
Are there any documents to explain the usage of
CodeGenStrategy? It seems that every pass with the name of
*-codegen-strategy-* can use it, right? Or, it is only for testing?
CodegenStrategy is an experimental tool to run a sequence of passes on a specific function / operation. AFAIK there is no documentation except for the code due to its experimental nature and I think it will soon be replaced by other solutions (for example,
[RFC] Interfaces and dialects for precise IR transformation control - #5 by nicolasvasilache). If possible, I would avoid deep diving and just use it to bridge the gap until other solutions replace it.