aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorramelg01 <ramy.elgammal@arm.com>2021-10-02 14:34:36 +0100
committerramy.elgammal <ramy.elgammal@arm.com>2021-10-04 17:51:37 +0000
commit4a6d9e85a9cb2e199d20b06e5450036c3b83b91d (patch)
treedcfa7986053d80c16ca3edb5ef0bd38fba501ba4 /src/runtime
parent6d891575e0c4432e170db7746037934299a0f2ca (diff)
downloadComputeLibrary-4a6d9e85a9cb2e199d20b06e5450036c3b83b91d.tar.gz
Provide logging for configure functions in all CPP functions
- Moving impl of CPPSplit template to src/runtime/CPP to allow including of Log.h from src/common. - Fix logging of vector<ITensor*> to print contained tensor's info not their ptrs. Partially-Resovles: COMPMID-4718 Signed-off-by: Ramy Elgammal <ramy.elgammal@arm.com> Change-Id: Idec81665b2a7c0cfae5248803109c6e2edc520a1 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6362 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/CL/functions/CLBatchNormalizationLayer.cpp3
-rw-r--r--src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp10
-rw-r--r--src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp9
-rw-r--r--src/runtime/CPP/functions/CPPDetectionPostProcessLayer.cpp12
-rw-r--r--src/runtime/CPP/functions/CPPNonMaximumSuppression.cpp6
-rw-r--r--src/runtime/CPP/functions/CPPPermute.cpp6
-rw-r--r--src/runtime/CPP/functions/CPPSplit.cpp186
-rw-r--r--src/runtime/CPP/functions/CPPTopKV.cpp6
-rw-r--r--src/runtime/CPP/functions/CPPUpsample.cpp6
-rw-r--r--src/runtime/NEON/functions/NEUnstack.cpp2
10 files changed, 232 insertions, 14 deletions
diff --git a/src/runtime/CL/functions/CLBatchNormalizationLayer.cpp b/src/runtime/CL/functions/CLBatchNormalizationLayer.cpp
index 234a0df2aa..e8affc0853 100644
--- a/src/runtime/CL/functions/CLBatchNormalizationLayer.cpp
+++ b/src/runtime/CL/functions/CLBatchNormalizationLayer.cpp
@@ -29,10 +29,11 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/core/Validate.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "src/common/utils/Log.h"
#include "src/core/CL/kernels/CLBatchNormalizationLayerKernel.h"
+#include "src/common/utils/Log.h"
+
namespace arm_compute
{
CLBatchNormalizationLayer::CLBatchNormalizationLayer()
diff --git a/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp b/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp
index b6803d0d37..dccbe4045d 100644
--- a/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp
+++ b/src/runtime/CPP/functions/CPPBoxWithNonMaximaSuppressionLimit.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -26,6 +26,8 @@
#include "arm_compute/core/CPP/kernels/CPPBoxWithNonMaximaSuppressionLimitKernel.h"
#include "arm_compute/runtime/Scheduler.h"
+#include "src/common/utils/Log.h"
+
namespace arm_compute
{
namespace
@@ -130,10 +132,12 @@ CPPBoxWithNonMaximaSuppressionLimit::CPPBoxWithNonMaximaSuppressionLimit(std::sh
{
}
-void CPPBoxWithNonMaximaSuppressionLimit::configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in, ITensor *scores_out, ITensor *boxes_out, ITensor *classes,
- ITensor *batch_splits_out, ITensor *keeps, ITensor *keeps_size, const BoxNMSLimitInfo info)
+void CPPBoxWithNonMaximaSuppressionLimit::configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in,
+ ITensor *scores_out, ITensor *boxes_out, ITensor *classes, ITensor *batch_splits_out,
+ ITensor *keeps, ITensor *keeps_size, const BoxNMSLimitInfo info)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(scores_in, boxes_in, scores_out, boxes_out, classes);
+ ARM_COMPUTE_LOG_PARAMS(scores_in, boxes_in, batch_splits_in, scores_out, boxes_out, classes, batch_splits_out, keeps, keeps_size, info);
_is_qasymm8 = scores_in->info()->data_type() == DataType::QASYMM8 || scores_in->info()->data_type() == DataType::QASYMM8_SIGNED;
diff --git a/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp b/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp
index fdb4c9f0f6..41d875eb97 100644
--- a/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp
+++ b/src/runtime/CPP/functions/CPPDetectionOutputLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020 Arm Limited.
+ * Copyright (c) 2018-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,6 +28,8 @@
#include "arm_compute/core/Validate.h"
#include "src/core/helpers/AutoConfiguration.h"
+#include "src/common/utils/Log.h"
+
#include <list>
namespace arm_compute
@@ -388,9 +390,12 @@ CPPDetectionOutputLayer::CPPDetectionOutputLayer()
{
}
-void CPPDetectionOutputLayer::configure(const ITensor *input_loc, const ITensor *input_conf, const ITensor *input_priorbox, ITensor *output, DetectionOutputLayerInfo info)
+void CPPDetectionOutputLayer::configure(const ITensor *input_loc, const ITensor *input_conf, const ITensor *input_priorbox,
+ ITensor *output, DetectionOutputLayerInfo info)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(input_loc, input_conf, input_priorbox, output);
+ ARM_COMPUTE_LOG_PARAMS(input_loc, input_conf, input_priorbox, output, info);
+
// Output auto initialization if not yet initialized
// Since the number of bboxes to kept is unknown before nms, the shape is set to the maximum
// The maximum is keep_top_k * input_loc_size[1]
diff --git a/src/runtime/CPP/functions/CPPDetectionPostProcessLayer.cpp b/src/runtime/CPP/functions/CPPDetectionPostProcessLayer.cpp
index 31f1fafd69..ecbc49b3c1 100644
--- a/src/runtime/CPP/functions/CPPDetectionPostProcessLayer.cpp
+++ b/src/runtime/CPP/functions/CPPDetectionPostProcessLayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -28,6 +28,8 @@
#include "arm_compute/core/Validate.h"
#include "src/core/helpers/AutoConfiguration.h"
+#include "src/common/utils/Log.h"
+
#include <cstddef>
#include <ios>
#include <list>
@@ -213,10 +215,14 @@ CPPDetectionPostProcessLayer::CPPDetectionPostProcessLayer(std::shared_ptr<IMemo
{
}
-void CPPDetectionPostProcessLayer::configure(const ITensor *input_box_encoding, const ITensor *input_scores, const ITensor *input_anchors,
- ITensor *output_boxes, ITensor *output_classes, ITensor *output_scores, ITensor *num_detection, DetectionPostProcessLayerInfo info)
+void CPPDetectionPostProcessLayer::configure(const ITensor *input_box_encoding, const ITensor *input_scores,
+ const ITensor *input_anchors, ITensor *output_boxes, ITensor *output_classes,
+ ITensor *output_scores, ITensor *num_detection, DetectionPostProcessLayerInfo info)
{
ARM_COMPUTE_ERROR_ON_NULLPTR(input_box_encoding, input_scores, input_anchors, output_boxes, output_classes, output_scores);
+ ARM_COMPUTE_LOG_PARAMS(input_box_encoding, input_scores, input_anchors, output_boxes, output_classes, output_scores,
+ num_detection, info);
+
_num_max_detected_boxes = info.max_detections() * info.max_classes_per_detection();
auto_init_if_empty(*output_boxes->info(), TensorInfo(TensorShape(_kNumCoordBox, _num_max_detected_boxes, _kBatchSize), 1, DataType::F32));
diff --git a/src/runtime/CPP/functions/CPPNonMaximumSuppression.cpp b/src/runtime/CPP/functions/CPPNonMaximumSuppression.cpp
index d0d0b1e98b..6d01b127c0 100644
--- a/src/runtime/CPP/functions/CPPNonMaximumSuppression.cpp
+++ b/src/runtime/CPP/functions/CPPNonMaximumSuppression.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,12 +25,16 @@
#include "arm_compute/core/CPP/kernels/CPPNonMaximumSuppressionKernel.h"
+#include "src/common/utils/Log.h"
+
namespace arm_compute
{
void CPPNonMaximumSuppression::configure(
const ITensor *bboxes, const ITensor *scores, ITensor *indices, unsigned int max_output_size,
const float score_threshold, const float nms_threshold)
{
+ ARM_COMPUTE_LOG_PARAMS(bboxes, scores, indices, max_output_size, score_threshold, nms_threshold);
+
auto k = std::make_unique<CPPNonMaximumSuppressionKernel>();
k->configure(bboxes, scores, indices, max_output_size, score_threshold, nms_threshold);
_kernel = std::move(k);
diff --git a/src/runtime/CPP/functions/CPPPermute.cpp b/src/runtime/CPP/functions/CPPPermute.cpp
index 76fa09f12b..83941f1dc1 100644
--- a/src/runtime/CPP/functions/CPPPermute.cpp
+++ b/src/runtime/CPP/functions/CPPPermute.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,10 +25,14 @@
#include "arm_compute/core/CPP/kernels/CPPPermuteKernel.h"
+#include "src/common/utils/Log.h"
+
using namespace arm_compute;
void CPPPermute::configure(const ITensor *input, ITensor *output, const PermutationVector &perm)
{
+ ARM_COMPUTE_LOG_PARAMS(input, output, perm);
+
auto k = std::make_unique<CPPPermuteKernel>();
k->configure(input, output, perm);
_kernel = std::move(k);
diff --git a/src/runtime/CPP/functions/CPPSplit.cpp b/src/runtime/CPP/functions/CPPSplit.cpp
new file mode 100644
index 0000000000..98af8ad971
--- /dev/null
+++ b/src/runtime/CPP/functions/CPPSplit.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2021 Arm Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/runtime/CPP/functions/CPPSplit.h"
+
+#ifdef ARM_COMPUTE_CPU_ENABLED // NEON Build is activated
+#include "arm_compute/runtime/NEON/functions/NESlice.h"
+#endif /* ARM_COMPUTE_CPU_ENABLED */
+
+#ifdef ARM_COMPUTE_OPENCL_ENABLED // OPENCL build is activated
+#include "arm_compute/runtime/CL/functions/CLSlice.h"
+#endif /* ARM_COMPUTE_OPENCL_ENABLED */
+
+#include "src/common/utils/Log.h"
+
+namespace arm_compute
+{
+/** Basic function to split a tensor along a given axis */
+
+template <typename SliceType, typename TensorInterfaceType>
+CPPSplit<SliceType, TensorInterfaceType>::CPPSplit()
+ : _outputs_vector(), _slice_functions(), _num_outputs(0)
+{
+}
+
+template <typename SliceType, typename TensorInterfaceType>
+Status CPPSplit<SliceType, TensorInterfaceType>::validate(const ITensorInfo *input, const std::vector<ITensorInfo *> &outputs, unsigned int axis)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
+ ARM_COMPUTE_RETURN_ERROR_ON(axis >= input->num_dimensions());
+ ARM_COMPUTE_RETURN_ERROR_ON(outputs.size() < 2);
+
+ // Get output shape
+ TensorShape output_shape{};
+ unsigned int total_output_shape_size = 0;
+
+ // Sum the output sizes and fall back to evenly-sized splits if any are zero
+ const bool using_split_shapes = std::none_of(outputs.begin(), outputs.end(), [&total_output_shape_size](ITensorInfo * info)
+ {
+ unsigned int output_shape_size = info->tensor_shape().total_size();
+ total_output_shape_size += output_shape_size;
+ return output_shape_size == 0;
+ });
+
+ if(using_split_shapes)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().total_size() != total_output_shape_size);
+ }
+ else
+ {
+ output_shape = arm_compute::misc::shape_calculator::compute_split_shape(input, axis, outputs.size());
+ ARM_COMPUTE_RETURN_ERROR_ON(output_shape.total_size() == 0);
+ }
+
+ // Validate output tensors
+ unsigned int axis_offset = 0;
+ for(const auto &output : outputs)
+ {
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
+ if(using_split_shapes)
+ {
+ output_shape = output->tensor_shape();
+ ARM_COMPUTE_RETURN_ERROR_ON(output_shape.total_size() == 0);
+ }
+
+ const size_t axis_split_step = output_shape[axis];
+
+ // Start/End coordinates
+ Coordinates start_coords;
+ Coordinates end_coords;
+ for(unsigned int d = 0; d < output_shape.num_dimensions(); ++d)
+ {
+ end_coords.set(d, -1);
+ }
+
+ // Output auto inizialitation if not yet initialized
+ TensorInfo tmp_output_info = *output->clone();
+ if(tmp_output_info.tensor_shape().total_size() == 0)
+ {
+ tmp_output_info = input->clone()->set_is_resizable(true).set_tensor_shape(output_shape);
+ }
+
+ // Update coordinate on axis
+ start_coords.set(axis, axis_offset);
+ end_coords.set(axis, axis_offset + axis_split_step);
+
+ ARM_COMPUTE_RETURN_ON_ERROR(SliceType::validate(input, output, start_coords, end_coords));
+ axis_offset += axis_split_step;
+ }
+
+ return Status{};
+}
+
+template <typename SliceType, typename TensorInterfaceType>
+void CPPSplit<SliceType, TensorInterfaceType>::configure(const TensorInterfaceType *input, const std::vector<TensorInterfaceType *> &outputs, unsigned int axis)
+{
+ // (TensorInterfaceType*)
+ ARM_COMPUTE_LOG_PARAMS(input, outputs, axis);
+
+ // Create Slice functions
+ _num_outputs = outputs.size();
+ _slice_functions.resize(_num_outputs);
+
+ // Extract output tensor info
+ std::vector<ITensorInfo *> outputs_info;
+ for(auto &output : outputs)
+ {
+ ARM_COMPUTE_ERROR_ON_NULLPTR(output);
+ outputs_info.emplace_back(output->info());
+ }
+
+ // If any of the outputs have a zero size, fall-back to using evenly-sized output splits
+ const bool outputs_have_sizes = std::none_of(outputs_info.begin(), outputs_info.end(), [](ITensorInfo * info)
+ {
+ return info->tensor_shape().total_size() == 0;
+ });
+
+ // Validate
+ ARM_COMPUTE_ERROR_THROW_ON(CPPSplit::validate(input->info(), outputs_info, axis));
+
+ unsigned int axis_offset = 0;
+ unsigned int i = 0;
+
+ for(const auto &output_info : outputs_info)
+ {
+ // Get output shape
+ TensorShape output_shape = (outputs_have_sizes ?
+ output_info->tensor_shape() :
+ arm_compute::misc::shape_calculator::compute_split_shape(input->info(), axis, _num_outputs));
+
+ const size_t axis_split_step = output_shape[axis];
+
+ // Start/End coordinates
+ Coordinates start_coords;
+ Coordinates end_coords;
+
+ for(unsigned int d = 0; d < output_shape.num_dimensions(); ++d)
+ {
+ end_coords.set(d, -1);
+ }
+
+ // Update coordinate on axis
+ start_coords.set(axis, axis_offset);
+ end_coords.set(axis, axis_offset + axis_split_step);
+
+ // Configure slice function
+ _slice_functions[i].configure(input, outputs[i], start_coords, end_coords);
+
+ // Set valid region from shape
+ outputs[i]->info()->set_valid_region(ValidRegion(Coordinates(), output_shape));
+
+ // Update axis offset
+ axis_offset += axis_split_step;
+ ++i;
+ }
+}
+
+// Instantiate CPPSplit for NESlice and CLSlice types to enable linking to the above templated CPPSplit's methods
+#ifdef ARM_COMPUTE_CPU_ENABLED // NEON Build is activated
+template class CPPSplit<NESlice, ITensor>;
+#endif /* ARM_COMPUTE_CPU_ENABLED */
+
+#ifdef ARM_COMPUTE_OPENCL_ENABLED // OPENCL build is activated
+template class CPPSplit<CLSlice, ICLTensor>;
+#endif /* ARM_COMPUTE_OPENCL_ENABLED */
+} // namespace arm_compute
diff --git a/src/runtime/CPP/functions/CPPTopKV.cpp b/src/runtime/CPP/functions/CPPTopKV.cpp
index 2547e56a1d..62a74735a2 100644
--- a/src/runtime/CPP/functions/CPPTopKV.cpp
+++ b/src/runtime/CPP/functions/CPPTopKV.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,10 +25,14 @@
#include "arm_compute/core/CPP/kernels/CPPTopKVKernel.h"
+#include "src/common/utils/Log.h"
+
namespace arm_compute
{
void CPPTopKV::configure(const ITensor *predictions, const ITensor *targets, ITensor *output, const unsigned int k)
{
+ ARM_COMPUTE_LOG_PARAMS(predictions, targets, output, k);
+
auto kernel = std::make_unique<CPPTopKVKernel>();
kernel->configure(predictions, targets, output, k);
_kernel = std::move(kernel);
diff --git a/src/runtime/CPP/functions/CPPUpsample.cpp b/src/runtime/CPP/functions/CPPUpsample.cpp
index 3b4ba2ba42..8f72473aeb 100644
--- a/src/runtime/CPP/functions/CPPUpsample.cpp
+++ b/src/runtime/CPP/functions/CPPUpsample.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Arm Limited.
+ * Copyright (c) 2017-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,10 +25,14 @@
#include "arm_compute/core/CPP/kernels/CPPUpsampleKernel.h"
+#include "src/common/utils/Log.h"
+
using namespace arm_compute;
void CPPUpsample::configure(const ITensor *input, ITensor *output, const PadStrideInfo &info)
{
+ ARM_COMPUTE_LOG_PARAMS(input, output, info);
+
auto k = std::make_unique<CPPUpsampleKernel>();
k->configure(input, output, info);
_kernel = std::move(k);
diff --git a/src/runtime/NEON/functions/NEUnstack.cpp b/src/runtime/NEON/functions/NEUnstack.cpp
index 176b17f1f5..0ffab5e92a 100644
--- a/src/runtime/NEON/functions/NEUnstack.cpp
+++ b/src/runtime/NEON/functions/NEUnstack.cpp
@@ -71,7 +71,7 @@ void NEUnstack::configure(const ITensor *input, const std::vector<ITensor *> &ou
ARM_COMPUTE_ERROR_ON_NULLPTR(input);
ARM_COMPUTE_ERROR_THROW_ON(NEUnstack::validate(input->info(), outputs_vector_info, axis));
- ARM_COMPUTE_LOG_PARAMS(input, output_vector, outputs_vector_info, axis);
+ ARM_COMPUTE_LOG_PARAMS(input, output_vector, axis);
// Wrap around negative values
const unsigned int axis_u = wrap_axis(axis, input->info());