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] Fix @differentiable attribute type checking crasher. (#26405)
Diagnose invalid `Differentiable` conformances during `@differentiable`
attribute type checking. Reject conformances that cannot resolve a
`TangentVector` witness type.
Resolves TF-521.
// TF-521: Test invalid `@differentiable` attribute due to invalid
755
+
// `Differentiable` conformance (`TangentVector` does not conform to
756
+
// `AdditiveArithmetic`).
757
+
structTF_521<T:FloatingPoint>{
758
+
varreal:T
759
+
varimaginary:T
760
+
761
+
// expected-error @+1 {{can only differentiate functions with results that conform to 'Differentiable', but 'TF_521<T>' does not conform to 'Differentiable'}}
762
+
@differentiable(vjp: _vjpInit where T: Differentiable, T ==T.TangentVector)
763
+
init(real:T=0, imaginary:T=0){
764
+
self.real = real
765
+
self.imaginary = imaginary
766
+
}
767
+
}
768
+
// expected-error @+2 {{type 'TF_521<T>' does not conform to protocol 'Differentiable'}}
769
+
// expected-note @+1 {{do you want to add protocol stubs}}
0 commit comments