Add new rounding mechanism
To be merged after !358 (merged).
Introduces a new rounding mechanism in Aidge: the generic Aidge::round()
function, which should always be used. The available rounding modes are the following:
enum class RoundingMode {
// Directed rounding
Down, // std::floor
Up, // std::ceil
TowardZero, // std::trunc
AwayFromZero,
// Round to nearest
HalfDown, // std::rint or std::nearbyint with FE_DOWNWARD mode
HalfUp, // std::rint or std::nearbyint with FE_UPWARD mode
HalfTowardZero, // std::rint or std::nearbyint with FE_TOWARDZERO mode
HalfAwayFromZero, // std::round and std::rint or std::nearbyint with FE_TONEAREST mode
HalfToEven, // Python round() and numpy.round()
HalfToOdd
};
The following operators have now a RoundingMode
attribute (that is only meaningful when their output type is integral):
-
AvgPooling
; -
GlobalAveragePooling
; -
ReduceMean
; -
Round
(which has the same behavior as ONNXRound
whenRoundingMode
is set toHalfToEven
. This is the case when importing an ONNX model).
HalfAwayFromZero
, the same as C++ std::round()
, but not the same as the default Python rounding, which is HalfToEven
.
Implementations that do not yet support output integral type can ignore this attribute (as with the current implementation of these operators in CUDA).
Edited by Olivier BICHLER