-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Fix PullbackCloner
tangent value category mismatch crash
#33512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2431,7 +2431,7 @@ bool PullbackCloner::Implementation::runForSemanticMemberGetter() { | |
|
||
// Switch based on the base tangent struct's value category. | ||
// TODO(TF-1255): Simplify using unified adjoint value data structure. | ||
switch (tangentVectorSILTy.getCategory()) { | ||
switch (getTangentValueCategory(origSelf)) { | ||
case SILValueCategory::Object: { | ||
auto adjResult = getAdjointValue(origEntry, origResult); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: hypothetically, there may be a similar "tangent value category mismatch" hole on this line where I can't think of a trigger for this in practice (semantic member getter pullback generation for |
||
switch (adjResult.getKind()) { | ||
|
@@ -2472,7 +2472,7 @@ bool PullbackCloner::Implementation::runForSemanticMemberGetter() { | |
if (field == tanField) { | ||
// Switch based on the property's value category. | ||
// TODO(TF-1255): Simplify using unified adjoint value data structure. | ||
switch (origResult->getType().getCategory()) { | ||
switch (getTangentValueCategory(origResult)) { | ||
case SILValueCategory::Object: { | ||
auto adjResult = getAdjointValue(origEntry, origResult); | ||
auto adjResultValue = materializeAdjointDirect(adjResult, pbLoc); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %target-build-swift %s | ||
// REQUIRES: asserts | ||
|
||
// SR-13411: Semantic member getter pullback generation crash due to tangent value category mismatch | ||
|
||
import _Differentiation | ||
|
||
struct Dense: Differentiable { | ||
@differentiable | ||
var bias: Float? | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we could make this logic handle all
ResultConvention
cases.But with this change, the three common
ResultConvention
cases are all handed (Unowned
,Owned
,Indirect
). I haven't seen the other cases (UnownedInnerPointer
,Autoreleased
) appear in practice.