-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Refine the implicit wrt
logic for @differentiable attribute
#67174
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
Tagging @rxwei @BradLarson @dan-zheng @jkshtj @asavonic |
To clarify what I was arguing for: I think inference for simple cases (no inout parameters) is pretty good, but it gets complicated with multiple semantic results. |
@rxwei Does this mean that we'd always require setters to be differentiated wrt protocol Protocol: Differentiable {
@differentiable(reverse, wrt: (self, x, y))
@differentiable(reverse, wrt: x)
func method(_ x: Float, _ y: Double) -> Float
@differentiable(reverse)
var property: Float { get set }
@differentiable(reverse, wrt: x)
subscript(_ x: Float, _ y: Float) -> Float { get set }
} |
So, we are having special handling in inouts in many places. In preparation for future changes (treating class reference as potential semantic results, etc.), I made a refactoring introducing "semantic result parameters". I believe I walked over all places where inouts were handled and checked if the logic is specific to inouts or in general to semantic result parameters and made the corresponding changes (though I could certainly miss something obscure or some corner cases). On top of that, 918e243 implements the logic we discussed: semantic result parameters (inouts for now) are not considered as semantic results unless they are Please take a look into #67230 |
Introduce the notion of "semantic result parameter". Handle differentiation of inouts via semantic result parameter abstraction. Do not consider non-wrt semantic result parameters as semantic results Fixes #67174
Originally posted by @rxwei in #66873 (comment)
I think there are two angles where we need to decide:
@differentiable
without specifyingwrt:
.inout
argument. If the user explicitly specifieswrt:
on an inout argument, we treat it as a semantic result.The text was updated successfully, but these errors were encountered: