[Frontend] Remove the dead convert_index floor/mod codegen path#271
Open
YWHyuk wants to merge 1 commit into
Open
[Frontend] Remove the dead convert_index floor/mod codegen path#271YWHyuk wants to merge 1 commit into
YWHyuk wants to merge 1 commit into
Conversation
95f127e to
f4ac374
Compare
9b913d4 to
4767e8a
Compare
f4ac374 to
b16b2d8
Compare
b7c1ec4 to
9033945
Compare
axis-split's affine-only contract (docs/axis-split-scheduling.md) linearizes aligned FloorDiv/ModularIndexing into per-axis affine indices upstream, so the load/store index reaching codegen is already pure affine. The convert_index method (which lowered floor/mod view indices to affine.apply with a constant divisor and a single free symbol) and the helper that guarded it are therefore dead -- a tripwire at every floor/mod branch never fired across the view/op test suite. Remove convert_index entirely and inline its only live behaviour at the call sites in _convert_sympy_to_mlir_expr and parse_index_list. A residual FloorDiv/ModularIndexing now fails loudly via the whole-expression guard in each of those functions (mirroring the DMA-index assert) instead of silently mis-lowering. Also drop the assumption-stripping Symbol(str(...)) + expr.replace round-trip in the affine-map builder: it only mattered when convert_index transformed the term, and is now a verified no-op (indices and the affine string depend only on symbol names). Drop the now-unused re import. Verified: the full view/reshape/transpose suite (test_floormod_axis_split incl. group_norm/repeat/repeat_interleave/mixed-radix/pixel_shuffle, transpose2D/3D, view3D_2D, cat) plus add/matmul/reduce/softmax/layernorm/batchnorm pass unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SfwHCV7TaX4s9xkn8i7anG
b16b2d8 to
aae710a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The load/store affine-index path (
convert_indexand_convert_sympy_to_mlir_exprinPyTorchSimFrontend/mlir/mlir_codegen_backend.py) used to lowerFloorDiv/ModularIndexingsub-expressions (view/reshape/transpose indices) intoaffine.applymaps with a constant divisor and a single free symbol.This is superseded by axis-split's affine-only contract:
axis_split.pystripsFloorDiv/ModularIndexingfrom index expressions upstream at the Inductor scheduling layer (seedocs/axis-split-scheduling.md), so MLIR codegen now only ever receives pure affine, constant-stride indices. The DMA-index path already asserts this.Verification
A temporary tripwire (
raise RuntimeError) placed at the entry of both floor/mod handlers (theModularIndexing///branches ofconvert_index, and theModularIndexing/FloorDivbranches of_convert_sympy_to_mlir_expr) never fired across:test_floormod_axis_split(group_normc//(C/G), repeat mod, repeat_interleave floor),test_transpose2D,test_transpose3D,test_view3D_2D,test_cattest_add,test_matmul,test_reduce,test_softmax,test_layernorm,test_batchnorm,test_conv2dconfirming the floor/mod codegen path is dead.
Change
Remove the floor/mod lowering branches. Mirroring the existing DMA-index assert, replace them with a clear
NotImplementedErrorso any residual floor/mod that escapes axis-split fails loudly instead of being silently mis-lowered. The now-unusedreimport is dropped.The full view/op test suite passes unchanged (allclose) after removal.
🤖 Generated with Claude Code