-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Store original declaration in DifferentiableAttr
.
#27985
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
[AutoDiff] Store original declaration in DifferentiableAttr
.
#27985
Conversation
This fails locally during stdlib compilation with a nondescript error:
Triggering tests to see if the issue is reproducible. |
@swift-ci Please test tensorflow |
|
||
FuncDecl *originalDecl = cast<FuncDecl>(MF.getDecl(originalDeclId)); |
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.
The issue is this line causes an infinite loop: we cannot deserialize the original declaration here because @differentiable
attributes are deserialized as part of deserializing the original declaration.
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.
Fixed in 4df0307 via ad-hoc deserialization logic. I couldn't think of a better solution.
Store original `AbstractFunctionDecl` in `DifferentiableAttr`. This is important for requestifying `DifferentiableAttr->getParameterIndices()`: we want the ability to resolve parameter indices without needing to pass the original `AbstractFunctionDecl` to `getParameterIndices`.
Deserializing the original declaration DeclID in `@differentiable` attributes does not work because it causes `@differentiable` attribute deserialization to enter an infinite loop. Instead, use ad-hoc deserialization logic to set the original declaration in `@differentiable` attributes. Add round-trip `@differentiable` attribute AST serialization test. `@differentiable` attribute serialization asserts that the original declaration is set.
93ce245
to
4df0307
Compare
Triggering extended test suite ( |
Extended test suite failed while building
Please hold off on merging; more changes are necessary to support requestifying |
Store original declaration `Decl *` in `DifferentiableAttr` instead of casting to `AbstractFunctionDecl *`. This helps ensure that the original declaration is set.
0c62032
to
e2be0a2
Compare
4415f95
to
12bd568
Compare
@swift-ci Please test tensorflow |
Confirmed that extended test suite has passed. |
Store original declaration
Decl *
inDifferentiableAttr
.This is important for requestifying
DifferentiableAttr->getParameterIndices()
: we want the ability toresolve parameter indices without needing to pass the original
AbstractFunctionDecl
togetParameterIndices
.Add round-trip
@differentiable
attribute AST serialization test.@differentiable
attribute type-checking and serialization assertthat the original declaration is set.
A step towards unblocking the
swift-DEVELOPMENT-SNAPSHOT-2019-10-24-a
merge.