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
Fix integer true-divide silently truncating instead of promoting to float (#32)
Summary
Integer true-divide (x / y, torch.true_divide, torch.div(x, y, rounding_mode=None)) was dividing operands as integers first and only casting the truncated result to float afterward, silently dropping the fractional part on every backend. Per PyTorch's promotion rules, integer operands must be promoted to float before dividing.
div.Tensor/div.Scalar/true_divide.Tensor were wired to the generic replace_binary_ops handler, which keeps same-kind integers as integers (correct for add/sub/mul, wrong for true divide). Re-pointed them to replace_truediv, which already promotes to the node's real float output type before dividing.
Fixed the same latent bug in replace_div_tensor_mode's rounding_mode=None branch.
Grouped div-family tests into a TestDiv class (matches existing TestCopy-style convention) and added regression tests for the integer cases above.
floordiv/mod/fmod/rounding_mode="floor"/"trunc" were already correct and untouched.
Test plan
python unit test
0 commit comments