[AutoDiff] Create JVPEmitter#25954
Merged
rxwei merged 31 commits intoswiftlang:tensorflowfrom Jul 10, 2019
Merged
Conversation
) (swiftlang#25778) Xcode puts the bin/ and lib/ directories in a subdirectory based on configuration; account for this when copying over compiler-rt for non-host Apple platforms using one of the existing helpers in build-script-impl.
`PointwiseMultiplicative` represents a ring over multiplication with identity element "one" and a multiplicative inverse (reciprocal). Conform `Differentiable` synthesized struct types to `PointwiseMultiplicative` protocol if possible. Enables revamping optimizers, which requires division (i.e. multiplication with multiplicative inverse).
…swiftlang#25803) Partial fix for `@differentiable` function thunk with output opaque abstraction pattern. Avoid `AbstractionPattern` methods that crash for opaque patterns. Small step towards fixing TF-123. Reproducers no longer crash, SIL verification fails instead. Robust fix requires more work - see TF-123 for more details.
tensorflow/swift-apis@60f63e1 `Tensor` now conforms to `PointwiseMultiplicative`.
a56c4cc to
349db72
Compare
f4067ea to
b7343a2
Compare
…wiftlang#25967) In VJPEmitter, if the original function call has substitutions, we `partial_apply` it with no arguments to specialize it. This `partial_apply` is not being released. JVP and VJP are being specialized the same way, but they are not being released either. To fix this, we release the `@differentiable` function returned by `autodiff_function`, which will release the original and the associated functions tht are to be filled in later altogether. If the original function does not have substitutions, we retain the original function to balance out the release of the `@differentiable` function that comes later. As a result, `ADContext::promoteToDifferentiableFunction` no longer needs to retain the associated functions. Example where the original function has substitutions: ``` f' = partial_apply f<...>() f_diff = autodiff_function f' release_value f_diff ``` Example where the original function does not have substitutions: ``` retain_value f f_diff = autodiff_function f release_value f_diff ``` Note: This makes the `autodiff_function` folding optimization no longer able to detect the pattern, but it is necessary. We can rewrite the optimization later. This should fix [TF-621](https://bugs.swift.org/browse/TF-621).
bartchr808
commented
Jul 9, 2019
| } | ||
|
|
||
| static SILFunction* createJVP( | ||
| static SILFunction *createEmptyVJP( |
Contributor
Author
There was a problem hiding this comment.
The git diff here is acting funny in the next several lines, may be hard to follow but I more so made a copy of createEmptyVJP and named it createEmptyJVP and removed the previous createJVP to more closely resemble how VJPEmitter looks like and JVPEmitter will become.
Contributor
Author
|
@swift-ci please test tensorflow |
rxwei
reviewed
Jul 9, 2019
Contributor
Author
|
@swift-ci please test tensorflow |
rxwei
approved these changes
Jul 10, 2019
Contributor
Author
|
@swift-ci please test tensorflow |
2 similar comments
Contributor
Author
|
@swift-ci please test tensorflow |
Contributor
Author
|
@swift-ci please test tensorflow |
bartchr808
added a commit
that referenced
this pull request
Aug 20, 2019
This PR extends on the previous work here on the `JVPEmitter` (#25954) to make it be able to generate SIL code for the `differential` function, as well as more correctly implementing the body of the JVP.' generates a valid JVP and differential. I have yet to add support for control flow and generics. This PR also renames `PullbackInfo` to `LinearMap` info since it has a lot of tangent mapping helpers that `JVPEmitter` can use when creating the differential. This is still early, so the JVP/Differential emission only runs with the flag `-Xllvm -run-jvp-generation` when running Swift. With it, you can differentiate basic Float functions with `+ - / *` with no `var`s
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
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.
Creates a very barebones
JVPEmitterwhich copies the body of the original function returning(original, undef), and creates the differential function with a body that returns anundef.Apologies for the weird commit history, there was something wrong with my
tensorflowbranch on the fork of this repo that caused this. However, I fixed it now so future PRs won't be this ugly.