-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
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.
Description
Description
The following code does not compile giving the following error diagnostic:
Function is not differentiable
Differentiated functions in '@inlinable' functions must be marked '@differentiable' or have a public '@derivative'; this is not possible with a closure, make a top-level function instead
This is incorrect however as the function itself is not a closure and is differentiable.
Reproduction
import _Differentiation
public struct Solution2<Thing: Differentiable & FloatingPoint>: Differentiable where Thing.TangentVector == Thing {
@inlinable
public static func optimization() -> Thing {
var initial = Thing.zero
let (_, delta) = valueWithGradient(at: initial, of: simulationWithLoss)
initial.move(by: delta)
return initial
}
@inlinable
@differentiable(reverse)
static func simulationWithLoss(input: Thing) -> Thing {
return input // implementation
}
}
Expected behavior
Compile without error
Environment
Apple Swift version 6.0-dev (LLVM 097782ee554d9fe, Swift 60bf038)
Target: arm64-apple-macosx14.0
Additional information
No response
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.