aboutsummaryrefslogtreecommitdiff
path: root/src/core/ITensor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ITensor.cpp')
-rw-r--r--src/core/ITensor.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/core/ITensor.cpp b/src/core/ITensor.cpp
index 607f5cedbf..4dc8ea959b 100644
--- a/src/core/ITensor.cpp
+++ b/src/core/ITensor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2019 ARM Limited.
+ * Copyright (c) 2016-2021, 2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,16 +25,17 @@
#include "arm_compute/core/Error.h"
#include "arm_compute/core/Helpers.h"
+#include "arm_compute/core/Utils.h"
#include "arm_compute/core/Window.h"
#include <cstring>
#include <limits>
-using namespace arm_compute;
-
+namespace arm_compute
+{
void ITensor::copy_from(const ITensor &src)
{
- if(&src == this)
+ if (&src == this)
{
return;
}
@@ -46,7 +47,7 @@ void ITensor::copy_from(const ITensor &src)
ARM_COMPUTE_ERROR_ON(src_info->num_channels() != dst_info->num_channels());
ARM_COMPUTE_ERROR_ON(src_info->element_size() != dst_info->element_size());
- for(size_t d = 0; d < src_info->num_dimensions(); d++)
+ for (size_t d = 0; d < src_info->num_dimensions(); d++)
{
ARM_COMPUTE_ERROR_ON(src_info->dimension(d) > dst_info->dimension(d));
}
@@ -64,11 +65,8 @@ void ITensor::copy_from(const ITensor &src)
const size_t line_size = src_info->element_size() * src_info->dimension(0);
- execute_window_loop(win_src, [&](const Coordinates &)
- {
- memcpy(dst_it.ptr(), src_it.ptr(), line_size);
- },
- src_it, dst_it);
+ execute_window_loop(
+ win_src, [&](const Coordinates &) { memcpy(dst_it.ptr(), src_it.ptr(), line_size); }, src_it, dst_it);
}
#ifdef ARM_COMPUTE_ASSERTS_ENABLED
@@ -85,10 +83,10 @@ void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
stream_status.copyfmt(s);
// Set precision
- if(is_data_type_float(dt) && (io_fmt.precision_type != IOFormatInfo::PrecisionType::Default))
+ if (is_data_type_float(dt) && (io_fmt.precision_type != IOFormatInfo::PrecisionType::Default))
{
int precision = io_fmt.precision;
- if(io_fmt.precision_type == IOFormatInfo::PrecisionType::Full)
+ if (io_fmt.precision_type == IOFormatInfo::PrecisionType::Full)
{
precision = std::numeric_limits<float>().max_digits10;
}
@@ -99,7 +97,7 @@ void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
size_t print_width = 0;
size_t print_height = 0;
int start_offset = 0;
- switch(io_fmt.print_region)
+ switch (io_fmt.print_region)
{
case IOFormatInfo::PrintRegion::NoPadding:
print_width = this->info()->dimension(0);
@@ -109,13 +107,14 @@ void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
case IOFormatInfo::PrintRegion::ValidRegion:
print_width = this->info()->valid_region().shape.x();
print_height = this->info()->valid_region().shape.y();
- start_offset = this->info()->offset_element_in_bytes(Coordinates(this->info()->valid_region().anchor.x(),
- this->info()->valid_region().anchor.y()));
+ start_offset = this->info()->offset_element_in_bytes(
+ Coordinates(this->info()->valid_region().anchor.x(), this->info()->valid_region().anchor.y()));
break;
case IOFormatInfo::PrintRegion::Full:
print_width = padding.left + this->info()->dimension(0) + padding.right;
print_height = padding.top + this->info()->dimension(1) + padding.bottom;
- start_offset = static_cast<int>(this->info()->offset_first_element_in_bytes()) - padding.top * strides[1] - padding.left * strides[0];
+ start_offset = static_cast<int>(this->info()->offset_first_element_in_bytes()) - padding.top * strides[1] -
+ padding.left * strides[0];
break;
default:
break;
@@ -127,16 +126,17 @@ void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
const uint8_t *ptr = this->buffer() + start_offset;
// Start printing
- for(size_t i = 0; i < slices2D; ++i)
+ for (size_t i = 0; i < slices2D; ++i)
{
// Find max_width of elements in slice to align columns
int max_element_width = 0;
- if(io_fmt.align_columns)
+ if (io_fmt.align_columns)
{
size_t offset = i * strides[2];
- for(size_t h = 0; h < print_height; ++h)
+ for (size_t h = 0; h < print_height; ++h)
{
- max_element_width = std::max<int>(max_element_width, max_consecutive_elements_display_width(s, dt, ptr + offset, print_width));
+ max_element_width = std::max<int>(
+ max_element_width, max_consecutive_elements_display_width(s, dt, ptr + offset, print_width));
offset += strides[1];
}
}
@@ -144,7 +144,7 @@ void ITensor::print(std::ostream &s, IOFormatInfo io_fmt) const
// Print slice
{
size_t offset = i * strides[2];
- for(size_t h = 0; h < print_height; ++h)
+ for (size_t h = 0; h < print_height; ++h)
{
print_consecutive_elements(s, dt, ptr + offset, print_width, max_element_width, io_fmt.element_delim);
offset += strides[1];
@@ -168,3 +168,9 @@ void ITensor::mark_as_unused() const
{
_is_used = false;
}
+
+void ITensor::mark_as_used() const
+{
+ _is_used = true;
+}
+} // namespace arm_compute