scf.for fix when iter-args and result args have shadow mismatch in fwd#2750
Draft
spikerheado1234 wants to merge 1 commit intomainfrom
Draft
scf.for fix when iter-args and result args have shadow mismatch in fwd#2750spikerheado1234 wants to merge 1 commit intomainfrom
spikerheado1234 wants to merge 1 commit intomainfrom
Conversation
wsmoses
reviewed
Mar 18, 2026
| llvm::enumerate(targetValues, operandRange)) { | ||
| if (gutils->isConstantValue(regionValue)) | ||
| bool iterArgActive = !gutils->isConstantValue(regionValue); | ||
| bool resultActive = i < op->getNumResults() && |
Member
There was a problem hiding this comment.
this isn't generally correct since an input operand doesn't necessarily correspond to the outputs as here.
Instead really you need to construct this correctly [and separately] for scf for, or with an interface -- and pass said array to the general controlFlowForwardHandler which accepts arrays
wsmoses
reviewed
Mar 18, 2026
| // | ||
| // We also register the mapping in invertedPointers so that invertPointerM, | ||
| // which checks invertedPointers before isConstantValue, returns the shadow | ||
| // block arg instead of zero when body ops reference this iter arg. |
Member
There was a problem hiding this comment.
this should be handled in createWithShadows, not here
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.
In forward mode AD, if an iter-arg is deemed a constant, yet its corresponding result has a tangent, then there will be a mismatch between the number of iter-args and result-args. This PR fixes that by unioning if either an iter-arg or its corresponding result is active, inserting a corresponding shadow arg if at least one is active.