-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[AutoDiff upstream] Add @derivative(of:)
attribute.
#28321
[AutoDiff upstream] Add @derivative(of:)
attribute.
#28321
Conversation
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.
LGTM with a few changes, thanks!
…utes. In the code review for #28321, the main developers of AutoDiff agreed to rename `@differentiating` and `@transposing` to `@derivative(of:)` and `@transpose(of:)`, respectively. This PR updates the manifesto to reflect this change.
Rename `@differentiating` to `@derivative(of:)`. `@derivative(of:)` more clearly evokes derivative registration; the syntax is otherwise unchanged. Deprecate `@differentiating`, to be removed in the next release. Discussed here: swiftlang#28321 (comment) Partially resolves TF-999. TF-1000 tracks updating all `@differentiating` usages across repositories.
Rename `@differentiating` to `@derivative(of:)`. `@derivative(of:)` more clearly evokes derivative registration; the syntax is otherwise unchanged. Deprecate `@differentiating`, to be removed in the next release. Discussed here: #28321 (comment). Partially resolves TF-999. TF-1000 tracks updating all `@differentiating` usages across repositories. --- Confirmed via `grep -nr differentiating include lib stdlib test` that all remaining occurrences are intended. --- Example: ```swift extension Float { @Derivative(of: +) static func vjpAdd(lhs: Self, rhs: Self) -> (value: Self, pullback: (Self) -> (Self, Self)) { (lhs + rhs, { v in (v, v) }) } } ```
Rename `@transposing` to `@transpose(of:)` and deprecate `@transposing`. `@transpose(of:)` more clearly evokes transpose registration; the syntax is otherwise unchanged. Discussed here: swiftlang#28321 (comment) Resolves TF-992. TF-999 tracks removing `@transposing` attribute in the next release. TF-1009 tracks `@transpose` syntax support for qualified names.
Rename `@transposing` to `@transpose(of:)`. `@transpose(of:)` more clearly evokes transpose registration; the syntax is otherwise unchanged. Discussed here: #28321 (comment) Remove `@transposing`. Removal without deprecation should be fine because there are no known users of `@transposing` attribute. Resolves TF-992. TF-1009 tracks `@transpose` syntax support for qualified names.
4b9f025
to
9acdfba
Compare
@differentiating
attribute.@derivative(of:)
attribute.
I addressed all comments and rebased onto master. There are no major changes: the biggest syntax change is renaming |
…ibute. Update gyb-generated files for `@derivative` attribute. Friend PR: swiftlang/swift#28321
Update gyb-generated files for `@derivative` attribute. Friend PR: swiftlang/swift#28321
9acdfba
to
03ae118
Compare
The `@derivative(of:)` attribute registers a function as a derivative of another function. This patch adds the `@derivative(of:)` attribute definition, syntax, parsing, and printing. Resolves TF-826. Todos: - Type-checking (TF-829). - Serialization (TF-837).
03ae118
to
48e3b47
Compare
swiftlang/swift-syntax#188 |
Build failed |
Build failed |
Merging since there are no major changes since the last approval and CI has passed. |
Minor style fixes and gardening. Change code to be closer to master after #28321.
Update gyb-generated files for `@derivative` attribute. Friend PR: swiftlang/swift#28321
The
@derivative(of:)
attribute registers a function as a derivative of another function.This patch adds the
@derivative(of:)
attribute definition, syntax, parsing, and printing.Resolves TF-826.
Todos: