swift
7551278a - [AutoDiff] Make `@noDerivative` attribute imply non-varying semantics. (#29543)

Commit
5 years ago
[AutoDiff] Make `@noDerivative` attribute imply non-varying semantics. (#29543) Previously, `@noDerivative` could only be declared on stored properties in `Differentiable`-conforming structs and classes. Now, `@noDerivative` can be declared on all function-like declarations: `func`, `var`, `init`, and `subscript`. `@noDerivative` attribute now also implies `@_semantics("autodiff.nonvarying")`. SIL values produced from `@noDerivative` declarations will never be marked as varying by differentiable activity analysis. These values do not need a derivative. Marking declarations as `@noDerivative` is a usability improvement over using `withoutDerivative(at:)` at use sites. However, `@noDerivative` is invasive because it requires annotation on original declarations. There may exist a more elegant solution.
Author
Parents
Loading