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

[AutoDiff] Add an error when @differentiable attributes do not match. #22149

Merged
merged 1 commit into from Jan 26, 2019

Conversation

pschuh
Copy link
Collaborator

@pschuh pschuh commented Jan 26, 2019

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
^

@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

1 similar comment
@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

Copy link
Collaborator

@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.

Awesome!

include/swift/AST/DiagnosticsSema.def Outdated Show resolved Hide resolved
@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

1 similar comment
@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

Copy link
Member

@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.

Great patch!

include/swift/AST/Attr.h Outdated Show resolved Hide resolved
include/swift/AST/DiagnosticsSema.def Outdated Show resolved Hide resolved
lib/Sema/TypeCheckProtocol.cpp Outdated Show resolved Hide resolved
lib/Sema/TypeCheckProtocol.cpp Outdated Show resolved Hide resolved
@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

2 similar comments
@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow

@pschuh
Copy link
Collaborator Author

pschuh commented Jan 26, 2019

@swift-ci please test tensorflow macos

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.

None yet

3 participants