swift
bbe86e90 - [AutoDiff upstream] Add `Differentiable` protocol derived conformances. (#30671)

Commit
5 years ago
[AutoDiff upstream] Add `Differentiable` protocol derived conformances. (#30671) Add `AdditiveArithmetic` derived conformances for structs and classes, gated by the `-enable-experimental-differentiable-programming` flag. Structs and classes whose stored properties all conform to `Differentiable` can derive `Differentiable`: - `associatedtype TangentVector: Differentiable & AdditiveArithmetic` - Member `TangentVector` structs are synthesized whose stored properties are all `var` stored properties that conform to `Differentiable` and that are not `@noDerivative`. - `mutating func move(along: TangentVector)` The `@noDerivative` attribute may be declared on stored properties to opt out of inclusion in synthesized `TangentVector` structs. Some stored properties cannot be used in `TangentVector` struct synthesis and are implicitly marked as `@noDerivative`, with a warning: - `let` stored properties. - These cannot be updated by `mutating func move(along: TangentVector)`. - Non-`Differentiable`-conforming stored properties. `@noDerivative` also implies `@_semantics("autodiff.nonvarying")`, which is relevant for differentiable activity analysis. Add type-checking and SILGen tests. Resolves TF-845.
Author
Parents
Loading