Description
Previous ID | SR-14235 |
Radar | None |
Original Reporter | @dan-zheng |
Type | Bug |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, AutoDiff |
Assignee | None |
Priority | Medium |
md5: 1c36955f37f690185a211308ac4034a9
Issue Description:
// a.swift
@differentiable
func crossFileDerivativeAttr<T: DifferentiableTensorProtocol>(
_ input: T
) -> T {
return input.identityDerivativeAttr()
}
import _Differentiation
protocol DifferentiableTensorProtocol: Differentiable {}
extension DifferentiableTensorProtocol {
func identityDerivativeAttr() -> Self { self }
// Test cross-file `@derivative` attribute.
@derivative(of: identityDerivativeAttr)
func vjpIdentityDerivativeAttr() -> (
value: Self, pullback: (TangentVector) -> TangentVector
) {
fatalError()
}
}
The error occurs because AbstractFunctionDecl::getDerivativeConfigurations
is not sufficiently requestified to type-check @derivative
attributes in other files.
$ swiftc a.swift b.swift
a.swift:20:16: error: expression is not differentiable
return input.identityDerivativeAttr()
^
a:20:16: note: cannot differentiate functions that have not been marked '@differentiable' and that are defined in other files
return input.identityDerivativeAttr()
^