Skip to content
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

[SR-12637] Wrapped property differentiation #55081

Open
dan-zheng opened this issue Apr 21, 2020 · 0 comments
Open

[SR-12637] Wrapped property differentiation #55081

dan-zheng opened this issue Apr 21, 2020 · 0 comments
Labels
AutoDiff compiler The Swift compiler in itself new feature

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-12637
Radar None
Original Reporter @dan-zheng
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, AutoDiff
Assignee None
Priority Medium

md5: 002347d6b9b2f32ef740d86432529a06

Sub-Tasks:

  • SR-12638 Differentiable derived conformances: handle wrapped properties
  • SR-12639 Differentiation transform: support wrapped value getters/setters
  • SR-12640 Differentiation transform: support wrapped value modify accessors

relates to:

  • TF-1254 Forward-mode property wrapper differentiation

Issue Description:

Differentiation should include special support for property wrappers.
Synthesized TangentVector structs should include wrapped values' TangentVectors as stored properties.

todo: fill in details, update differentiable programming manifesto

Example:

import _Differentiation

@propertyWrapper
struct Wrapper<Value> {
  var wrappedValue: Value
}
// No `Differentiable` conformance should be necessary necessary:
// extension Wrapper: Differentiable where Value: Differentiable {}

struct Struct {
  @Wrapper var x: Float = 0
  // Compiler generates:
  // var _x: Wrapper<Float>
  // var x: Float {
  //   get { _x.wrappedValue }
  //   set { _x.wrappedValue = newValue }
  // }

  @Wrapper var y: Float = 1
  var z: Float = 2
}

extension Struct: Differentiable {
  // Compiler currently synthesizes:
  // struct TangentVector: Differentiable & AdditiveArithmetic {
  //   var x: Wrapper<Float>.TangentVector
  //   var y: Wrapper<Float>.TangentVector
  //   var z: Float
  //   ...
  // }

  // Compiler should synthesize:
  // struct TangentVector: Differentiable & AdditiveArithmetic {
  //   var x: Float
  //   var y: Float
  //   var z: Float
  //   ...
  // }
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff compiler The Swift compiler in itself new feature
Projects
None yet
Development

No branches or pull requests

1 participant