diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-02-20 18:11:42 +0000 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2019-02-22 15:07:23 +0000 |
commit | 7097e3c7cc7cbea7959685354cfc84c2c1823f75 (patch) | |
tree | bbc74b268430fd244665409ba862178f35d69dcf | |
parent | 8f5802f1ee432445ed37344060ffa23916f7f29f (diff) | |
download | ComputeLibrary-7097e3c7cc7cbea7959685354cfc84c2c1823f75.tar.gz |
COMPMID-1601: Graph examples segfaulting on some platform when gles=1
Makes the graph to setup and initialize only the backends used as some
platform have issues when GLES backend get initialized but not used.
Change-Id: Icf88675ffd8c2997e54a68baabfbbce241b0712c
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-on: https://review.mlplatform.org/745
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Giuseppe Rossini <giuseppe.rossini@arm.com>
-rw-r--r-- | arm_compute/graph/Utils.h | 9 | ||||
-rw-r--r-- | src/graph/GraphManager.cpp | 11 | ||||
-rw-r--r-- | src/graph/Utils.cpp | 11 |
3 files changed, 17 insertions, 14 deletions
diff --git a/arm_compute/graph/Utils.h b/arm_compute/graph/Utils.h index 1a0509b6fa..4ffccec9be 100644 --- a/arm_compute/graph/Utils.h +++ b/arm_compute/graph/Utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -89,11 +89,12 @@ void force_target_to_graph(Graph &g, Target target); * @return A PassManager with default mutating passes */ PassManager create_default_pass_manager(Target target); -/** Default setups the graph context if not done manually +/** Setups requested backend context if it exists, is supported and hasn't been initialized already. * - * @param[in,out] ctx Graph Context + * @param[in,out] ctx Graph Context. + * @param[in] target Target to setup the backend for. */ -void setup_default_graph_context(GraphContext &ctx); +void setup_requested_backend_context(GraphContext &ctx, Target target); /** Default releases the graph context if not done manually * * @param[in,out] ctx Graph Context diff --git a/src/graph/GraphManager.cpp b/src/graph/GraphManager.cpp index 57c5f9dca2..4f942b99e4 100644 --- a/src/graph/GraphManager.cpp +++ b/src/graph/GraphManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -45,9 +45,6 @@ GraphManager::GraphManager() void GraphManager::finalize_graph(Graph &graph, GraphContext &ctx, PassManager &pm, Target target) { - // Setup graph context if not done manually - setup_default_graph_context(ctx); - // Check if graph has been registered if(_workloads.find(graph.id()) != std::end(_workloads)) { @@ -55,7 +52,7 @@ void GraphManager::finalize_graph(Graph &graph, GraphContext &ctx, PassManager & } // Force target to all graph construct - // TODO (geopin01) : Support heterogeneous execution + // TODO (COMPMID-2014) : Support heterogeneous execution Target forced_target = target; if(!is_target_supported(target)) { @@ -64,6 +61,10 @@ void GraphManager::finalize_graph(Graph &graph, GraphContext &ctx, PassManager & } force_target_to_graph(graph, forced_target); + // Setup backend context + // TODO (COMPMID-2014) : Setup all backends needed by the graph + setup_requested_backend_context(ctx, forced_target); + // Configure all tensors detail::configure_all_tensors(graph); diff --git a/src/graph/Utils.cpp b/src/graph/Utils.cpp index 71ec548f8a..71a6fc582b 100644 --- a/src/graph/Utils.cpp +++ b/src/graph/Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -104,13 +104,14 @@ void release_default_graph_context(GraphContext &ctx) } } -void setup_default_graph_context(GraphContext &ctx) +void setup_requested_backend_context(GraphContext &ctx, Target target) { - for(const auto &backend : backends::BackendRegistry::get().backends()) + if(backends::BackendRegistry::get().contains(target)) { - if(backend.second->is_backend_supported()) + const auto &backend = backends::BackendRegistry::get().find_backend(target); + if(backend->is_backend_supported()) { - backend.second->setup_backend_context(ctx); + backend->setup_backend_context(ctx); } } } |