aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-22 18:17:43 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-23 10:58:46 +0000
commitb0cd5d8cf6945bed4df62603799d73b5413654a1 (patch)
treeffe6e7597960f596dd5023450ddab7dea3c8376e
parent27e67f0b2047cfa2f011f9e242e3068d9e106b39 (diff)
downloadComputeLibrary-b0cd5d8cf6945bed4df62603799d73b5413654a1.tar.gz
Use polymorphic_downcast instead of dynamic_cast
Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: Ibd8f629c3f0a2943705ba0f7d65a264948dac4b0 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5147 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/graph/Workload.cpp6
-rw-r--r--src/runtime/CL/mlgo/HeuristicTree.cpp8
-rw-r--r--src/runtime/OperatorTensor.cpp6
3 files changed, 13 insertions, 7 deletions
diff --git a/src/graph/Workload.cpp b/src/graph/Workload.cpp
index 7020503171..2bae1c8ca6 100644
--- a/src/graph/Workload.cpp
+++ b/src/graph/Workload.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -27,6 +27,8 @@
#include "arm_compute/graph/ITensorHandle.h"
#include "arm_compute/graph/nodes/PrintLayerNode.h"
+#include "support/Cast.h"
+
namespace arm_compute
{
namespace graph
@@ -46,7 +48,7 @@ void execute_task(ExecutionTask &task)
// COMPMID-3012 - Hide the printing logic from the execute_task method in the graph API
else if(task.node->type() == NodeType::PrintLayer)
{
- auto print_node = dynamic_cast<PrintLayerNode *>(task.node);
+ auto print_node = utils::cast::polymorphic_downcast<PrintLayerNode *>(task.node);
auto input_handle = print_node->input(0)->handle();
auto transform = print_node->transform();
diff --git a/src/runtime/CL/mlgo/HeuristicTree.cpp b/src/runtime/CL/mlgo/HeuristicTree.cpp
index 65219998cb..1c75cdc427 100644
--- a/src/runtime/CL/mlgo/HeuristicTree.cpp
+++ b/src/runtime/CL/mlgo/HeuristicTree.cpp
@@ -24,6 +24,8 @@
#include "src/runtime/CL/mlgo/HeuristicTree.h"
#include "arm_compute/core/Log.h"
+#include "support/Cast.h"
+
#include <algorithm>
#include <deque>
#include <set>
@@ -114,7 +116,7 @@ std::pair<bool, T> HeuristicTree::query(GEMMShape shape) const
return std::make_pair(false, T{});
}
ARM_COMPUTE_ERROR_ON_MSG(cur_node->type() != NodeType::Branch, "Unexpected NodeType");
- auto br_node = dynamic_cast<BranchNode *>(cur_node);
+ auto br_node = utils::cast::polymorphic_downcast<BranchNode *>(cur_node);
if(evaluate(shape, br_node->condition))
{
cur_node = _tree.at(br_node->true_node).get();
@@ -126,7 +128,7 @@ std::pair<bool, T> HeuristicTree::query(GEMMShape shape) const
++depth;
}
ARM_COMPUTE_ERROR_ON_MSG(cur_node->type() != NodeType::Leaf, "Unexpected NodeType");
- auto l_node = dynamic_cast<LeafNode<T> *>(cur_node);
+ auto l_node = utils::cast::polymorphic_downcast<LeafNode<T> *>(cur_node);
return std::make_pair(true, l_node->value);
}
@@ -202,7 +204,7 @@ bool HeuristicTree::check_if_structurally_correct() const
auto cur_node = _tree.at(id).get();
if(cur_node->type() == NodeType::Branch)
{
- auto br_node = dynamic_cast<BranchNode *>(cur_node);
+ auto br_node = utils::cast::polymorphic_downcast<BranchNode *>(cur_node);
to_visit.push_back(br_node->true_node);
to_visit.push_back(br_node->false_node);
}
diff --git a/src/runtime/OperatorTensor.cpp b/src/runtime/OperatorTensor.cpp
index 5a35154479..a8ad53da90 100644
--- a/src/runtime/OperatorTensor.cpp
+++ b/src/runtime/OperatorTensor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Arm Limited.
+ * Copyright (c) 2020-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -24,6 +24,8 @@
#include "arm_compute/runtime/OperatorTensor.h"
#include "arm_compute/runtime/MemoryRegion.h"
+#include "support/Cast.h"
+
namespace arm_compute
{
namespace experimental
@@ -48,7 +50,7 @@ uint8_t *OperatorTensor::buffer() const
switch(_mem_type)
{
case MemoryType::CPU:
- return (uint8_t *)dynamic_cast<MemoryRegion *>(_memory->region())->buffer();
+ return (uint8_t *)utils::cast::polymorphic_downcast<MemoryRegion *>(_memory->region())->buffer();
default:
ARM_COMPUTE_ERROR("Memory type not supported.");
}