Even though the P protocol has declared that 'var a' is differentiable, using it below fails:
import Foundation
import _Differentiation
protocol P: Differentiable {
@differentiable(reverse)
var a: Double {get set}
}
struct S: P {
var a: Double = 3
}
// this works when something concrete is held, setA is differentiable
//struct Holder: Differentiable {
// var p: S
//
// @differentiable(reverse)
// mutating func setA(a: Double) {
// self.p.a = a
// }
//}
// this doesn't work, after genericizing the Holder,
struct Holder<ConcreteP: P>: Differentiable {
var p: ConcreteP
@differentiable(reverse)
mutating func setA(a: Double) {
self.p.a = a // "Expression is not differentiable" at line 'self.p.a = a' even though P.a has been marked @differentiable
}
}
Environment
7/7 snapshotAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Bug, AutoDiff | |Assignee | kaiau.tk@gmail.com (JIRA) | |Priority | Medium | md5: f5d010cdf3f202bb1c50f71d8f3ee6b4Issue Description:
Even though the P protocol has declared that 'var a' is differentiable, using it below fails: