-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-13096] Fix autodiff typing rules for class-typed function parameters #55542
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 |
4 tasks
@dan-zheng Why the pullback in the testcase has |
Yes, I think you're right. I'll update the issue description, thanks. |
Great, thanks. I'm having locally, so this will be a part of larger PR: // reverse-mode derivative of Class.setterForX(_:)
sil hidden [thunk] [always_inline] @$s4main5ClassC10setterForXyySfFTJrSSpSr : $@convention(method) (Float, @guaranteed Class) -> @owned @callee_guaranteed (@inout Class.TangentVector) -> Float {
// %0 // user: %3
// %1 // user: %3
bb0(%0 : $Float, %1 : $Class):
// function_ref Class.vjpSetterForX(_:)
%2 = function_ref @$s4main5ClassC13vjpSetterForXyyt5value_SfAC13TangentVectorVzc8pullbacktSfF : $@convention(method) (Float, @guaranteed Class) -> @owned @callee_guaranteed (@inout Class.TangentVector) -> Float
// user: %3
%3 = apply %2(%0, %1) : $@convention(method) (Float, @guaranteed Class) -> @owned @callee_guaranteed (@inout Class.TangentVector) -> Float // user: %5
// function_ref autodiff self-reordering reabstraction thunk for @escaping @callee_guaranteed (@inout Class.TangentVector) -> (@unowned Float)
%4 = function_ref @$s4main5ClassC13TangentVectorVSfIegld_AESfIegld_TJOp : $@convention(thin) (@inout Class.TangentVector, @guaranteed @callee_guaranteed (@inout Class.TangentVector) -> Float) -> Float // user: %5
%5 = partial_apply [callee_guaranteed] %4(%3) : $@convention(thin) (@inout Class.TangentVector, @guaranteed @callee_guaranteed (@inout Class.TangentVector) -> Float) -> Float // user: %6
return %5 : $@callee_guaranteed (@inout Class.TangentVector) -> Float // id: %6
} // end sil function '$s4main5ClassC10setterForXyySfFTJrSSpSr' |
20 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Additional Detail from JIRA
md5: bece69c35790a09fc5e98c37400842e1
relates to:
Issue Description:
Fix
@differentiable
and@derivative
type-checking for class-typed function parameters.Class-typed values have reference semantics and can be freely mutated. Thus, they should be treated like
inout
parameters for the purposes of@differentiable
and@derivative
type-checking.Example:
Unexpected error, because the class-typed
self
parameter is not treated as a "semantic result" byautodiff::getFunctionSemanticResultTypes
.The text was updated successfully, but these errors were encountered: