You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TF-1175 Self-mutating class method call is not marked active
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:
import_DifferentiationclassClass: Differentiable {
varx: Float = 0// Semantically acts like `Class.x.set`.// Type: `(Class) -> (Float) -> Void`.funcsetterForX(_newValue: Float) {
self.x = newValue
}
// This VJP is expected to pass type-checking but does not.@derivative(of: setterForX, wrt: (self, newValue))
funcvjpSetterForX(_newValue: Float) -> (
value: (), pullback: (inoutTangentVector) -> Float
) {
fatalError()
}
}
Unexpected error, because the class-typed self parameter is not treated as a "semantic result" by autodiff::getFunctionSemanticResultTypes.
@dan-zheng Why the pullback in the testcase has (inout TangentVector, Float) -> Void function type? Shouldn't it be (inout TangentVector) -> Float as we're having wrt for both arguments?
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: