Commit Graph

144 Commits

Author SHA1 Message Date
marcrasi
99356cd9f4 [AutoDiff upstream] add more differentiation tests (#30933) 2020-04-13 09:40:45 -07:00
Saleem Abdulrasool
f7a65f8e6a Merge pull request #30961 from texasmichelle/change_filename
Add .gyb extension to filename
2020-04-11 16:02:51 -07:00
Saleem Abdulrasool
3a8eea4d58 Merge pull request #30907 from compnerd/autodiff-fix
test: repair the AutoDiff test on Windows
2020-04-10 18:33:01 -07:00
Saleem Abdulrasool
83183f465f Merge pull request #30950 from compnerd/no-fp80
AutoDiff: disable the test cases for FP80
2020-04-10 15:09:05 -07:00
Saleem Abdulrasool
abd4b12d21 Merge pull request #30951 from compnerd/cross-module-differentiation-win
AutoDiff: repair the cross-module-differentiation on Windows
2020-04-10 14:42:48 -07:00
Michelle Casbon
1c5eaed84d Add .gyb extension to filename 2020-04-10 21:22:01 +00:00
Dan Zheng
486e667904 [AutoDiff] Support direct init reference differentiation. (#30946)
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 12:23:19 -07:00
Dan Zheng
a864a57c9a [AutoDiff upstream] Add Differentiable.withDerivative(_:). (#30945)
Add `Differentiable.withDerivative(_:)`, a "derivative surgery" API.

`Differentiable.withDerivative(_:)` is an identity function returning `self`.
It takes a closure and applies it to the derivative of the return value, in
contexts where the return value is differentiated with respect to.
2020-04-10 12:22:56 -07:00
Saleem Abdulrasool
26c61f5183 AutoDiff: repair the cross-module-differentiation on Windows
Make the cross-module differentiation test work on Windows by converting
to a shared library to run the test.
2020-04-10 11:25:40 -07:00
Saleem Abdulrasool
de9aa59b74 test: repair the AutoDiff test on Windows
`-lm` is not portable, it is only needed on certain platforms (e.g.
Linux, not BSD).  Remove the explicit link.

Avoid using a static library as that is not supported on all platforms
(e.g. Windows).  Use the helper macros to generate the library.

Repairs the Windows tests.
2020-04-10 10:58:22 -07:00
Saleem Abdulrasool
0444df6f50 Merge pull request #30952 from compnerd/autodiff-vs-differential-programming
AutoDiff: repair the test on Windows
2020-04-10 10:56:46 -07:00
Saleem Abdulrasool
d09c0f85bf Merge pull request #30949 from compnerd/fp80-android
AutoDiff: Android, Windows does not support FP80
2020-04-10 10:32:42 -07:00
Saleem Abdulrasool
ccdc8efa95 AutoDiff: repair the test on Windows
The name of the module is encoded into the type name.  The module name
is not `null` on Windows, which would fail to match the name.  It is
possible to make the test less overly-constricted, but setting the
module name to null is simpler and avoids more regex matching.
2020-04-10 08:14:54 -07:00
Saleem Abdulrasool
3528e7e1fa AutoDiff: disable the test cases for FP80
The FP80 tests should not be built on Android or Windows.  This fixes
the Windows run of the test.
2020-04-10 08:11:47 -07:00
Saleem Abdulrasool
4b67e95299 AutoDiff: Android, Windows does not support FP80
Correct the condition for FP80.  This should have no real impact on
Android as the tests are not currently executed.
2020-04-10 08:09:35 -07:00
Dan Zheng
e9ed2d50cf [AutoDiff] Fix @derivative attribute type-checking crash. (#30936)
Fix `@derivative` attribute type-checking crash, so far reproducible only via
`-parse-stdlib`.

The crash occurs because it is not sufficient for type-checking to check for
`Differentiable` conformances. We must also check for invalid `TangentVector`
associated types.

Resolves SR-12559.
2020-04-10 02:14:02 -07:00
Dan Zheng
b4fa7e0027 [AutoDiff] Support direct init reference differentiation.
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 01:26:34 -07:00
Dan Zheng
3ef8360f3e [AutoDiff] Add AnyDifferentiable. (#30928)
Add `AnyDifferentiable`, a type-erased wrapper for `Differentiable`-conforming types.
2020-04-09 22:49:55 -07:00
marcrasi
ddef9292a6 [AutoDiff upstream] DifferentiationUnittest and some e2e tests (#30915)
Adds 2 simple e2e tests and some lit subsitutions and unittest libraries
necessary to support them.
2020-04-09 14:25:31 -07:00
Saleem Abdulrasool
1d7b3a5ba8 Merge pull request #30925 from compnerd/30875
test: repair the Android CI after #30875
2020-04-09 14:16:52 -07:00
Dan Zheng
d4ff5847d0 [AutoDiff upstream] Add AnyDerivative.
Add `AnyDerivative`, a type-erased wrapper for `Differentiable.TangentVector`
associated type implementations.
2020-04-09 11:52:59 -07:00
Saleem Abdulrasool
6f28e54505 test: repair the Android CI after #30875
The added test was not correctly indicated as a running test.
2020-04-09 11:36:41 -07:00
Dan Zheng
65ab642b1a [AutoDiff upstream] Add Differentiable.zeroTangentVector.
Add `Differentiable.zeroTangentVectorInitializer` protocol requirement and
`Differentiable.zeroTangentVector` default implementation.
2020-04-09 11:15:18 -07:00
Dan Zheng
5b943963cc Merge pull request #30918 from dan-zheng/autodiff-forward-mode
[AutoDiff] Enable forward-mode differentiation tests.
2020-04-09 10:01:06 -07:00
marcrasi
d99d8da956 [AutoDiff upstream] handle differentiable_function in DiagnoseInvalidEscapingCaptures (#30909) 2020-04-09 09:34:24 -07:00
Dan Zheng
3f06912fd9 [AutoDiff] Enable forward-mode differentiation tests.
Resolves TF-1237 TODO comments.
2020-04-09 01:49:25 -07:00
Dan Zheng
f22d923340 [AutoDiff] Remove obsolete TODO comments. 2020-04-09 01:10:43 -07:00
Dan Zheng
3999b8b23f Merge pull request #30912 from dan-zheng/fix-synthesized-file-unit
Fix SynthesizedFileUnit serialization and TBDGen issues.
2020-04-09 00:30:26 -07:00
Dan Zheng
75548c30be Merge pull request #30875 from apple/autodiff-upstream-stdlib-differentiation
[AutoDiff upstream] Add stdlib `Differentiable` conformances and derivatives.
2020-04-08 22:31:47 -07:00
Dan Zheng
c142fcf6e2 [AutoDiff] Add SynthesizedFileUnit TBDGen/serialization tests.
Upstream `SynthesizedFileUnit` failing tests from TF-1239.
2020-04-08 21:22:06 -07:00
Argyrios Kyrtzidis
1b26b96f05 Merge pull request #30897 from dan-zheng/autodiff-cleanup
[AutoDiff] Clean up syntax.
2020-04-08 21:07:01 -07:00
Dan Zheng
4495f6b87d Fix tests for 32-bit platforms.
- Remove unnecessary imports from test/AutoDiff/stdlib/simd.swift.
- Use platform-correct `Builtin` integer type in
  `PullbackEmitter::getArrayAdjointElementBuffer`.
2020-04-08 19:16:00 -07:00
Dan Zheng
01db90dd61 Merge branch 'master' of github.com:apple/swift into autodiff-upstream-stdlib-differentiation 2020-04-08 14:12:03 -07:00
Dan Zheng
9cfe91aa01 Merge pull request #30877 from dan-zheng/SR-12548-fix
[SILOptimizer] Disable `SILCombiner::visitPartialApplyInst` for method callees.
2020-04-08 14:09:58 -07:00
marcrasi
0340e9a84e Merge pull request #30887 from marcrasi/ad-upstream-tests
[AutoDiff upstream] witness table IRGen test
2020-04-08 13:55:18 -07:00
Dan Zheng
73f0560af5 [AutoDiff] Standardize on "differentiability parameter" terminology.
Change "differentiation parameter" to "differentiability parameter", matching
terminology in docs/DifferentiableProgramming.md.
2020-04-08 13:01:17 -07:00
Dan Zheng
2eb460de4d [AutoDiff upstream] Add forward-mode differentiation. (#30878)
JVP functions are forward-mode derivative functions. They take original
arguments and return original results and a differential function. Differential
functions take derivatives wrt arguments and return derivatives wrt results.

`JVPEmitter` is a cloner that emits JVP and differential functions at the same
time. In JVP functions, function applications are replaced with JVP function
applications. In differential functions, function applications are replaced
with differential function applications.

In JVP functions, each basic block takes a differential struct containing callee
differentials. These structs are consumed by differential functions.
2020-04-08 11:29:21 -07:00
Marc Rasi
105e3b298c [AutoDiff upstream] witness table IRGen test 2020-04-08 11:14:21 -07:00
Dan Zheng
606c070e11 [SILOptimizer] Disable SILCombiner::visitPartialApplyInst for method callees.
Disable `SILCombiner::visitPartialApplyInst` from rewriting `partial_apply` with
with `@convention(method)` callee to `thin_to_thick_function`.

This fixes SIL verification errors: `thin_to_thick_function` only supports
`@convention(thin)` operands.

Resolves SR-12548.
2020-04-08 12:40:44 +00:00
Dan Zheng
06f52182c4 Add negative test for SR-12548.
Test SR-12548: `SILCombiner::visitPartialApplyInst` rewrites `partial_apply`
with `@convention(method)` callee to `thin_to_thick_function`.

This produces a SIL verification error: `thin_to_thick_function` only supports
`@convention(thin)` operands.
2020-04-08 12:29:29 +00:00
Dan Zheng
b6d765348d [AutoDiff upstream] Test differentiable collection higher-order functions.
Test `Array.differentiableMap(_:)` and `Array.differentiableReduce(_:_:)`.
2020-04-08 02:50:50 -07:00
Dan Zheng
d599105715 [AutoDiff upstream] Fix stdlib differentiation tests.
Temporarily disable not-yet-supported differentiation tests:

- Forward-mode differentiation.
  - TF-1237: to be upstreamed.
- `Differentiable.zeroTangentVector`.
  - TF-1238: to be upstreamed.
- `SIMD.sum` differentiation.
  - TF-1103: `@_alwaysEmitIntoClient` derivative registration.
2020-04-08 02:50:43 -07:00
Dan Zheng
e377436169 Merge branch 'master' of github.com:apple/swift into autodiff_upstream_conformances_derivatives_master 2020-04-08 02:49:17 -07:00
Dan Zheng
da36555aa5 [AutoDiff upstream] Gardening.
- Standardize filenames: `XXXDifferentiation.swift`.
  - Use Pascal or snake case consistently.
- Formatting changes.
2020-04-08 02:49:12 -07:00
Dan Zheng
f27f1cde66 Merge pull request #30863 from dan-zheng/synthesized-file-unit
[AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
2020-04-07 23:48:09 -07:00
Dan Zheng
f7a9eed4de [AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
Add implicit declarations generated by the differentiation transform to a
`SynthesizedFileUnit` instead of an ad-hoc pre-existing `SourceFile`.

Resolves TF-1232: type reconstruction for AutoDiff-generated declarations.

Previously, type reconstruction failed because retroactively adding declarations
to a `SourceFile` did not update name lookup caches.
2020-04-07 18:29:34 -07:00
marcrasi
eefe9a083c Merge pull request #30851 from apple/derivative-attr-serialization
[AutoDiff] SR-12526: cross-module @derivative deserialization
2020-04-07 17:23:47 -07:00
Marc Rasi
7abf8ae305 actually set the lazy resolver 2020-04-07 15:05:27 -07:00
Marc Rasi
2d1436e8d2 fix SR-12526 test 2020-04-07 10:26:57 -07:00
Dan Zheng
fccfa29240 [AutoDiff upstream] Update LoadableByAddress. (#30825)
Update LoadableByAddress to handle AutoDiff-related instructions:
- `differentiable_function`
- `differentiable_function_extract`
- `linear_function`
- `linear_function_extract`
- `differentiability_witness_function`
2020-04-06 16:47:38 -07:00