Skip to content

[AutoDiff] Add differentiability_witness_function instruction. #27719

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 3 commits into from
Oct 17, 2019

Conversation

dan-zheng
Copy link
Contributor

@dan-zheng dan-zheng commented Oct 16, 2019

differentiability_witness_function looks up a differentiability witness
function (JVP, VJP, or transpose) for a referenced function using SIL
differentiability witnesses.

sil [ossa] @generic : $@convention(thin) <T> (@in_guaranteed T, Float) -> @out T

sil @test_derivative_witnesses : $... {
  %vjp = differentiability_witness_function [vjp] [parameters 0 1] [results 0] <T where T: Differentiable, T == T.TangentVector> @generic : $@convention(thin) <T> (@in_guaranteed T, Float) -> @out T
}

The differentiability witness function kind identifies the witness function to
look up: [jvp], [vjp], or [transpose].

The remaining components identify the SIL differentiability witness:

  • Original function name.
  • Parameter indices.
  • Result indices.
  • Witness generic signature (optional). When parsing SIL, the parsed witness
    generic signature is combined with the original function's generic signature
    to form the full witness generic signature.

Known caveats:

  • It may be problematic for SIL instructions like DifferentiabilityWitnessFunctionInst to store a SILFunction * pointer to the original function because SILFunction has special reference counting logic: see SILInstruction::dropAllReferences.
  • It may be desirable to change the design of DifferentiabilityWitnessFunctionInst to directly store a SILDifferentiabilityWitness * pointer, or store the original function name and type. Deferring exploration until changes become necessary or the right design becomes evident.

The TF-866 master issue tracks all retroactive derivative registration tasks.

@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label Oct 16, 2019
@dan-zheng dan-zheng mentioned this pull request Oct 16, 2019
@dan-zheng dan-zheng force-pushed the diff-witness-func-inst branch 3 times, most recently from 5e4ea84 to 6c3e758 Compare October 17, 2019 02:57
@dan-zheng dan-zheng marked this pull request as ready for review October 17, 2019 03:03
@dan-zheng dan-zheng requested a review from rxwei October 17, 2019 03:03
`differentiability_witness_function` looks up a differentiability witness
function (JVP, VJP, or transpose) for a referenced function using SIL
differentiability witnesses.
@dan-zheng dan-zheng force-pushed the diff-witness-func-inst branch from 6c3e758 to 0e5c3e5 Compare October 17, 2019 03:09
Simplify SIL instruction syntax in SIL.rst.
@dan-zheng dan-zheng force-pushed the diff-witness-func-inst branch from 0db4e27 to cb30eb7 Compare October 17, 2019 03:48
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng dan-zheng merged commit 4ebb910 into swiftlang:tensorflow Oct 17, 2019
@dan-zheng dan-zheng deleted the diff-witness-func-inst branch October 17, 2019 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants