Commit Graph

8 Commits

Author SHA1 Message Date
Anton Korobeynikov
c89e270b7d Implement value witness table for @differentiable functions (#60875)
@differentiable function is actually a triple (function, jvp, vjp). Previously normal thick function value witness table was used. As a result, for example,  only function was copied, but none of differential components.

This was the cause of uninitialized memory accesses and subsequent segfaults.

Should fix now unavailable TF-1122
2022-09-01 03:09:39 -07:00
Slava Pestov
b57be6dbf1 Revert "AutoDiff: Disable requirement machine when building or testing Differentiation library"
This reverts commit 4f6ba29715.
2021-09-23 13:24:40 -04:00
Slava Pestov
4f6ba29715 AutoDiff: Disable requirement machine when building or testing Differentiation library
The SIL type lowering logic for AutoDiff gets the substituted generic signature
mixed up with the invocation generic signature, so it tries to ask questions
about DependentMemberTypes in a signature with no requirements. This triggers
assertions when the requirement machine is enabled.

Disable the requirement machine until this is fixed.
2021-07-30 19:42:31 -04:00
Richard Wei
0b53a02544 [AutoDiff] Rename 'in:' to 'of:' in differential operators.
Rename the argument label `in:` in `gradient(at:in:)`, `pullback(at:in:)`, etc to `of:`, as suggested in the [pitch thread](https://forums.swift.org/t/differentiable-programming-for-gradient-based-machine-learning/42147).
2021-02-24 01:33:42 -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
Saleem Abdulrasool
edad6810e1 test: explicitly reference SR (NFC)
Adjust the disabled tests to explicitly reference the SR.  This cleans
up the previous change to enable the autodifferentiation CI tests on
Windows.
2021-01-13 13:17:38 -08:00
Saleem Abdulrasool
0511af57f5 CI: disable 4 tests, enable autodiff tests on Windows
This disables 4 tests:
  - DerivativeRegistrationTests.NonCanonicalizedGenericSignatureComparison
  - Reabstraction.diff param generic => concrete
  - Reabstraction.diff param and nondiff param generic => concrete
  - Reabstraction.result generic => concrete

Simultaneously, enable the remainder of the auto-diff test suite on
Windows.  These tests fail on Windows due to an invalid parameter during
the reabstraction of the generic differentiable parameters.  The
remainder of the auto-differentiation tests pass on all the platforms.
2021-01-12 14:42:50 -08:00
marcrasi
99356cd9f4 [AutoDiff upstream] add more differentiation tests (#30933) 2020-04-13 09:40:45 -07:00