-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
AutoDiffSILbugA 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 itselfswift 6.0unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
Description
The code below should produce identical gradients, however, it does not
Reproduction
import _Differentiation
@differentiable(reverse)
func square(y: Double) -> Double? {
return y * y
}
@differentiable(reverse)
func square2(y: Double?) -> Double {
return y! * y!
}
print(valueWithGradient(at: 42.0, of: {y in square(y:y)!}))
print(valueWithGradient(at: 42.0, of: {y in square2(y:y)}))
Expected behavior
(value: 1764.0, gradient: 84.0)
(value: 1764.0, gradient: 84.0)
Environment
Swift version 6.0-dev (LLVM 76ba61e88550d3b, Swift 9470ad7)
Target: arm64-apple-macosx13.0
Additional information
Currently we are printing:
(value: 1764.0, gradient: 84.0)
(value: 1764.0, gradient: 42.0)
Metadata
Metadata
Assignees
Labels
AutoDiffSILbugA 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 itselfswift 6.0unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output