-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff upstream] Add stdlib Differentiable
conformances and derivatives.
#30875
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
…ysEmitIntoClient since that's not supported yet.
- Standardize filenames: `XXXDifferentiation.swift`. - Use Pascal or snake case consistently. - Formatting changes.
…m_conformances_derivatives_master
Add `@available` attributes for declarations using `Float16`.
…rmances. Move `Differentiable` conformances out of Differentiable.swift. All `Differentiable` conformances exist in separate files.
…ions. Test `Array.differentiableMap(_:)` and `Array.differentiableReduce(_:_:)`.
@swift-ci Please test |
Build failed |
Build failed |
Two tests fail with |
//===----------------------------------------------------------------------===// | ||
|
||
import Swift | ||
import SwiftShims |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might not need to import SwiftShims on master. What do you think? Aside from that looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there are a couple of test failures still.
…m-stdlib-differentiation
Build failed |
Fixed test failures for 32-bit platforms. |
Build failed |
Build failed |
- Remove unnecessary imports from test/AutoDiff/stdlib/simd.swift. - Use platform-correct `Builtin` integer type in `PullbackEmitter::getArrayAdjointElementBuffer`.
ffbe041
to
4495f6b
Compare
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test macOS |
@swift-ci Please test Windows |
The added test was not correctly indicated as a running test.
test: repair the Android CI after #30875
New files were added in swiftlang#30875 which did not include os(OpenBSD), so add this. add_swift_target_library in AddSwiftStdlib subsequently required modification. _add_target_variant_link_flags likely needs modification as well, but this is better suited to a separate PR.
* [build-script] Add the installation prefix to the toolchain path In several places, it was assumed to be /usr and hard-coded to that. This makes sure the installation prefix actually passed in is used. * [stdlib] StaticString: extension per conformance * Fix @available(macCatalyst N, iOS N+M) bug Previously, availability checking computed a declaration’s availability as the intersection of all @available attributes with active platforms. This meant that Swift would not allow you to use an API that was available earlier in a child platform than in its parent until it was also available in the parent platform. That was incorrect. This PR corrects availability checking to find the most specific @available attribute with an introduced version and use that instead. Fixes rdar://60892534. * [stdlib] Buildfix differentiation for OpenBSD. New files were added in swiftlang#30875 which did not include os(OpenBSD), so add this. add_swift_target_library in AddSwiftStdlib subsequently required modification. _add_target_variant_link_flags likely needs modification as well, but this is better suited to a separate PR. * Handle multiple @available attributes correctly The previous commit broke a promise made by the implementation it replaced: if there were two or more @available(introduced:) attributes for the same platform, the greatest version wins. This commit restores that property while still completely overriding the parent platform’s availability with a child platform’s. * [Diagnostics] Provide anchors on demand instead of storing in `FailureDiagnostic` This decouples `FailureDiagnostic` from expression. * [Diagnostics] Switch `get{Raw}Anchor` to return `TypedNode` In preparation to anchor `ConstraintLocator` from `TypedNode` let's refactor diagnostics (which is the biggest user of locators) to support `TypedNode` instead of `Expr *`. * [Diagnostics] Switch `getConstraintLocator` variants to accept `TypedNode` * [Diagnostics] Switch `getContextualType*` to use `TypedNode` * [Diagnostics] Switch `getType` to use `TypedNode` * [Diagnostics] Resolve const-ness problems introduced by `TypedNode` Since `TypedNode` elements are all marked as `const` diagnostics need to get some of the APIs adjusted to support passing `const Expr *`. * Add compiler option to *disable* warnings-as-errors `-no-warnings-as-errors` This functionality is required for build systems to be able to overload/disable a given Swift project's preference of treating warnings as errors. Resolves rdar://problem/35699776 * [Diagnostics] Add helper functions to work with anchors - `{castTo, getAs, is}Expr` * [Diagnostics] Adjust `getCallInfo` to accept `TypedNode` instead of expression * Avoid unnecessary performTypeChecking() in REPL * [SIL Diagnostics] Improve diagnostics for capture of inout values within escaping autoclosures. <rdar://problem/60551844> * [NFC] Refactor validateTBDIfNeeded Inline the conditions for the astGuaranteedToCorrespondToSIL parameter and clean up the logic here to be more const-friendly. Also try to centralize and document the reasons we skip TBD validation. * Revert "[Darwin] Further restrict inference of the simulator environment" * [Gardening] Const-qualify CompilerInstance::getInvocation() * [NFC] Formalize isModuleExternallyConsumed Yank this parameter and document the historical scope creep of this value. * More StringRef -> std::string conversion fixes. This is needed for the master-next branch. * Devirtualizer: fix a miscompile due to handling of cast instructions. getInstanceWithExactDynamicType returns a new instance and for this the class decl has to be updated. https://bugs.swift.org/browse/SR-12538 rdar://problem/61911112 * [NFC] Fix typo in SerializedModuleLoader.cpp Co-authored-by: Butta <[email protected]> Co-authored-by: Ben Rimmington <[email protected]> Co-authored-by: Brent Royal-Gordon <[email protected]> Co-authored-by: 3405691582 <[email protected]> Co-authored-by: Pavel Yaskevich <[email protected]> Co-authored-by: Artem Chikin <[email protected]> Co-authored-by: Rintaro Ishizaki <[email protected]> Co-authored-by: Ravi Kandhadai <[email protected]> Co-authored-by: Robert Widmann <[email protected]> Co-authored-by: Saleem Abdulrasool <[email protected]> Co-authored-by: Mishal Shah <[email protected]> Co-authored-by: Michael Forster <[email protected]> Co-authored-by: swift-ci <[email protected]> Co-authored-by: Erik Eckstein <[email protected]> Co-authored-by: Ravi Kandhadai <[email protected]> Co-authored-by: Pavel Yaskevich <[email protected]>
Add
Differentiable
conformances and derivatives for stdlib types and functions to the_Differentiation
module. Most upstreaming work done by @ematejska!Differentiable
conformancesFloatingPoint
-conforming types:Float16
,Float
,Double
,Float80
Array
whereElement: Differentiable
SIMD
-conforming types whereScalar: Differentiable & BinaryFloatingPoint, Scalar.TangentVector: BinaryFloatingPoint
Derivatives
+
,+=
,-
,-=
,*
,*=
,/
,/=
Array.init(repeating:count:)
,Array.subscript.get
,Array.+(_:_:)
SIMD
operations:+
,-
,*
,/
exp
,log
,cos
,sin
, etc.Differentiable collection higher-order functions:
Array.differentiableMap(_:)
,Array.differentiableReduce(_:_:)
Add end-to-end derivative tests.
Todos:
Differentiable.zeroTangentVector
protocol requirement and implementations.SIMD.sum
differentiation.@_alwaysEmitIntoClient
derivative registration.