-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Add builtin differentiable/linear function consturctors. #28467
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dan-zheng
approved these changes
Nov 24, 2019
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!
@swift-ci please test tensorflow |
…ntiable(linear)` function from component functons. * `Builtin.differentiableFunction_*` Takes an original function, a JVP function and a VJP function and returns a `@differentiable` function. Pseudo-declaration: ```swift func differentiableFunction_arity{arity}[_throws]?{throws}<T...{arity}, U>( _ original: __owned @escaping (T...{arity}) {throws}? -> U, _ jvp: __owned @escaping (T...{arity}) {throws}? -> (value: U, differential: (T.TangentVector...{arity}) -> U.TangentVector), _ vjp: __owned @escaping (T...{arity}) {throws}? -> (value: U, pullback: (U.TangentVector) -> (T.TangentVector...{arity})) ) -> @differentiable (T...{arity}) {throws}? -> U where T...{arity} : Differentiable, U : Differentiable ``` * `Builtin.linearFunction_*` Takes an original function and a transpose function and returns a `@differentiable` function. Pseudo-declaration: ```swift func linearFunction_arity{arity}[_throws]?{throws}<T...{arity}, U>( _ original: __owned @escaping (T...{arity}) {throws}? -> U, _ transpose: __owned @escaping (U.TangentVector) {throws}? -> (T.TangentVector...{arity}) ) -> @differentiable (T...{arity}) {throws}? -> U where T...{arity} : Differentiable & AdditiveArithmetic, U : Differentiable & AdditiveArithmetic ``` These builtins will be used to write unit tests for `@differentiable` and `@differentiable(linear)` function types that do not necessarily depend on the differentiation transform. TODO: - SR-11848: For robustness, we need SIL FileCheck tests for all AD builtins. These have not been added for `Builtin.autodiffApply*`, so I'm leaving this as a future task. - SR-11847: Update `differentiableFunction(from:)` to use `Builtin.differentiableFunction*` in its implementation. - SR-11849: Disallow non-top-level derivative registration. Resolves SR-11846.
@swift-ci please test tensorflow |
rxwei
added a commit
to rxwei/swift
that referenced
this pull request
Nov 25, 2019
…le function constructor builtins. This PR updates `differentiableFunction(from:)` to use differentiable function constructor builtins added in swiftlang#28467. The standard library no longer has non-top-level derivative registration. Resolves SR-11847. Unblocks SR-11849.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add builtin functions that construct a
@differentiable
or@differentiable(linear)
function from component functons.Builtin.differentiableFunction_*
Takes an original function, a JVP function and a VJP function and returns a
@differentiable
function.Pseudo-declaration:
Builtin.linearFunction_*
Takes an original function and a transpose function and returns a
@differentiable
function.Pseudo-declaration:
These builtins will be used to write unit tests for
@differentiable
and@differentiable(linear)
function types that do not necessarily depend on the differentiation transform.TODO:
Builtin.autodiffApply*
, so I'm leaving this as a future task.differentiableFunction(from:)
to useBuiltin.differentiableFunction*
in its implementation.Resolves SR-11846.