Commit Graph

10 Commits

Author SHA1 Message Date
Allan Shortlidge
d0028e098e Test: Improve test coverage for TBDGen. 2022-10-19 12:35:30 -07:00
Anthony Latsis
189837eb03 Gardening: Migrate test suite to GH issues: AutoDiff/TBD 2022-09-19 02:44:03 +03:00
Erik Eckstein
6ee19f0bea Do conservative cross-module-optimization by default
The "regular" CMO is done with the option `-cross-module-optimization`. It's good for performance but can increase code size.
Now, which this change CMO is also done if the option is not given, but in a very conservative way. Only very small functions are serialized and not additional type metadata is kept alive.

rdar://70082202
2022-01-12 12:43:53 +01:00
Richard Wei
3c02dba2c4 [AutoDiff] Change derivative vtable thunk linkage to private.
Derivative vtable thunks should never be public. They are only called through vtable lookup.

Resolves rdar://73791807.
2021-02-16 03:12:43 -05:00
Richard Wei
af8942d940 [AutoDiff] Rename '@differentiable' to '@differentiable(reverse)'.
Compiler:
- Add `Forward` and `Reverse` to `DifferentiabilityKind`.
- Expand `DifferentiabilityMask` in `ExtInfo` to 3 bits so that it now holds all 4 cases of `DifferentiabilityKind`.
- Parse `@differentiable(reverse)` and `@differentiable(_forward)` declaration attributes and type attributes.
- Emit a warning for `@differentiable` without `reverse`.
- Emit an error for `@differentiable(_forward)`.
- Rename `@differentiable(linear)` to `@differentiable(_linear)`.
- Make `@differentiable(reverse)` type lowering go through today's `@differentiable` code path. We will specialize it to reverse-mode in a follow-up patch.

ABI:
- Add `Forward` and `Reverse` to `FunctionMetadataDifferentiabilityKind`.
- Extend `TargetFunctionTypeFlags` by 1 bit to store the highest bit of differentiability kind (linear). Note that there is a 2-bit gap in `DifferentiabilityMask` which is reserved for `AsyncMask` and `ConcurrentMask`; `AsyncMask` is ABI-stable so we cannot change that.

_Differentiation module:
- Replace all occurrences of `@differentiable` with `@differentiable(reverse)`.
- Delete `_transpose(of:)`.

Resolves rdar://69980056.
2021-02-07 14:09:46 -08:00
Richard Wei
2f883a3599 [AutoDiff] Fix TBDGen issues for derivative dispatch thunks and method descriptors.
- Add `DispatchThunkDerivative` and `MethodDescriptorDerivative` as link entities. The derivative functions of initializers, subscripts, properties, and methods are **all methods**, so we don't need other link entities for this purpose.
- Mangle dispatch thunks and method descriptors. Make `AutoDiffFunction` a context node since it can be nested.

Resolves SR-13866 (rdar://71318828) and SR-13125 (rdar://65240599).
2021-01-30 16:47:00 -08:00
Richard Wei
ffe6064101 Mangle derivative functions and linear maps.
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen.
- `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature.

A mangled differentiation function name includes:
- The original function.
- The differentiation function kind.
- The parameter indices for differentiation.
- The result indices for differentiation.
- The derivative generic signature.
2021-01-07 02:21:10 -08:00
Dan Zheng
a8a95d0a75 [AutoDiff upstream] Enable @differentiable on setters. (#35133)
Enable `@differentiable` attribute on setters of properties and
subscripts in `Differentiable`-conforming types.

Add automatically-differentiated `@differentiable` setter test.

Resolves TF-1166.
2020-12-17 14:05:22 -05:00
Marc Rasi
7191c9c21d [AutoDiff] remove all-concrete gen sig from more places 2020-07-15 17:28:14 -07:00
Dan Zheng
4671dc5c0f [AutoDiff upstream] Add TBDGen for AutoDiff symbols.
Emit symbols for `@differentiable` and `@derivative` declaration attributes:
- Differentiability witness symbols.
- Derivative function (JVP/VJP) symbols.
- Linear map (differential/pullback) symbols.

Add TBDGen test.
2020-04-03 01:14:28 +00:00