COMPMID-556: Added a rounding policy to the quantize function

Change-Id: I6272a36636c5d9baff6d35dee0a50dc847f65bfa
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/110266
Tested-by: BSG Visual Compute Jenkins server to access repositories on http://mpd-gerrit.cambridge.arm.com <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
diff --git a/src/core/Utils.cpp b/src/core/Utils.cpp
index af864f5..af50bbb 100644
--- a/src/core/Utils.cpp
+++ b/src/core/Utils.cpp
@@ -21,10 +21,13 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+
 #include "arm_compute/core/Utils.h"
 
 #include "arm_compute/core/FixedPoint.h"
 
+#include "support/ToolchainSupport.h"
+
 #include <algorithm>
 #include <cmath>
 #include <cstdint>
@@ -387,3 +390,34 @@
     }
     return 0;
 }
+
+int arm_compute::round(float x, RoundingPolicy rounding_policy)
+{
+    using namespace std;
+    int rounded = 0;
+    switch(rounding_policy)
+    {
+        case RoundingPolicy::TO_ZERO:
+        {
+            rounded = static_cast<int>(x);
+            break;
+        }
+        case RoundingPolicy::TO_NEAREST_UP:
+        {
+            rounded = static_cast<int>(support::cpp11::round(x));
+            break;
+        }
+        case RoundingPolicy::TO_NEAREST_EVEN:
+        {
+            ARM_COMPUTE_ERROR("TO_NEAREST_EVEN rounding policy is not supported.");
+            break;
+        }
+        default:
+        {
+            ARM_COMPUTE_ERROR("Unsupported rounding policy.");
+            break;
+        }
+    }
+
+    return rounded;
+}