-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Labels
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfmultiple filesFlag: An issue whose reproduction requires multiple filesFlag: An issue whose reproduction requires multiple filesserializationArea → compiler: Serialization & deserializationArea → compiler: Serialization & deserializationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
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()
^
Metadata
Metadata
Assignees
Labels
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfmultiple filesFlag: An issue whose reproduction requires multiple filesFlag: An issue whose reproduction requires multiple filesserializationArea → compiler: Serialization & deserializationArea → compiler: Serialization & deserializationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis