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
kovdan01 opened this issue
May 26, 2025
· 3 comments
Labels
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfSILGenArea → compiler: The SIL generation stageswift 6.2unexpected behaviorBug: Unexpected behavior or incorrect output
For some functions with ternary operators, derivative is calculated incorrectly (ternary function in reproducer). When changing ternary operators to if statements, the calculation becomes correct (ifelse function in reproducer). The function results themselves are calculated correctly for both cases.
Particularly, for the reproducer, the expected gradient value with x0<=x1 is (0,0), while we get (1/x0,0).
The SIL of ternary and ifelse functions themselves (unoptimized, generated w/o -O flag) is exactly the same. The reverse-mode derivatives look almost identical, so the problem is probably in incorrectly generated pullback (the pullbacks are pretty different). I'll publish an update here when I find the particular incorrect place in the pullback of ternary.
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfSILGenArea → compiler: The SIL generation stageswift 6.2unexpected behaviorBug: Unexpected behavior or incorrect output
Uh oh!
There was an error while loading. Please reload this page.
Description
For some functions with ternary operators, derivative is calculated incorrectly (
ternary
function in reproducer). When changing ternary operators to if statements, the calculation becomes correct (ifelse
function in reproducer). The function results themselves are calculated correctly for both cases.Particularly, for the reproducer, the expected gradient value with
x0<=x1
is(0,0)
, while we get(1/x0,0)
.Reproduction
Output:
Expected behavior
Gradient value for
ternary
andifelse
should be equal (particularly, forx0<=x1
, we should have (0,0) gradient value for both).Environment
Swift version 6.2-dev (LLVM dc6a0c133fea15e, Swift efecad888e1731c)
Target: x86_64-unknown-linux-gnu
Build config: +assertions
Additional information
No response
The text was updated successfully, but these errors were encountered: