Commit Graph

125 Commits

Author SHA1 Message Date
Dan Zheng
d5d076db6a [AutoDiff] Support differentiation of branching cast instructions.
Support differentiation of `is` and `as?` operators.

These operators lower to branching cast SIL instructions, requiring control
flow differentiation support.

Resolves SR-12898.
2020-05-28 12:54:38 -07:00
Dan Zheng
24de636822 [AutoDiff] Re-enable control_flow.swift test.
This test was disabled in SR-12741 due to iphonesimulator-i386 failures.
Enabling the test on other platforms is important to prevent regressions.
2020-05-28 12:41:55 -07:00
Dan Zheng
e3938b5c7d [AutoDiff] Fix Array.append(_:) pullback.
The derivative wrt `self` should drop the last element from the incoming seed.

Example:
- Incoming seed: [1, 2, 3, 4]
- Derivative wrt `self`: [1, 2, 3]
- Derivative wrt appended element: 4
2020-05-14 09:27:50 -07:00
Dan Zheng
2e690e2d5e [AutoDiff] NFC: garden array differentiation.
Use consistent variable naming. Reorganize code.
2020-05-14 09:27:50 -07:00
Dan Zheng
212c89d869 [AutoDiff] NFC: add clarifying comments to test. 2020-05-11 01:43:43 -07:00
Dan Zheng
96f3f6fbcb [AutoDiff] Finish wrapped property differentiation support.
Add special-case VJP generation support for "semantic member accessors".
This is necessary to avoid activity analysis related diagnostics and simplifies
generated code.

Fix "wrapped property mutability" check in `Differentiable` derived conformnances.
This resolves SR-12642.

Add e2e test using real world property wrappers (`@Lazy` and `@Clamping`).
2020-05-10 15:55:29 -07:00
Dan Zheng
1f5818a5e9 [AutoDiff] Support property wrapper differentiation.
Support differentiation of property wrapper wrapped value getters and setters.

Create new pullback generation code path for "semantic member accessors".
"Semantic member accessors" are attached to member properties that have a
corresponding tangent stored property in the parent `TangentVector` type.

These accessors have special-case pullback generation based on their semantic
behavior. Currently, only getters and setters are supported.

This special-case pullback generation is currently used for stored property
accessors and property wrapper wrapped value accessors. In the future, it can
also be used to support `@differentiable(useInTangentVector)` computed
properties: SR-12636.

User-defined accesors cannot use this code path because they may use custom
logic that does not semantically perform a member access.

Resolves SR-12639.
2020-05-09 16:43:06 -07:00
Andrew Trick
4150dbd2ed SR-12741: disable AutoDiff/validation-test/control_flow.swift. 2020-05-06 01:08:06 -07:00
Dan Zheng
bab23d8298 SILOptimizer: fix partial_apply optimization. (#31552)
`partial_apply` can be rewritten to `thin_to_thick_function` only if the
specialized callee is `@convention(thin)`.

This condition is newly exercised by the differentiation transform:
`{JVP,VJP}Emitter::visitApplyInst` generates argument-less `partial_apply`
with `@convention(method)` callees.

Resolves SR-12732.
2020-05-05 09:09:42 -07:00
Andrew Trick
2f1b21d64c Temporarily disable 3 AutoDiff tests: SR-12732
https://bugs.swift.org/browse/SR-12732
3 AutoDiff test failures: crashing in SIL verification

Failing Tests (3):
06:26:12     Swift(macosx-x86_64) :: AutoDiff/validation-test/derivative_registration.swift
06:26:12     Swift(macosx-x86_64) :: AutoDiff/validation-test/custom_derivatives.swift
06:26:12     Swift(macosx-x86_64) :: AutoDiff/stdlib/derivative_customization.swift

Possibly from:

commit 738ef730e8
Author: Dan Zheng <danielzheng@google.com>
Date:   Mon May 4 00:44:48 2020 -0700

    [AutoDiff] Fix `@differentiable` attribute derivative configurations. (#31524)
2020-05-04 14:34:51 -07:00
Saleem Abdulrasool
debc627ce5 Merge pull request #31332 from compnerd/custom-derivative
test: repair the `custom_derivative` test
2020-04-26 16:11:56 -07:00
Saleem Abdulrasool
fef09af0b1 Merge pull request #31330 from compnerd/autodiff-module
test: repair the `separate_tangent_type` test on Windows
2020-04-26 16:10:45 -07:00
Saleem Abdulrasool
54e4994f6f test: repai the custom_derivative test
The test imports the C library for the math library.  Add a case for
Windows.
2020-04-26 11:56:03 -07:00
Saleem Abdulrasool
e18a61f1a4 test: repair the cross_module_derivative_attr test
Convert to dynamic libraries, fix the run lines, remove the workaround
for the TBD validation.
2020-04-26 11:53:03 -07:00
Saleem Abdulrasool
281d5198ce test: repair the separate_tangent_type test on Windows 2020-04-26 11:44:41 -07:00
marcrasi
a48880d13f [AutoDiff upstream] add more validation tests (#31190) 2020-04-22 17:31:11 -07:00
marcrasi
433821b7d1 [AutoDiff upstream] add more validation tests (#31112) 2020-04-21 15:30:25 -07:00
marcrasi
99356cd9f4 [AutoDiff upstream] add more differentiation tests (#30933) 2020-04-13 09:40:45 -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
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
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
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
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
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
Dan Zheng
c142fcf6e2 [AutoDiff] Add SynthesizedFileUnit TBDGen/serialization tests.
Upstream `SynthesizedFileUnit` failing tests from TF-1239.
2020-04-08 21:22:06 -07:00