-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff upstream] Add differential operators and some utilities. #30711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test |
Build error: 04:25:08 Failed to reconstruct type for $sq_xIelgnr_D
04:25:08 Original type:
04:25:08 (sil_function_type type=@differentiable(linear) @callee_guaranteed (@in_guaranteed τ_0_1) -> @out τ_0_0
04:25:08 (input=generic_type_param_type depth=0 index=1)
04:25:08 (result=generic_type_param_type depth=0 index=0)
04:25:08 (substitution_map generic_signature=<nullptr>)
04:25:08 (substitution_map generic_signature=<nullptr>))
04:25:08 Stack dump:
04:25:08 0. Program arguments: /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/bin/swift -frontend -c /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/Differentiation/Differentiable.swift /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/Differentiation/DifferentialOperators.swift /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/Differentiation/DifferentiationUtilities.swift -disable-objc-attr-requires-foundation-module -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/./lib/swift/macosx -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/../../../Developer/Library/Frameworks -warn-implicit-overrides -enable-library-evolution -g -module-cache-path /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/./module-cache -module-link-name swift_Differentiation -parse-stdlib -resource-dir /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/./lib/swift -swift-version 5 -O -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -enable-ownership-stripping-after-serialization -enforce-exclusivity=unchecked -enable-experimental-differentiable-programming -parse-as-library -module-name _Differentiation -o /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/buildbot_incremental/swift-macosx-x86_64/stdlib/public/Differentiation/OSX/x86_64/_Differentiation.o -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements
04:25:08 1. Apple Swift version 5.3-dev (LLVM 6287796090, Swift 649b83dfe6)
04:25:08 2. While evaluating request IRGenWholeModuleRequest(IR Generation for module _Differentiation)
04:25:08 3. While emitting IR SIL function "@$s16_Differentiation9transpose2ofxq_XIq_xXI_tAA14DifferentiableRz13TangentVectorAaDPQzRszAaDR_AeFQy_Rs_r0_lF".
04:25:08 for 'transpose(of:)' (at /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/Differentiation/DifferentialOperators.swift:22:8)
04:25:08 0 swift 0x000000010828e1d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
04:25:08 1 swift 0x000000010828d158 llvm::sys::RunSignalHandlers() + 248
04:25:08 2 swift 0x000000010828e7cd SignalHandler(int) + 285
04:25:08 3 libsystem_platform.dylib 0x00007fff69c2e5fd _sigtramp + 29
04:25:08 4 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338741783072
04:25:08 5 libsystem_c.dylib 0x00007fff69b00808 abort + 120
04:25:08 6 swift 0x00000001083c8526 (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) (.cold.2) + 102
04:25:08 7 swift 0x000000010429421a (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) + 3626 I haven't been able to reproduce it on macOS... |
I think that may be https://github.com/apple/swift/blob/9c4212a49b483f455bcd1caf4de6f2ef12a5ad54/include/swift/AST/IRGenOptions.h#L333. I don't know how hard that is to fix for real. We obviously can't check |
* Add all [differential operators](https://github.com/apple/swift/blob/master/docs/DifferentiableProgramming.md#list-of-differential-operators). * Add `withoutDerivative(at:)`, used for efficiently stopping the derivative propagation at a value and causing the derivative at the value to be zero. * Add utility `differentiableFunction(from:)`, used for creating a `@differentiable` function from an original function and a derivative function. Mostly work done by @marcrasi and @dan-zheng. Partially resolves TF-843. TODO: * Add `AnyDerivative`. * Add `Array.differentiableMap(_:)` and `differentiableReduce(_:_:)`.
Handle differentiability kind (`@differentiable` and `@differentiable(linear)`) in `ASTBuilder::createImplFunctionType`. Resolves TF-1225.
391a586
to
64d0e76
Compare
I have updated the included test to test all the reverse mode differential operators. (Forward mode ones are less important so I don't think it's worth it to spend more time writing tests for them now.) This is ready now, so I'll do a test then merge it. |
@swift-ci please test |
@swift-ci please smoke test |
Build failed |
Build failed |
Thanks for taking over the work! |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci please smoke test macos |
@swift-ci please smoke test macOS |
Hmm, |
@swift-ci please smoke test macOS |
b26f252
to
013a66b
Compare
Aha, it was a python lint error, not actually a flake. Now it should be fixed. |
@swift-ci please smoke test |
@swift-ci please smoke test |
We broke the long-test: https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04-long-test/5804/ . I have a temporary fix that should make the CI green again: #30756 |
withoutDerivative(at:)
, used for efficiently stopping the derivative propagation at a value and causing the derivative at the value to be zero.differentiableFunction(from:)
, used for creating a@differentiable
function from an original function and a derivative function.Mostly work done by @marcrasi and @dan-zheng.
Partially resolves TF-843.
TODO:
AnyDerivative
.Array.differentiableMap(_:)
anddifferentiableReduce(_:_:)
.