Commit Graph

656 Commits

Author SHA1 Message Date
Saleem Abdulrasool
281d5198ce test: repair the separate_tangent_type test on Windows 2020-04-26 11:44:41 -07:00
marcrasi
207958c12f [AutoDiff] fix tests to pass on tensorflow branch (#31264) 2020-04-24 09:53:05 -07:00
ematejska
4cd68edf8c [Autodiff upstream] Add DifferentiabilityWitnessDevirtualizer SILOptimizer pass (#30984)
Add DifferentiabilityWitnessDevirtualizer: an optimization pass that
devirtualizes `differentiability_witness_function` instructions into
`function_ref` instructions.

Co-authored-by: Dan Zheng <danielzheng@google.com>
2020-04-23 02:13:05 -07:00
marcrasi
a48880d13f [AutoDiff upstream] add more validation tests (#31190) 2020-04-22 17:31:11 -07:00
Dan Zheng
1d4ba599f2 [AutoDiff] Add negative test for SR-12641. (#31207)
Add negative test exposing SR-12641: SILGen verification error regarding
reabstraction thunking for `@differentiable` functions.
2020-04-22 16:19:22 -07:00
Dan Zheng
8357c188eb [AutoDiff] Mangle @noDerivative parameters. (#31201)
Mangle `@noDerivative` parameters to fix type reconstruction errors.
Resolves SR-12650. The new mangling is non-breaking.

When differentiation supports multiple result indices and `@noDerivative`
results are added, we can reuse some of this mangling support.
2020-04-22 12:38:21 -07:00
marcrasi
433821b7d1 [AutoDiff upstream] add more validation tests (#31112) 2020-04-21 15:30:25 -07:00
marcrasi
bc0dd81950 [AutoDiff upstream] SILOptimizer tests (#31114) 2020-04-17 20:46:47 -07:00
Pavel Yaskevich
8d392b48d0 Revert "[opt] remove trivially dead instructions in mandatory combine" 2020-04-16 10:26:29 -07:00
Michael Gottesman
6998ad9c70 Merge pull request #30429 from zoecarver/optimize/remove-dead-in-mand-combine
[opt] remove trivially dead instructions in mandatory combine
2020-04-15 13:33:03 -07:00
zoecarver
4cc98f0070 [opt] Remove trivially dead instructions in mandatory combine.
Failing tests that do not test mandatory combine are updated to skip
the mandatory combine pass. Othere tests are updated to use otherwise
removed values.
2020-04-14 23:39:11 -07:00
Dan Zheng
3198436221 [AutoDiff] Add REQUIRES: CPU=x86_64 to IRGen test. 2020-04-14 20:01:55 +00:00
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