You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AutoDiff] [API] Continue deriving conformances for Differentiable. (#21646)
* [API] Continue deriving conformances for `Differentiable`.
Continue implementing `Differentiable` derived conformances for struct types.
A follow-up to #21580.
This patch introduces support for:
- Synthesizing member `TangentVector` and `CotangentVector` structs.
This is necessary when not all members have `Self == TangentVector ==
CotangentVector`.
- Marking synthesized vector space structs and typealiases with
`@_fieldwiseProductSpace`.
- Making synthesis consistent with recent changes to `Differentiable`.
- Vector space associated types now conform to `AdditiveArithmetic`,
not `VectorNumeric` (which is limited to a single `Scalar` type).
- Use `@noDerivative` attribute to determine vector space struct
members. A member in the original struct type marked with
`@noDerivative` will not have corresponding members in vector space
structs.
- Enabliing derived conformances to `AdditiveArithmetic` and
`VectorNumeric` for structs with no stored properties.
- Many bug fixes regarding code synthesis, details omitted.
There are some todos:
- Fix SR-9595, which is related to mutually recursive associated types.
The bug blocks `Differentiable` synthesis for structs whose members
have generic types (e.g. `<T : Differentiable>`).
Failing tests due to this bug are commented in
`test/Sema/struct_differentiable.swift`.
- Synthesize `@differentiable(wrt: (self))` on stored properties of
`Differentiable`-conforming types.
- It's possible to do this synthesis during the derived conformances code
path, but the derived conformances code path is not triggered if a type
manually defines all `Differentiable` requirements.
- Add `Differentiable` derived conformances runtime tests.
- Future: enable `Differentiable` derived conformances for enums.
* [API] Conform synthesized vector space structs to `KeyPathIterable`.
* Minor cleanup.
* [API] Un-conform synthesized vector space structs from `KeyPathIterable`.
Synthesizing `KeyPathIterable` for these structs is ad-hoc and limited in
usefulness (not useful when `Self != TangentVector` or `Self != CotangentVector`).
A more general solution involves providing a mapping between `Self`s
keypaths and vector space structs' keypaths.
* Fix test/AutoDiff/noderivative-attr.swift.
0 commit comments