-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] [AutoDiff] Synthesize more @_fieldwiseProductSpace
attributes.
#21863
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
[Sema] [AutoDiff] Synthesize more @_fieldwiseProductSpace
attributes.
#21863
Conversation
When all members have all `Differentiable` associated types equal to `Self`, a single member `AllDifferentiableVariables` struct is synthesized. Later, `TangentVector` and `CotangentVector` typealiases are generated that forward to it. This patch proactively generates `TangentVector` and `CotangentVector` aliases with the `@_fieldwiseProductSpace` attribute.
@swift-ci Please test tensorflow |
What if, in a type whose members’ tangent/cotangent/alldiffable equals the original type, the user explicitly declares ‘typealias TangentVector = AllDifferentiableVariables’? Will synthesis still run? |
Not currently, but it's a simple fix to do so. EDIT: Sorry, I was mistaken. The following simple program fails: // test.swift
public struct Foo : Differentiable {
public var a: Float
typealias TangentVector = AllDifferentiableVariables
}
Referencing |
@swift-ci Please test tensorflow |
macOS CI fails mysteriously, twice in a row now. @shahmishal Do you have any idea what's going on? Thanks! |
Looks like it lost connection:
|
@swift-ci Please test tensorflow |
The current synthesis behavior is fine. Not running synthesis is better than running and forgetting to add @fieldwise. |
When all members have all
Differentiable
associated types equal toSelf
,a single member
AllDifferentiableVariables
struct is synthesized.Later,
TangentVector
andCotangentVector
typealiases are generated thatforward to it.
This patch proactively generates
TangentVector
andCotangentVector
aliaseswith the
@_fieldwiseProductSpace
attribute.