| 536 | } |
| 537 | |
| 538 | int64_t python_round_nonnegative(float value) { |
| 539 | if (value < 0.0F) { |
| 540 | throw std::runtime_error("ACE-Step diffusion expected a nonnegative value for Python-style rounding"); |
| 541 | } |
| 542 | const double x = static_cast<double>(value); |
| 543 | const double floor_value = std::floor(x); |
| 544 | const double fraction = x - floor_value; |
| 545 | int64_t rounded = static_cast<int64_t>(floor_value); |
| 546 | if (fraction > 0.5) { |
| 547 | ++rounded; |
no test coverage detected