Skip to content

[AutoDiff upstream] Serialize derivative function configurations. #30672

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

Conversation

dan-zheng
Copy link
Contributor

Serialize derivative function configurations per module.

@differentiable and @derivative attributes register derivatives for
AbstractFunctionDecls for a particular "derivative function configuration":
parameter indices and dervative generic signature.

To find @derivative functions registered in other Swift modules, derivative
function configurations must be serialized per module. When configurations for
a AbstractFunctionDecl are requested, all configurations from imported
modules are deserialized. This module serialization technique has precedent: it
is used for protocol conformances (e.g. extension declarations for a nominal
type) and Obj-C members for a class type.

Add AbstractFunctionDecl::getDerivativeFunctionConfigurations entry point
for accessing derivative function configurations.

In the differentiation transform: use
AbstractFunctionDecl::getDerivativeFunctionConfigurations to implement
findMinimalDerivativeConfiguration for canonical derivative function
configuration lookup, replacing getMinimalASTDifferentiableAttr.

Resolves TF-1100.


Upstreams #28608 from tensorflow branch.
Tests will be added when the differentiation transform is upstreamed: TF-1211.

Serialize derivative function configurations per module.

`@differentiable` and `@derivative` attributes register derivatives for
`AbstractFunctionDecl`s for a particular "derivative function configuration":
parameter indices and dervative generic signature.

To find `@derivative` functions registered in other Swift modules, derivative
function configurations must be serialized per module. When configurations for
a `AbstractFunctionDecl` are requested, all configurations from imported
modules are deserialized. This module serialization technique has precedent: it
is used for protocol conformances (e.g. extension declarations for a nominal
type) and Obj-C members for a class type.

Add `AbstractFunctionDecl::getDerivativeFunctionConfigurations` entry point
for accessing derivative function configurations.

In the differentiation transform: use
`AbstractFunctionDecl::getDerivativeFunctionConfigurations` to implement
`findMinimalDerivativeConfiguration` for canonical derivative function
configuration lookup, replacing `getMinimalASTDifferentiableAttr`.

Resolves TF-1100.
@dan-zheng dan-zheng requested review from rxwei, CodaFi and marcrasi March 27, 2020 08:10
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

@dan-zheng
Copy link
Contributor Author

Linux CI flaked.
@swift-ci Please smoke test Linux

@dan-zheng dan-zheng merged commit 2831548 into swiftlang:master Mar 27, 2020
@dan-zheng dan-zheng deleted the serialized-derivative-configurations branch March 27, 2020 13:40
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.

2 participants