Skip to content
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

[SR-13151] Reliably show expected derivative type in @derivative type-checking diagnostics #55104

Open
dan-zheng opened this issue Apr 23, 2020 · 0 comments

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-13151
Radar None
Original Reporter @dan-zheng
Type Sub-task
Additional Detail from JIRA
Votes 0
Component/s
Labels Sub-task
Assignee None
Priority Medium

md5: f88754cc076ca8599227af088003d5d6

Parent-Task:

  • SR-13149 @derivative and @transpose type-checking diagnostic improvements

Issue Description:

It's not always obvious what should be the type of a custom derivative function, given an original function and wrt differentiability parameters.

It would be nice for the compiler to reliably show the correct derivative type in @derivative attribute type-checking diagnostics. This enables the workflow of "declaring a dummy derivative function declaration, then changing its type to the compiler-suggested correct type":

@differentiable(where T: Differentiable)
func foo<T, U>(_ x: T, _ y: inout Float, _ z: U) {}

@derivative(of: foo)
func vjpFoo() {}

Currently, the expected derivative type isn't reliably shown:

autodiff.swift:4:2: error: '@derivative(of:)' attribute requires function to return a two-element tuple; first element must have label 'value:' and second element must have label 'pullback:' or 'differential:'
@derivative(of: foo)
 ^

But we can reliably show it if the original function declaration and differentiability parameters can be resolved.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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

No branches or pull requests

1 participant