-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff][SIL] Reverse-mode differentiation: thunk generation crash #59429
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
Comments
Another reproducer. I don't know whether this is the same bug. import _Differentiation
func curry<T, U, V>(
_ f: @differentiable(reverse) (T, U) -> V
) -> (T) -> (@differentiable(reverse) (U) -> V) {
{ x in { y in f(x, y) } }
} Stack trace
|
This is a duplicate of #55966. The previous issue was closed because of an incorrect assumption: that the crash only happens when forward-mode differentiation is enabled. Here, no extra compiler flags are passed in. As in #55966 (comment), I only included the first line of each crash. import _Differentiation
// From the differentiable programming manifesto:
// Error diagnostic
func curry<T, U, V>(
_ f: @differentiable (T, U) -> V
) -> @differentiable (T) -> @differentiable (U) -> V {
{ x in { y in f(x, y) } }
}
// Error diagnostic
func curry<T, U, V>(
_ f: @escaping @differentiable(reverse) (T, U) -> V
) -> @differentiable(reverse) (T) -> (@differentiable(reverse) (U) -> V) {
{ x in { y in f(x, y) } }
}
// Compiles just fine
func curry<T, V>(
_ f: @escaping @differentiable(reverse) (T, T) -> V
) -> (T) -> (@differentiable(reverse) (T) -> V) {
{ x in { y in f(x, y) } }
}
// Assertion failed: (signature || !origType->hasTypeParameter()), function initSwiftType, file AbstractionPattern.h, line 528.
func curry<T, U, V>(
_ f: @escaping (T, U) -> V
) -> (T) -> (@differentiable(reverse) (U) -> V) {
{ x in { y in f(x, y) } }
} Ad nauseam// Assertion failed: (signature || !origType->hasTypeParameter()), function initSwiftType, file AbstractionPattern.h, line 528.
func curry<T, U, V>(
_ f: (T, U) -> V
) -> (T) -> (@differentiable(reverse) (U) -> V) {
{ x in { y in f(x, y) } }
}
// Bad generic parameter in τ_0_2
func curry<T, V>(
_ f: (T, T) -> V
) -> (T) -> (@differentiable(reverse) (T) -> V) {
{ x in { y in f(x, y) } }
}
// Bad generic parameter in τ_0_1
func curry<T>(
_ f: (T, T) -> T
) -> (T) -> (@differentiable(reverse) (T) -> T) {
{ x in { y in f(x, y) } }
}
// Bad generic parameter in τ_0_1
func curry<T>(
_ f: (T) -> T
) -> (T) -> (@differentiable(reverse) (T) -> T) {
{ x in { y in f(y) } }
}
// Error diagnostic
func curry<T>(
_ f: (T) -> T
) -> (T) -> (@differentiable(reverse) (T) -> T) {
{ x in { y in f(x) } }
}
// Compiles just fine
func curry<T>(
_ f: @escaping (T) -> T
) -> (T) -> (@differentiable(reverse) (T) -> T) {
{ x in { y in f(x) } }
} |
The above reproducers still trigger various assertion and validation failures on top-of-tree Swift, so I'll reopen this in order to track a fix. |
Describe the bug
The following Swift code causes a compiler crash.
To Reproduce
Steps to reproduce the behavior:
file.swift
.swift -DCRASH_2 file.swift
, where-DCRASH_2
corresponds to the number chosen in the previous step.Expected behavior
A compiler crash with one of four possible stack traces.
Crash 1
Crash 2
Crash 3
Crash 4
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: