-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Check @noDerivative for function type comparison #67121
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,7 +741,8 @@ struct TF_675 : Differentiable { | |
let _: @differentiable(reverse) (Float) -> Float = TF_675().method | ||
|
||
// TF-918: Test parameter subset thunk + partially-applied original function. | ||
let _: @differentiable(reverse) (Float, Float) -> Float = (+) as @differentiable(reverse) (Float, @noDerivative Float) -> Float | ||
let _: @differentiable(reverse) (Float, @noDerivative Float) -> Float = (+) as @differentiable(reverse) (Float, Float) -> Float | ||
let _: @differentiable(reverse) (Float, @noDerivative Float) -> Float = (+) as @differentiable(reverse) (Float, @noDerivative Float) -> Float | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised this test was there! Maybe it was meant to test function conversions to a function with more let _: @differentiable(reverse) (Float, @noDerivative Float) -> Float = (+) as @differentiable(reverse) (Float, Float) -> Float Is the above possible today? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the above example is also possible. I think it is the same as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it actually work in a runtime test? |
||
|
||
//===----------------------------------------------------------------------===// | ||
// Differentiation in fragile functions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
import _Differentiation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the test is not in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asavonic Please submit a follow-up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry for causing this issue. I've submitted a PR to fix it: #67190 |
||
|
||
// Allow Type -> @noDerivative Type | ||
// | ||
func test1(_ foo: @escaping @differentiable(reverse) (Float, Float) -> Float) { | ||
let fn: @differentiable(reverse) (Float, @noDerivative Float) -> Float = foo | ||
_ = fn(0, 0) | ||
} | ||
|
||
// Allow @noDerivative Type -> Type when LHS function is not differentiable | ||
// | ||
func test2(_ foo: @escaping @differentiable(reverse) (Float, @noDerivative Float) -> Float) { | ||
let fn: (Float, Float) -> Float = foo | ||
_ = fn(0, 0) | ||
} | ||
|
||
// Disallow @noDerivative Type -> Type when LHS function is also differentiable | ||
// | ||
func test3(_ foo: @escaping @differentiable(reverse) (Float, @noDerivative Float) -> Float) { | ||
// expected-error @+1 {{cannot convert value of type '@differentiable(reverse) (Float, @noDerivative Float) -> Float' to specified type '@differentiable(reverse) (Float, Float) -> Float'}} | ||
let fn: @differentiable(reverse) (Float, Float) -> Float = foo | ||
_ = fn(0, 0) | ||
} |
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.
I can no longer find TF-918... Is there a GitHub issue for it?
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm afraid all TF issues gone long time ago. And if they were not converted to normal Swift JIRA issues, then they cannot be found anywhere...
@shahmishal will you please confirm?
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.
We should probably go over all
TF-
bugs in comments and remove them.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.
And rewrite to present issues when the issue was migrated (there are few of them IIRC). Some of the TF's refer to some design decisions made in the past. It would be good to document them somehow while there are some memories on them :) I'll check what are the most important / interesting ones