COMPMID-1626: Fixed VGG 16/19 bad_alloc failure.

Some systems don't have enough memory to run the VGG networks, for example
on systems with only 2GB memory the VGG example fails throwing a bad_alloc exception.

This patch introduces the concept of global memory policy in ACL, the policy
is a mechanism which could be used by the library's functions to try to reduce
memory consumption on systems with limited memory.

In this specific case the VGG examples set the policy to MINIMIZE. The GEMM
function checks if the policy is MINIMIZE and in this case does not use the
pretransposed weights path as this requires considerable more memory.

Change-Id: I53abc3c9c64d045d8306793ffc9d24b28e228b7b
diff --git a/arm_compute/core/CPP/CPPTypes.h b/arm_compute/core/CPP/CPPTypes.h
index 9ffb484..0ac8bf6 100644
--- a/arm_compute/core/CPP/CPPTypes.h
+++ b/arm_compute/core/CPP/CPPTypes.h
@@ -26,6 +26,7 @@
 
 #include "arm_compute/core/Error.h"
 
+#include <array>
 #include <string>
 #include <vector>
 
@@ -46,6 +47,19 @@
     A55r1
 };
 
+/** Global memory policy.
+ * The functions in the runtime will use different strategies based on the policy currently set.
+ *
+ * MINIMIZE will try to reduce the amount allocated by the functions at the expense of performance normally.
+ * NORMAL won't try to save any memory and will favor speed over memory consumption
+ *
+ */
+enum class MemoryPolicy
+{
+    MINIMIZE,
+    NORMAL
+};
+
 /** Convert a cpumodel value to a string
  *
  * @param val CPUModel value to be converted
@@ -180,6 +194,33 @@
     unsigned int          _L2_cache_size = 262144;
 };
 
+class MEMInfo final
+{
+public:
+    MEMInfo();
+
+    /** Return the total amount of RAM memory in the system expressed in KB.
+     *
+     * @return Total memory
+     */
+    size_t get_total_in_kb() const;
+
+    static void set_policy(MemoryPolicy policy);
+    static MemoryPolicy get_policy();
+
+    /** Common memory sizes expressed in Kb to avoid having them
+     *  duplicated throughout the code.
+     */
+    static const size_t ONE_GB_IN_KB = { 1035842 };
+    static const size_t TWO_GB_IN_KB = { ONE_GB_IN_KB * 2 };
+
+private:
+    size_t              _total;
+    size_t              _free;
+    size_t              _buffer;
+    static MemoryPolicy _policy;
+};
+
 /** Information about executing thread and CPU. */
 struct ThreadInfo
 {
diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h
index 0240916..8df5c65 100644
--- a/arm_compute/core/Types.h
+++ b/arm_compute/core/Types.h
@@ -940,8 +940,8 @@
      * @param[in] weights         (Optional)Weights [wx, wy, ww, wh] for the deltas. Defaults to all ones
      * @param[in] bbox_xform_clip (Optional)Minimum bounding box width and height after bounding box transformation in log-space. Defaults to log(1000/16)
      */
-    BoundingBoxTransformInfo(float img_width, float img_height, float scale, bool apply_scale = false, const std::array<float, 4> weights = { 1.0, 1.0, 1.0, 1.0 }, float bbox_xform_clip =
-                                 4.135166556742356)
+    BoundingBoxTransformInfo(float img_width, float img_height, float scale, bool apply_scale = false, const std::array<float, 4> weights = { { 1.f, 1.f, 1.f, 1.f } }, float bbox_xform_clip =
+    4.135166556742356f)
         : _img_width(img_width), _img_height(img_height), _scale(scale), _apply_scale(apply_scale), _weights(weights), _bbox_xform_clip(bbox_xform_clip)
     {
     }