-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] WIP - Adding support for differentiating wrt inout parameters. #25687
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
Conversation
@rxwei in the last commit I added a helper for handling |
@rxwei @dan-zheng I also added support for inout wrt parameters to |
… the getters and the setters of properties.
I actually added support for propagating the |
I also ran tests to see if all is still good and everything passes except for an unexpected error message. Adding |
@rxwei I started looking a bit into the SIL optimization phases to try and figure out what to do next, but I had one question about function parameters: what's the difference between direct and indirect parameters? I assume I should use something like |
Indirect parameters are parameters that need to be handled as buffers due to various reasons (unknown size, |
@rxwei I've going through the code and I'm wondering if we also need to change |
The reason I'm asking this is because I don't know if this condition will be true for |
So currently in this PR I have made a modification in auto getTangentType = [lookupConformance](Type type) -> Type {
if (!type->is<InOutType>()) {
return type->getAutoDiffAssociatedTangentSpace(
lookupConformance)->getType();
}
Type base = type->getInOutObjectType();
Type tangentBase = base->getAutoDiffAssociatedTangentSpace(
lookupConformance)->getType();
return InOutType::get(tangentBase);
}; Should I instead move this inside |
Actually, I realize I cannot currently do that directly because |
An |
I see. In that case, I guess my current implementation as part of |
Actually I just pushed a change doing that because I feel like this is indeed necessary. |
Also, I don't think I need to change |
I also started making changes to the VJP emitter but I'm not at all sure if this is the right direction right now so I'll pause until you can take a look at the current set of changes and summarize the appropriate next steps. |
Also cc'ing @dan-zheng because I noticed that you have also worked a lot in this part of the codebase. |
6dcf239
to
04dca63
Compare
I accidentally deleted |
Thank you @eaplatanios for starting this effort and discussion! Sorry for letting this PR rot. #30013 just added |
@rxwei This is a very first step but I thought it'd be good to start making progress here and keep all the related discussions here.