aboutsummaryrefslogtreecommitdiff
path: root/examples/neon_copy_objects.cpp
diff options
context:
space:
mode:
authorFelix Thomasmathibalan <felixjohnny.thomasmathibalan@arm.com>2023-09-27 17:46:17 +0100
committerfelixjohnny.thomasmathibalan <felixjohnny.thomasmathibalan@arm.com>2023-09-28 12:08:05 +0000
commitafd38f0c617d6f89b2b4532c6c44f116617e2b6f (patch)
tree03bc7d5a762099989b16a656fa8d397b490ed70e /examples/neon_copy_objects.cpp
parentbdcb4c148ee2fdeaaddf4cf1e57bbb0de02bb894 (diff)
downloadComputeLibrary-afd38f0c617d6f89b2b4532c6c44f116617e2b6f.tar.gz
Apply clang-format on repository
Code is formatted as per a revised clang format configuration file(not part of this delivery). Version 14.0.6 is used. Exclusion List: - files with .cl extension - files that are not strictly C/C++ (e.g. Android.bp, Sconscript ...) And the following directories - compute_kernel_writer/validation/ - tests/ - include/ - src/core/NEON/kernels/convolution/ - src/core/NEON/kernels/arm_gemm/ - src/core/NEON/kernels/arm_conv/ - data/ There will be a follow up for formatting of .cl files and the files under tests/ and compute_kernel_writer/validation/. Signed-off-by: Felix Thomasmathibalan <felixjohnny.thomasmathibalan@arm.com> Change-Id: Ib7eb1fcf4e7537b9feaefcfc15098a804a3fde0a Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10391 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Diffstat (limited to 'examples/neon_copy_objects.cpp')
-rw-r--r--examples/neon_copy_objects.cpp61
1 files changed, 37 insertions, 24 deletions
diff --git a/examples/neon_copy_objects.cpp b/examples/neon_copy_objects.cpp
index b060b09759..6e9ebcaad5 100644
--- a/examples/neon_copy_objects.cpp
+++ b/examples/neon_copy_objects.cpp
@@ -22,9 +22,9 @@
* SOFTWARE.
*/
+#include "arm_compute/core/Types.h"
#include "arm_compute/runtime/NEON/NEFunctions.h"
-#include "arm_compute/core/Types.h"
#include "utils/Utils.h"
#include <cstring>
@@ -50,11 +50,11 @@ public:
dst_data = new float[width * height * batch];
// Fill src_data with pseudo(meaningless) values:
- for(unsigned int b = 0; b < batch; b++)
+ for (unsigned int b = 0; b < batch; b++)
{
- for(unsigned int h = 0; h < height; h++)
+ for (unsigned int h = 0; h < height; h++)
{
- for(unsigned int w = 0; w < width; w++)
+ for (unsigned int w = 0; w < width; w++)
{
src_data[b * (width * height) + h * width + w] = static_cast<float>(100 * b + 10 * h + w);
}
@@ -78,9 +78,12 @@ public:
Window input_window;
input_window.use_tensor_dimensions(input.info()->tensor_shape());
std::cout << " Dimensions of the input's iterator:\n";
- std::cout << " X = [start=" << input_window.x().start() << ", end=" << input_window.x().end() << ", step=" << input_window.x().step() << "]\n";
- std::cout << " Y = [start=" << input_window.y().start() << ", end=" << input_window.y().end() << ", step=" << input_window.y().step() << "]\n";
- std::cout << " Z = [start=" << input_window.z().start() << ", end=" << input_window.z().end() << ", step=" << input_window.z().step() << "]\n";
+ std::cout << " X = [start=" << input_window.x().start() << ", end=" << input_window.x().end()
+ << ", step=" << input_window.x().step() << "]\n";
+ std::cout << " Y = [start=" << input_window.y().start() << ", end=" << input_window.y().end()
+ << ", step=" << input_window.y().step() << "]\n";
+ std::cout << " Z = [start=" << input_window.z().start() << ", end=" << input_window.z().end()
+ << ", step=" << input_window.z().step() << "]\n";
// Create an iterator:
Iterator input_it(&input, input_window);
@@ -98,20 +101,28 @@ public:
// }
// }
// Except it works for an arbitrary number of dimensions
- execute_window_loop(input_window, [&](const Coordinates & id)
- {
- std::cout << "Setting item [" << id.x() << "," << id.y() << "," << id.z() << "]\n";
- *reinterpret_cast<float *>(input_it.ptr()) = src_data[id.z() * (width * height) + id.y() * width + id.x()];
- },
- input_it);
+ execute_window_loop(
+ input_window,
+ [&](const Coordinates &id)
+ {
+ std::cout << "Setting item [" << id.x() << "," << id.y() << "," << id.z() << "]\n";
+ *reinterpret_cast<float *>(input_it.ptr()) =
+ src_data[id.z() * (width * height) + id.y() * width + id.x()];
+ },
+ input_it);
// More efficient way: create an iterator to iterate through each row (instead of each element) of the output tensor:
Window output_window;
- output_window.use_tensor_dimensions(output.info()->tensor_shape(), /* first_dimension =*/Window::DimY); // Iterate through the rows (not each element)
+ output_window.use_tensor_dimensions(
+ output.info()->tensor_shape(),
+ /* first_dimension =*/Window::DimY); // Iterate through the rows (not each element)
std::cout << " Dimensions of the output's iterator:\n";
- std::cout << " X = [start=" << output_window.x().start() << ", end=" << output_window.x().end() << ", step=" << output_window.x().step() << "]\n";
- std::cout << " Y = [start=" << output_window.y().start() << ", end=" << output_window.y().end() << ", step=" << output_window.y().step() << "]\n";
- std::cout << " Z = [start=" << output_window.z().start() << ", end=" << output_window.z().end() << ", step=" << output_window.z().step() << "]\n";
+ std::cout << " X = [start=" << output_window.x().start() << ", end=" << output_window.x().end()
+ << ", step=" << output_window.x().step() << "]\n";
+ std::cout << " Y = [start=" << output_window.y().start() << ", end=" << output_window.y().end()
+ << ", step=" << output_window.y().step() << "]\n";
+ std::cout << " Z = [start=" << output_window.z().start() << ", end=" << output_window.z().end()
+ << ", step=" << output_window.z().step() << "]\n";
// Create an iterator:
Iterator output_it(&output, output_window);
@@ -126,13 +137,15 @@ public:
// }
// }
// Except it works for an arbitrary number of dimensions
- execute_window_loop(output_window, [&](const Coordinates & id)
- {
- std::cout << "Copying one row starting from [" << id.x() << "," << id.y() << "," << id.z() << "]\n";
- // Copy one whole row:
- memcpy(dst_data + id.z() * (width * height) + id.y() * width, output_it.ptr(), width * sizeof(float));
- },
- output_it);
+ execute_window_loop(
+ output_window,
+ [&](const Coordinates &id)
+ {
+ std::cout << "Copying one row starting from [" << id.x() << "," << id.y() << "," << id.z() << "]\n";
+ // Copy one whole row:
+ memcpy(dst_data + id.z() * (width * height) + id.y() * width, output_it.ptr(), width * sizeof(float));
+ },
+ output_it);
/** [Copy objects example] */