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] Add an error when @differentiable attributes do not match. #22149
Conversation
@swift-ci please test tensorflow |
1 similar comment
@swift-ci please test tensorflow |
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.
Awesome!
@swift-ci please test tensorflow |
1 similar comment
@swift-ci please test tensorflow |
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.
Great patch!
…when conforming to protocols.
@swift-ci please test tensorflow |
@swift-ci please test tensorflow macos |
Currently a mismatch between differentiable attributes on protocol and structs that conform to that protocol will result in a runtime error.
This PR adds a diagnostic error that always requires that these functions be differentiable.
This is an example of the diagnostic that is produced when this happens:
test2.swift:9:8: error: type 'ConformingWithErrors' does not conform to protocol 'DiffReq'
struct ConformingWithErrors : DiffReq {
^
test2.swift:10:8: note: candidate is missing differentiable attribute '@differentiable(wrt: (x, self)) '
func f1(_ x: Float) -> Float {
^
test2.swift:3:8: note: protocol requires function 'f1' with type '(Float) -> Float'; do you want to add a stub?
func f1(_ x: Float) -> Float
^