| 34 | using namespace std; |
| 35 | |
| 36 | int arm_compute::round(float x, RoundingPolicy rounding_policy) |
| 37 | { |
| 38 | using namespace std; |
| 39 | int rounded = 0; |
| 40 | switch (rounding_policy) |
| 41 | { |
| 42 | case RoundingPolicy::TO_ZERO: |
| 43 | { |
| 44 | rounded = static_cast<int>(x); |
| 45 | break; |
| 46 | } |
| 47 | case RoundingPolicy::TO_NEAREST_UP: |
| 48 | { |
| 49 | rounded = static_cast<int>(support::cpp11::round(x)); |
| 50 | break; |
| 51 | } |
| 52 | case RoundingPolicy::TO_NEAREST_EVEN: |
| 53 | { |
| 54 | #ifdef __aarch64__ |
| 55 | asm("fcvtns %x[res], %s[value]" : [res] "=r"(rounded) : [value] "w"(x)); |
| 56 | #else // __aarch64__ |
| 57 | ARM_COMPUTE_ERROR("TO_NEAREST_EVEN rounding policy is not supported."); |
| 58 | #endif // __aarch64__ |
| 59 | break; |
| 60 | } |
| 61 | default: |
| 62 | { |
| 63 | ARM_COMPUTE_ERROR("Unsupported rounding policy."); |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return rounded; |
| 69 | } |
no test coverage detected