-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Mangle derivative functions and linear maps #35259
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
Conversation
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.
Nice!
769d91c
to
d0ec736
Compare
@swift-ci please test |
d0ec736
to
3b65e15
Compare
@swift-ci please smoke test |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke test |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
@swift-ci please test linux |
Build failed |
Build failed |
3b65e15
to
6e1df19
Compare
@swift-ci please test |
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.
Basically LGTM. But I have a few comments.
Two general comments:
-
Can you add tests to test/Demangle/Inputs/manglings.txt?
-
It's good that you split such a large PR into multiple commits. But ideally each commit should be self-contained, i.e. each commit should contain a good commit message and the project should be compilable after each commit, and ideally the tests should pass. This makes it easier to understand "git log" and it enables "git bisect".
Your commit messages "Make compile" and "Fix all tests" suggest that this is not the case here.
c1858a3
to
72b165a
Compare
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen. - `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature. A mangled differentiation function name includes: - The original function. - The differentiation function kind. - The parameter indices for differentiation. - The result indices for differentiation. - The derivative generic signature.
72b165a
to
ffe6064
Compare
Sorry, the commit log in the PR may appear confusing, but I did not intend to merge these commits as is. My intention is to keep the original WIP commit by @dan-zheng to acknowledge his original contribution in the PR. When I merge I always use squash-and-merge, so only one commit will go into the tree. Nonetheless, I have squashed those commits. |
@swift-ci please test |
Build failed |
@swift-ci please test linux |
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.
Thanks, LGTM!
Mangle derivative functions and linear maps.
Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()
andMangle::ASTMangler::mangleAutoDiffLinearMap()
accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen.Mangle::DifferentiationMangler
handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature.A mangled differentiation function name includes:
Example:
Also:
Resolves SR-13507.