Skip to content

[META][AutoDiff] Fix autodiff for classes and class-valued arguments #65012

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

Open
1 of 4 tasks
asl opened this issue Apr 7, 2023 · 4 comments
Open
1 of 4 tasks

[META][AutoDiff] Fix autodiff for classes and class-valued arguments #65012

asl opened this issue Apr 7, 2023 · 4 comments
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@asl
Copy link
Contributor

asl commented Apr 7, 2023

This is a meta-issue noting all kinds of issues related to differentiating of classes, class methods, etc. While the things are more or less working for ordinary functions and structs, there are lots of missed functionality related to classes.

  • Classes-type function arguments have reference semantics. Therefore they should be treated semantically similar to inout arguments, however, there are lots of subtle differences. In particular, we need to fix activity analysis for classes, determination of semantic results, etc.
  • There are lots of interesting special things around classes including e.g. accessors. Setters work by a chance (however, the activity analysis in anything involving setters is just plain wrong), and we do not support read / modify accessors.
  • To support read / modify accessors we need to implement missed pieces of functionality around differentiation of co-routines. While semantically it is unclear how one could derive a derivative of function that essentially might return different values in general, we can narrow down task to support only @yield_once co-routines, where everything essentially returns only once, there is no way to resume / abort co-routine, so they act as a normal functions and @yield_once is just a way to transfer ownership.

Related issues:

@asl asl added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. AutoDiff labels Apr 7, 2023
@asl
Copy link
Contributor Author

asl commented Apr 7, 2023

Tagging @rxwei @dan-zheng @BradLarson

@dan-zheng
Copy link
Contributor

Quick check: do we have non-toy motivating use cases for class differentiation? If yes, could we please share them here?

Features like class differentiation involve many design decisions, and it's nice to do use-case-driven development to ensure decisions are made in support of real use cases.

@asl
Copy link
Contributor Author

asl commented Aug 10, 2023

This is for @BradLarson :)

@rxwei
Copy link
Contributor

rxwei commented Aug 10, 2023

I second Dan's quick check. It seems that there are more important issues to tackle to bring us closer to Swift Evolution like ABI stability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

3 participants