Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Transform][Fusion] Introduce an iterative tiling and fusion pass in forward and backward fashion #87

Merged
merged 15 commits into from
Aug 5, 2024
Merged
32 changes: 32 additions & 0 deletions include/gc/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,36 @@ def LinalgToXeGPU : Pass<"linalg-to-xegpu", "func::FuncOp"> {
];
}

def IterativeTilingAndFusion : Pass<"iterative-tiling-and-fusion",
"func::FuncOp"> {
let summary = "Iterative tiling and fusion for any tilable operation";
let description = [{
The pass tries to fuse any MLIR operation which can be tiled. Moreover, this pass aims to support:
1. Matmul fusion with element-wise/reduce/broadcast ops.
2. Pre-op and post-op fusion.
3. Multi-consumer and multi-producer support.
4. Multiple level of nest loops and candidates.
5. Flexible option to control the boundary of iterative process.
6. Cost-model to determine whether to fuse or not.

It intends to control the granularity of fusion by `fusion-level`, E.g.
* `0`: disable any fusion.
* `1`:[Default] enable both producer and consumer fusion, covering any tilable operation including tensor.pack/tensor.fill/linalg.reduce etc but excluding branches forked by multiple uses.
* `2`: `LEVEL 1` + extend to any topology including branches.
}];
let dependentDialects = ["func::FuncDialect", "linalg::LinalgDialect", "scf::SCFDialect",
"tensor::TensorDialect"];

let options = [
Option<"fusionLevel", "fusion-level", "int64_t",
/*default=*/"1",
"Control the granularity of fusion.">,
Option<"useCostModel", "use-cost-model", "bool",
/*default=*/"false",
"Decide if enable cost model to control iterative fusion.">,
ListOption<"defaultTileSize", "default-tile-size", "std::string",
"Set default TileSize for the certain type of op, saying matmul:{32,32}">,
];
}

#endif // GC_DIALECT_GC_PASSES
2 changes: 2 additions & 0 deletions lib/gc/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ add_mlir_library(GCPasses
OneDNNGraphToLinalg.cpp
Pipeline.cpp
TileNamed.cpp
IterativeTilingAndFusion.cpp
TilingUsingInterfaceX.cpp

ADDITIONAL_HEADER_DIRS
${PROJECT_SOURCE_DIR}/include
Expand Down
Loading