Skip to content

[AutoDiff] switch array and floating point derivatives to @derivative(of:) #29030

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
Jan 7, 2020

Conversation

marcrasi
Copy link

@marcrasi marcrasi commented Jan 6, 2020

Also I added a test for the FloatingPoint.swift derivatives because there isn't an existing test for them.

Once this and #28933 are merged, there will be no more vjp:s in the stdlib.

@marcrasi marcrasi requested review from rxwei and dan-zheng January 6, 2020 23:16
Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

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

Nice!

Minor comment: The title initially came across as "removing VJPs from stdlib", and I only realized it's removing @differentiable(vjp: ...)s when I looked at the diff. How about rewording the PR title to something like "[AutoDiff] Switch to '@Derivative(of:)' for array and floating point derivative registrations"?

@marcrasi marcrasi changed the title [AutoDiff] remove vjp:s from stdlib Array.swift and FloatingPoint.swift [AutoDiff] switch array and floating point derivatives to @derivative(of:) Jan 6, 2020
@marcrasi
Copy link
Author

marcrasi commented Jan 6, 2020

@swift-ci please test tensorflow

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.

Is it (or will it eventually be) necessary to keep @differentiable attributes on the public original functions so that the derivatives are registered with public access?


We discussed this as part of derivative visibility. Currently, derivative visibility is equal to the access level of the @derivative declaration, but we could potentially decouple it (e.g. by adding syntax like @derivative(of: foo, access: public)).

@rxwei
Copy link
Contributor

rxwei commented Jan 6, 2020

We discussed this and preferred making the derivative registration have the same visibility as the derivative function. The only thing that's preventing this is the fact that we do not yet support anonymous function declarations (with func _) and do not want to export named functions as public symbols.

The current code pattern (as it is in the library) will likely not compile in the final design, because when @differentiable is put on a public declaration, it cannot be satisfied with an internal @derivative(of:) registration.

@marcrasi marcrasi force-pushed the remove-remaining-vjp branch from 76bdf43 to 0cd6e2a Compare January 7, 2020 00:00
@marcrasi
Copy link
Author

marcrasi commented Jan 7, 2020

@swift-ci please test tensorflow

4 similar comments
@marcrasi
Copy link
Author

marcrasi commented Jan 7, 2020

@swift-ci please test tensorflow

@marcrasi
Copy link
Author

marcrasi commented Jan 7, 2020

@swift-ci please test tensorflow

@marcrasi
Copy link
Author

marcrasi commented Jan 7, 2020

@swift-ci please test tensorflow

@marcrasi
Copy link
Author

marcrasi commented Jan 7, 2020

@swift-ci please test tensorflow

@marcrasi marcrasi merged commit df399e7 into swiftlang:tensorflow Jan 7, 2020
@marcrasi marcrasi deleted the remove-remaining-vjp branch January 7, 2020 19:59
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.

3 participants