[LinalgExt] Refactor IGEMM detail computation and update layout decisions #24245
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 272 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.336
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #24245"
general
weight: 0.35
yzhang93
Refactors getIGEMMGenericConvDetails into three stages:
1. Build fully expanded IGEMM details where every conv loop dim maps 1:1 to an IGEMM dim (no collapsing). The image-side GEMM map is constructed following the original input tensor's layout order, with filter loop dims inserted adjacent to their corresponding input channel dims.
2. Canonicalize reduction dim labeling so their order in the loop space matches the order they appear in the image-side map, which is a prerequisite for collapsing.
3. Collapse adjacent same-kind dims that are collapsible across all indexing maps, producing the final collapsed GEMM maps, loop bounds, filter reassociation, and im2col output permutation.
This makes a few improvements over the old path:
- Better separation of concerns in the computation of the IGEMM details, because we have 3 separate phases that don't need to care what the other phases do.
- Improved reduction order for layout mismatches between image and filter (e.g.,
nhwc x nchw), because we canonicalize to the image's order, which makes vectorized loads from global memory possible in some cases where we otherwise had artificially strided access patterns.- The layout of the GEMM actually matches the layout of the convolution now. Before this PR, the layout of the im2col op's result would generally be in the "canonical" order, meaning there was an implicit transpose happening in the im2col access pattern. It is better to explicitly model this transpose in the GEMM indexing maps, where it is easier to target optimizations like transpose_load.
This refactoring will also make it easier to make a couple of follow-up changes, which will come as separate PRs:
- Redefine the classification of
BatchvsMdims in the im2col op semantics. The current definition is inconsistent with what the corresponding dims actually mean in the GEMM because convolution batch dims are actually M dims in the GEMM, but we classify them as batch in the im2col op. This will be a simple reclassification in phase 1 now.- Flatten parallel dimensions as well as reduction dimensions. This will be very simple now, since we will just need to update phase 3.