aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm_compute/graph/Workload.h14
-rw-r--r--src/graph/detail/ExecutionHelpers.cpp8
2 files changed, 18 insertions, 4 deletions
diff --git a/arm_compute/graph/Workload.h b/arm_compute/graph/Workload.h
index e9368eefd0..682b08d88d 100644
--- a/arm_compute/graph/Workload.h
+++ b/arm_compute/graph/Workload.h
@@ -69,6 +69,20 @@ public:
*/
struct ExecutionTask
{
+ ExecutionTask(std::unique_ptr<arm_compute::IFunction> &&f, INode *n)
+ : task(std::move(f)), node(n)
+ {
+ }
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ ExecutionTask(const ExecutionTask &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ ExecutionTask &operator=(const ExecutionTask &) = delete;
+ /** Default Move Constructor. */
+ ExecutionTask(ExecutionTask &&) noexcept = default;
+ /** Default move assignment operator */
+ ExecutionTask &operator=(ExecutionTask &&) noexcept = default;
+ /** Default destructor */
+ ~ExecutionTask() = default;
// TODO (geopin01) : Support vector of functions?
std::unique_ptr<arm_compute::IFunction> task = {}; /**< Task to execute */
INode *node = {}; /**< Node bound to this workload */
diff --git a/src/graph/detail/ExecutionHelpers.cpp b/src/graph/detail/ExecutionHelpers.cpp
index f2c381b7df..767154b45e 100644
--- a/src/graph/detail/ExecutionHelpers.cpp
+++ b/src/graph/detail/ExecutionHelpers.cpp
@@ -135,6 +135,9 @@ ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx, const std::ve
workload.graph = &g;
workload.ctx = &ctx;
+ // Reserve memory for tasks
+ workload.tasks.reserve(node_order.size());
+
// Create tasks
for(auto &node_id : node_order)
{
@@ -146,10 +149,7 @@ ExecutionWorkload configure_all_nodes(Graph &g, GraphContext &ctx, const std::ve
std::unique_ptr<IFunction> func = backend.configure_node(*node, ctx);
if(func != nullptr)
{
- ExecutionTask task;
- task.task = std::move(func);
- task.node = node;
- workload.tasks.push_back(std::move(task));
+ workload.tasks.emplace_back(ExecutionTask(std::move(func), node));
}
}
}