Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Extend 'Array' and 'Array.DifferentiableView' for aggregate math and collection protocols. #347

Merged
merged 1 commit into from
Jul 10, 2019

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Jul 10, 2019

Conform Array and Array.DifferentiableView to aggregate math protocols and collection protocols so that array derivatives can be handled by optimizers.

  • Conform Array to EleemntaryFunctions where Element conforms.
  • Conform Array.DifferentiableView to EleemntaryFunctions where Element conforms.
  • Conform Array.DifferentiableView to VectorProtocol where Element conforms.
  • Conform Array.DifferentiableView to PointwiseMultiplicative where Element conforms.
  • Conform Array.DifferentiableView to MutableCollection, RandomAccessCollection, and RangeReplaceableCollection.

Some (if not all) of these belong to the standard library, but adding these to stdlib will cause IRGen to crash at the moment.

This unblocks building fast.ai notebooks against new optimizer implementations.

@rxwei rxwei added the enhancement New feature or request label Jul 10, 2019
@rxwei rxwei requested review from eaplatanios and dan-zheng July 10, 2019 17:49
@rxwei rxwei changed the title Extend 'Array' and 'Array.DifferentiableView' for aggregate math. Extend 'Array' and 'Array.DifferentiableView' for aggregate math and collection protocols. Jul 10, 2019
@eaplatanios
Copy link
Contributor

@rxwei do you know why it causes IRGen to crash?

@rxwei
Copy link
Contributor Author

rxwei commented Jul 10, 2019

@eaplatanios I haven't investigated this yet. Has something to do with subscript(_:). I'll push a WIP branch.

@rxwei
Copy link
Contributor Author

rxwei commented Jul 10, 2019

swiftlang/swift#26062

Conform `Array` and `Array.DifferentiableView` to aggregate math protocols and collection protocols so that array derivatives can be handled by optimizers.

* Conform `Array` to `EleemntaryFunctions` where `Element` conforms.
* Conform `Array.DifferentiableView` to `EleemntaryFunctions` where `Element` conforms.
* Conform `Array.DifferentiableView` to `VectorProtocol` where `Element` conforms.
* Conform `Array.DifferentiableView` to `PointwiseMultiplicative` where `Element` conforms.
* Conform `Array.DifferentiableView` to `MutableCollection`, `RandomAccessCollection`, and `RangeReplaceableCollection`.

Some (if not all) of these belong to the standard library, but adding these to stdlib will cause IRGen to crash at the moment.

This unblocks building fast.ai notebooks against new optimizer implementations.
@rxwei rxwei merged commit 4656fe7 into tensorflow:master Jul 10, 2019
@rxwei rxwei deleted the stdlib-exts branch July 10, 2019 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants