Remainder: std::fmod vs aten remainder (#90)
Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/90 There is a slight difference in how std::fmod (which we use to compute float remainder) works compared to how aten determines remainders. For ```x mod y``` std::fmod: (From https://en.cppreference.com/w/cpp/numeric/math/fmod) > The returned value has the same sign as x and is less than y in magnitude. On the other hand, aten remainder always matches the sign of y To correct this, we need to add y to the remainder when one but not both of x and y is negative and the remainder is not 0 Reviewed By: digantdesai Differential Revision: D48532672 fbshipit-source-id: 9be635795bc9b1fab94fcbcd3c31f9d96d08cfcf
S
Salil Desai committed
6a703ce85b6ce3208e8c97dc459a77fefa2883e2
Parent: da53c68
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 9/7/2023, 9:56:02 PM