Provide half-away-from-zero rounding mode on Tensor::round #54201
Labels
enhancement
Not as big of a feature, but technically not a bug. Should be easy to fix
function request
A request for a new function or the addition of new arguments/modes to an existing function.
module: cpp
Related to C++ API
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃殌 Feature
Currently Tensor::round rounds half-to-nearest-even, however, some platforms and tools round half-away-from-zero by default. One of such examples is XLA, which uses half-away-from-zero by default (and half-to-nearest-even is emulated in libraries like JAX).
Operations like Tensor::div already support
rounding_mode
as an option, so hopefully a similar option - but with different values - can be added to round.Motivation
I am writing bindings for both PyTorch and XLA for the Elixir programming language and one of the discrepancies we found were the rounding operations. Both XLA and Elixir rounds half-away-from-zero, which is inconsistent to PyTorch default behaviour (which actually aligns with Python 3).
Pitch
The current behaviour rounds both
-0.5
and0.5
to0
. A new rounding option should round them to-1.0
and1.0
respectively.Thank you!
cc @yf225 @glaringlee
The text was updated successfully, but these errors were encountered: