aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2018-10-24 15:32:39 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-11-09 17:04:04 +0000
commit0cf77981fadb883b97efec112e115450873e64c3 (patch)
tree42592f5dd8721ab8337059df3861e1e2b849399d /examples
parent283fc606dbd9058f636b91350a1c47b97aba1a87 (diff)
downloadComputeLibrary-0cf77981fadb883b97efec112e115450873e64c3.tar.gz
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
Diffstat (limited to 'examples')
-rw-r--r--examples/graph_vgg16.cpp10
-rw-r--r--examples/graph_vgg19.cpp10
2 files changed, 20 insertions, 0 deletions
diff --git a/examples/graph_vgg16.cpp b/examples/graph_vgg16.cpp
index 4b5f33a7e8..482aab1683 100644
--- a/examples/graph_vgg16.cpp
+++ b/examples/graph_vgg16.cpp
@@ -41,6 +41,16 @@ public:
}
bool do_setup(int argc, char **argv) override
{
+ // Check if the system has enough RAM to run the example, systems with less than 2GB have
+ // to hint the API to minimize memory consumption otherwise it'll run out of memory and
+ // fail throwing the bad_alloc exception
+ arm_compute::MEMInfo meminfo;
+ const size_t mem_total = meminfo.get_total_in_kb();
+ if(mem_total <= arm_compute::MEMInfo::TWO_GB_IN_KB)
+ {
+ arm_compute::MEMInfo::set_policy(arm_compute::MemoryPolicy::MINIMIZE);
+ }
+
// Parse arguments
cmd_parser.parse(argc, argv);
diff --git a/examples/graph_vgg19.cpp b/examples/graph_vgg19.cpp
index ff7cf751a1..3b1773519a 100644
--- a/examples/graph_vgg19.cpp
+++ b/examples/graph_vgg19.cpp
@@ -40,6 +40,16 @@ public:
}
bool do_setup(int argc, char **argv) override
{
+ // Check if the system has enough RAM to run the example, systems with less than 2GB have
+ // to hint the API to minimize memory consumption otherwise it'll run out of memory and
+ // fail throwing the bad_alloc exception
+ arm_compute::MEMInfo meminfo;
+ const size_t mem_total = meminfo.get_total_in_kb();
+ if(mem_total <= arm_compute::MEMInfo::TWO_GB_IN_KB)
+ {
+ arm_compute::MEMInfo::set_policy(arm_compute::MemoryPolicy::MINIMIZE);
+ }
+
// Parse arguments
cmd_parser.parse(argc, argv);