Repository navigation
Description
The CPU pipelines are using default lowering config, and it is not flexible enough for rootOp based pipelines. Initially, we are considering to introduce isRootOp interface method. However, it is over-designed to me after thinking more. The root op essentially ties to an op that has distribution tiling config. Having a single op that has lowering_config was the assumption for root ops, but it is not the fact in CPU backends. Because there are cases that not all the dimensions are captured by the root op. E.g., reduction -> broadcast. This is why we have VectorInnerParallelTiles in TilingConfig which is only used by CPU atm.
iree/compiler/src/iree/compiler/Codegen/Common/TileSizeSelection.h
Lines 151 to 162 in 3e99b2b
| /// Internal representation for all the supported tiling levels. All or just | |
| /// a subset of them may be available in a valid configuration. | |
| enum TilingLevel : unsigned { | |
| DistributionTiles = 0, | |
| CacheParallelTiles = 1, | |
| CacheReductionTiles = 2, | |
| VectorCommonParallelTiles = 3, | |
| VectorReductionTiles = 4, | |
| VectorInnerParallelTiles = 5, | |
| MaxNumTileLevels = 6, | |
| InvalidLevel = 7, | |
| }; |
A better solution is creating a dictionary-based attribute in CPU dialect and use it everywhere. Currently, there are four tile size lists in most of CPU pipeline: distribution, vector-common-parallel, vector-reduction, and vector-inner-parallel.
We can set all the fields for the root op, and the only set the inner-parallel field to the ops that have parallel dimensions that are not captured by the root op.
We can use hasWorkgroupTilingLevel to determine if an op is a root op or not. Furthermore, if we pass the TilingLevel to the passes, the passes can start with the op that has the field. This allows more controls and makes the root-op based pipeline migrations easier. E.g., you can set all the fields except vector-inner-parallel to the rootOp and only set vector-inner-parallel field to the broadcast or pack ops based on which op should be the start op in the tile and fuse.
Based on my prototype, it is not easy to make a single PR that switches all the pipeline to use the new attribute, because currently the scalable tile sizes logic locates at setOpConfigAndEntryPointFnTranslation. It is easier to do the migration incrementally as not all the pipelines are able to be rootOp based pipeline atm.
iree/compiler/src/iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h
Lines 178 to 192 in 3e99b2b
| inline LogicalResult setOpConfigAndEntryPointFnTranslation( | |
| mlir::FunctionOpInterface entryPointFn, Operation *op, | |
| TileSizesListTypeRef tileSizes, | |
| ScalableTileFlagsListTypeRef scalableTileFlags, | |
| IREE::Codegen::DispatchLoweringPassPipeline passPipeline, | |
| ArrayRef<int64_t> workgroupSize = {}, | |
| std::optional<int64_t> subgroupSize = {}, | |
| DictionaryAttr pipelineConfig = DictionaryAttr()) { | |
| MLIRContext *context = entryPointFn.getContext(); | |
| auto config = IREE::Codegen::LoweringConfigAttr::get(context, tileSizes, | |
| scalableTileFlags); | |
| return setOpConfigAndEntryPointFnTranslation(entryPointFn, op, config, | |
| passPipeline, workgroupSize, | |
| subgroupSize, pipelineConfig); | |
| } |
Activity
[CPU] Disable lowering_config propagation for Mmt4dTilingExpert pipel…
[CPU] Introduce dictionary-based lowering_config attribute. (#21312)
[CodeGen][NFC] Retire native_vector_sizes from LoweringConfigAttr. (#…
[CodeGen] Make TilingConfig compatible with LoweringConfigAttrInterfa…
[CPU] Use TilingConfig for lowering_config propagation. (#21336)
[CPU] Implement lowering_config propagation for IREE::CPU::LoweringCo…
[CPU] Switch convolution pipelines to IREE::CPU::LoweringConfigAttr. (#…
[CPU][NFC] Switch existing tests to use IREE::CPU::LoweringConfig. (i…
[CPU][NFC] Switch existing tests to use IREE::CPU::LoweringConfig. (i…
[CPU] Disable lowering_config propagation for Mmt4dTilingExpert pipel…
[CPU] Introduce dictionary-based lowering_config attribute. (#21312)
[CodeGen][NFC] Retire native_vector_sizes from LoweringConfigAttr. (#…
[CodeGen] Make TilingConfig compatible with LoweringConfigAttrInterfa…
[CPU] Use TilingConfig for lowering_config propagation. (#21336)
[CPU] Implement lowering_config propagation for IREE::CPU::LoweringCo…
[CPU] Switch convolution pipelines to IREE::CPU::LoweringConfigAttr. (#…
[CPU][NFC] Switch existing tests to use IREE::CPU::LoweringConfig. (#…