-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Initial support for differentiation of throwing functions #82653
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
base: main
Are you sure you want to change the base?
Conversation
Tagging @JaapWijnen @kovdan01 |
@swift-ci please test |
@swift-ci please test |
Windows fails in unrelated @swift-ci please test windows platform |
assert(inserted && "should have unique adjoint for try_apply"); | ||
break; | ||
} | ||
case SILValueCategory::Address: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With existing tests, we never fall into this case. It's probably worth covering it with tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems we'd need something like object value with non-loadable tangent.
@swift-ci please test |
This adds initial support for differentiation of functions that may produce
Error
result. Essentially we wrap the pullback intoOptional
and emit a diamond-shape control flow pattern depending on whether the pullback value is available or not. VJP emission was modified to accommodate for this. In addition to this, some additional tricks are requires astry_apply
result is not available in the instruction parent block, it is available in normal successor basic block.As a result we can now:
try_apply
result (that would be produced fromdo ... try .. catch
constructions)try_apply
when error result is unreachable (usuallytry!
and similar source code constructs)@derivative(of:)
attribute, so we can register custom derivatives for functions producing error resultOptional.??
operator (note that support here is not yet complete as we cannot differentiate through autoclosures, sox ?? y
works only ify
is not active, e.g. a constant value).Some fixes here and there