MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / round

Method round

src/core/Rounding.cpp:36–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34using namespace std;
35
36int 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}

Calls 1

roundFunction · 0.50

Tested by

no test coverage detected