Repository navigation
BroadcastIota: only fold when the broadcast keeps the iota's extent - #3410
Merged
Merged
Conversation
broadcast_in_dim of an iota is an iota of the result along the mapped dimension only if that dimension keeps its size. An iota dimension of size 1 holds a single 0 that the broadcast repeats; folding it into an iota of the larger result counts 0, 1, ... instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3410 +/- ##
=======================================
Coverage 29.61% 29.62%
=======================================
Files 240 240
Lines 48460 48474 +14
=======================================
+ Hits 14351 14359 +8
- Misses 34109 34115 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
BroadcastIotafoldsbroadcast_in_dim(iota)into an iota of the result along the mapped dimension. That is only right when the broadcast leaves that dimension's size unchanged. If the iota dimension has size 1, the operand is all zeros and the broadcast repeats that 0. The fold instead produces 0, 1, 2, ….On main,
%1becomes[[0,0,0,0],[1,1,1,1],[2,2,2,2]]; it should be all zeros. The pattern now requires the iota dimension to keep its extent. The new case inbroadcastiota.mlirfolds the zero away.This came up as a miscompile in the MFEM quadrature-interpolator kernels (
Derivatives2Dwithvdim = 1) under the exec-time transform pattern list:broadcastindim_licmhoists a broadcast of the trip-1vdimloop's induction variable out of the inner loop.greedy_while_loop_batch_fissionbatches it as an iota of extent 1.enzyme_hlo_unroll(1)unrolls the trip-1 loop.broadcast_iotaturns the repeated 0 into0, 1, so the store index adds the inner index twice.With this change the runtime's full exec pipeline gives the same values as the unoptimized module. The whole lit suite has no new failures.
🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD