Skip to content
Snippets Groups Projects

Draft: Feat : Add halfway rounding modes to the Round operator

Closed Benjamin Halimi requested to merge rounding_modes into dev
1 unresolved thread

Description

Solves aidge_quantization#81 (closed) for the aidge_backend_cpu module.

Files modified : RoundImpl.hpp, RoundImpl_kernels.cpp and RoundImpl.cpp.

Note : Pipeline currently fails because aidge_core!419 (closed) is not merged yet !

Edited by Benjamin Halimi

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
30 32
31 for (std::size_t i = 0; i < inputLength; ++i) {
32 //std::round would not work since it doesn't follow the halves rules (See ONNX Round)
33 output[i] = static_cast<O>(std::nearbyint(static_cast<float>(input[i])));
33 for (std::size_t i = 0; i < inputLength; ++i)
34 {
35 float inputValue = static_cast<float>(input[i]);
36
37 if (mode == Round_Op::HalfwayRounding::NearestEven) {
38 output[i] = static_cast<O>(std::nearbyint(inputValue));
39 }
40 else if (mode == Round_Op::HalfwayRounding::AwayFromZero) {
41 output[i] = static_cast<O>(std::round(inputValue));
42 }
43 else if (mode == Round_Op::HalfwayRounding::NextInteger) {
44 output[i] = static_cast<O>(std::round(std::nextafter(inputValue, inputValue + 1)));
  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    • 07b3797c - use INFINITY instead of (inputValue + 1)

    Compare with previous version

  • I added a new rounding mechanism in aidge_core!421 (merged), which will superseed this MR.

  • Please register or sign in to reply
    Loading