You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AutoDiff] [stdlib] Add differentiable map and reduce methods on 'Array'. (#26023)
Add variants of map and reduce that take a `@differentiable` closure and are themselves differentiable.
```swift
extension Array {
@differentiable(wrt: self)
func differentiableMap<Result: Differentiable>(
_ body: @differentiable (Element) -> Result
) -> [Result]
@differentiable(wrt: (self, initialResult))
func differentiableReduce<Result: Differentiable>(
_ initialResult: Result,
_ nextPartialResult: @differentiable (Result, Element) -> Result
) -> Result
}
```
Also make `Array.DifferentiableView` conform to `ExpressibleByArrayLiteral` so that tests and user code are easier to write.
0 commit comments