-
Notifications
You must be signed in to change notification settings - Fork 10.7k
[AutoDiff] Canonicalize linear maps to be maximally indirect. #26709
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
Canonicalize JVPs/VJPs to return maximally abstracted linear map functions with `@in_guaranteed` parameters and an `@out` result. This is a necessary step towards re-enabling LoadableByAddress: linear map type is no longer computed based on the original function type. See TF-11 for more info regarding LoadableByAddress. See TF-625 for more info regarding maximally abstracted linear maps.
a690449 to
bf6b528
Compare
- Change differential generation to use only tangent buffers.
- Change pullback visitors to use only adjoint buffers.
- Change adjoint of active value propagation to use only adjoint buffers.
- Mark all tangent/adjoint value helpers as `[[deprecated]]`.
- They are not deleted because helpers may become useful after
SIL opaque values are introduced.
bf6b528 to
328676e
Compare
Will re-add in follow-up for separation of concerns.
9dbb1d6 to
361ae93
Compare
|
@swift-ci Please test tensorflow |
361ae93 to
e38afb9
Compare
|
@swift-ci Please test tensorflow |
|
It would be good to test the performance impact of this patch. Using adjoint buffers instead of adjoint values may incur a performance penalty. |
Remove unused `AdjointValue` utilities for materialization and addition. `AdjointValue` itself is preserved to implement symbolic zero buffer optimization.
Address review feedback. Standardize variable naming.
`tuple_extract` is no longer testable after Differentiation has been moved before OwnershipModelEliminator. Old reproducers for `tuple_extract` now generate `destructure_tuple`. Deleting untestable code is prudent.
Avoid unnecessary local tangent struct struct allocation. Generate `struct_element_addr` into existing struct tangent buffer.
cce599d to
a6988c8
Compare
Todo: add test. Currently, test crashes. This commit will be overwritten and rebased when done.
There are no known tests for `tuple_extract` visitors. Re-adding `tuple_extract` visitors may be necessary when differentiation supports inout parameters. This Gist shows cases where SILGen produces `struct_extract`: https://gist.github.com/dan-zheng/1343673d2d4d20d403306283b42d522b
Some cleanup will be refactored to a separate patch.
6dcf239 to
04dca63
Compare
|
A less invasive approach for re-enabling LoadableByAddress was found: #27923 Maximal indirection will not be pursued further: the differentiation transform should not be forced to generate maximally indirect code to workaround issues caused by LoadableByAddress. |
Canonicalize JVPs/VJPs to return maximally abstracted linear map functions
with
@in_guaranteedparameters and an@outresult.This is a necessary step towards re-enabling LoadableByAddress:
linear map type is no longer computed based on the original function type.
Summary of changes:
handle maximally indirect linear maps.
See TF-11 for more info regarding LoadableByAddress.
See TF-625 for more info regarding maximally abstracted linear maps.
Initial patch by @rxwei - commits lost because resolving conflicts got too complicated, sorry.