-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-13250] AutoDiff test failure: test/AutoDiff/validation-test/differentiable_protocol_requirements.swift #55690
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
@swift-ci create |
A minimized reproducer based on test/AutoDiff/validation-test/differentiable_protocol_requirements.swift: import DifferentiationUnittest
protocol FunctionsOfX: Differentiable {
@differentiable(reverse)
init(x: Tracked<Float>)
@differentiable(reverse)
var x: Tracked<Float> { get }
}
struct TestFunctionsOfX: FunctionsOfX {
@differentiable(reverse)
init(x: Tracked<Float>) { self.x = x }
var x: Tracked<Float>
}
// This causes a crash
func derivatives<F: FunctionsOfX>(at x: Tracked<Float>, of: F.Type)
-> Tracked<Float> { return gradient(at: x) { x in F(x: x).x } }
derivatives(at: 2.0, of: TestFunctionsOfX.self)
// This compiles OK
let x = Tracked<Float>(42)
gradient(at: x) { x in TestFunctionsOfX(x: x).x } Note that it is crucial to have Tagging @asl |
Only reproduced with
Happens in
|
So, devirtualizer wants to convert The original instruction is
The devirtualized one:
And the thunk we're calling is
(note the Here is the original code in %9 = witness_method $τ_0_0, #FunctionsOfX.init!allocator.jvp.SU.<Self where Self : FunctionsOfX> : <Self where Self : FunctionsOfX> (Self.Type) -> (Tracked<Float>) -> Self : $@convention(witness_method: FunctionsOfX) <τ_0_0 where τ_0_0 : FunctionsOfX> (@in Tracked<Float>, @thick τ_0_0.Type) -> (@out τ_0_0, @owned @callee_guaranteed @substituted <τ_0_0> (@in Tracked<Float>) -> @out τ_0_0 for <τ_0_0.TangentVector>) // user: %10
%10 = partial_apply [callee_guaranteed] %9<τ_0_0>() : $@convention(witness_method: FunctionsOfX) <τ_0_0 where τ_0_0 : FunctionsOfX> (@in Tracked<Float>, @thick τ_0_0.Type) -> (@out τ_0_0, @owned @callee_guaranteed @substituted <τ_0_0> (@in Tracked<Float>) -> @out τ_0_0 for <τ_0_0.TangentVector>) // user: %13 Here is the part of witness table:
And we are having thunk with sil private [transparent] [thunk] @AD__$s7tracked16TestFunctionsOfXVAA0cD1XA2aDP1xx23DifferentiationUnittest7TrackedVySfG_tcfCTW_jvp_SU : $@convention(witness_method: FunctionsOfX) (@in Tracked<Float>, @thick TestFunctionsOfX.Type) -> (@out TestFunctionsOfX, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed Tracked<Float>) -> @out τ_0_0 for <TestFunctionsOfX.TangentVector>) { |
Tagging @JaapWijnen |
Some additional context: The function type of witness table entry has On the other hand, in In |
Additional Detail from JIRA
md5: 24a514bc4a5ba11871c72f5b0d01ec85
Issue Description:
Test failure reported here: #32948 (comment)
The text was updated successfully, but these errors were encountered: