Skip to content

[AutoDiff] Mangle linear map self-reordering thunks and subset parameters thunks. #35847

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

Merged
merged 1 commit into from
Feb 13, 2021

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Feb 9, 2021

Add the following new mangling rules.

global ::= from-type to-type 'TJO' AUTODIFF-FUNCTION-KIND // autodiff self-reordering reabstraction thunk
global ::= from-type 'TJS' AUTODIFF-FUNCTION-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' INDEX-SUBSET 'P' // autodiff linear map subset parameters thunk
global ::= global to-type 'TJS' AUTODIFF-FUNCTION-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' INDEX-SUBSET 'P' // autodiff derivative function subset parameters thunk

Example:

$s13TangentVector16_Differentiation14DifferentiablePQzAaDQy_SdAFIegnnnr_TJSdSSSpSrSUSP ---> autodiff subset parameters thunk for differential from @escaping @callee_guaranteed (@in_guaranteed A._Differentiation.Differentiable.TangentVector, @in_guaranteed B._Differentiation.Differentiable.TangentVector, @in_guaranteed Swift.Double) -> (@out B._Differentiation.Differentiable.TangentVector) with respect to parameters {0, 1, 2} and results {0} to parameters {0, 2}
$sS2f8mangling3FooV13TangentVectorVIegydd_SfAESfIegydd_TJOp ---> autodiff self-reordering reabstraction thunk for pullback from @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned Swift.Float, @unowned mangling.Foo.TangentVector) to @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned mangling.Foo.TangentVector, @unowned Swift.Float)

Resolves rdar://72666310 / SR-13508.

Also fix a bug in AutoDiffFunction mangling where the original may be a global that contains more than 1 node (rdar://74151229 / SR-14106).

@rxwei
Copy link
Contributor Author

rxwei commented Feb 9, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 9, 2021

Build failed
Swift Test Linux Platform
Git Sha - 05fc0cc1a450acef241359cfcb51001361ef7f24

Copy link
Contributor

@dan-zheng dan-zheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I wonder if you've tested autodiff mangling + generic specialization mangling? I recall some bugs here (involving prespecialized functions?) [0 1 2], maybe they're relevant for thunk mangling or existing manglings.

@swift-ci
Copy link
Contributor

swift-ci commented Feb 9, 2021

Build failed
Swift Test OS X Platform
Git Sha - 05fc0cc1a450acef241359cfcb51001361ef7f24

@rxwei rxwei force-pushed the 72666310-mangle-ad-thunks branch from 05fc0cc to 1cb037f Compare February 9, 2021 19:22
@rxwei
Copy link
Contributor Author

rxwei commented Feb 9, 2021

@swift-ci please test

@rxwei
Copy link
Contributor Author

rxwei commented Feb 9, 2021

I wonder if you've tested autodiff mangling + generic specialization mangling? I recall some bugs here (involving prespecialized functions?) [0 1 2], maybe they're relevant for thunk mangling or existing manglings.

Thanks for the pointers. [2] is no longer reproducible, but I'm investigating [0] and [1].

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the de- and re-mangling changes. Basically LGTM. I just have a few comments

@rxwei rxwei force-pushed the 72666310-mangle-ad-thunks branch from 1cb037f to df1dd84 Compare February 13, 2021 09:33
@rxwei
Copy link
Contributor Author

rxwei commented Feb 13, 2021

Thanks for the pointers. [2] is no longer reproducible, but I'm investigating [0] and [1].

@dan-zheng [0] and [1] should be resolved now.

…ters thunks.

Add the following new mangling rules.
```
global ::= from-type to-type 'TJO' AUTODIFF-FUNCTION-KIND // autodiff self-reordering reabstraction thunk
global ::= from-type 'TJS' AUTODIFF-FUNCTION-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' INDEX-SUBSET 'P' // autodiff linear map subset parameters thunk
global ::= global to-type 'TJS' AUTODIFF-FUNCTION-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' INDEX-SUBSET 'P' // autodiff derivative function subset parameters thunk
```

Example:
```console
$s13TangentVector16_Differentiation14DifferentiablePQzAaDQy_SdAFIegnnnr_TJSdSSSpSrSUSP ---> autodiff subset parameters thunk for differential from @escaping @callee_guaranteed (@in_guaranteed A._Differentiation.Differentiable.TangentVector, @in_guaranteed B._Differentiation.Differentiable.TangentVector, @in_guaranteed Swift.Double) -> (@out B._Differentiation.Differentiable.TangentVector) with respect to parameters {0, 1, 2} and results {0} to parameters {0, 2}
$sS2f8mangling3FooV13TangentVectorVIegydd_SfAESfIegydd_TJOp ---> autodiff self-reordering reabstraction thunk for pullback from @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned Swift.Float, @unowned mangling.Foo.TangentVector) to @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned mangling.Foo.TangentVector, @unowned Swift.Float)
```

Resolves rdar://72666310 / SR-13508.

Also fix a bug in `AutoDiffFunction` mangling where the original may be a global that contains more than 1 node (rdar://74151229 / SR-14106).
@rxwei rxwei force-pushed the 72666310-mangle-ad-thunks branch from df1dd84 to f9ddecf Compare February 13, 2021 09:38
@rxwei
Copy link
Contributor Author

rxwei commented Feb 13, 2021

@swift-ci please test and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants