Skip to content

[CPU] Switch lowering config to dictionary-based attribute #21297

Closed

Description

@hanhanW

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.

/// 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.

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

  1. self-assigned this
    on Jul 8, 2025
  2. added
    codegen/llvm
    on Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

codegen/llvm

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions