aboutsummaryrefslogtreecommitdiff
path: root/src/core/TensorInfo.cpp
diff options
context:
space:
mode:
authorRamy Elgammal <ramy.elgammal@arm.com>2022-12-22 15:21:03 +0000
committerRamy Elgammal <ramy.elgammal@arm.com>2023-01-09 15:41:02 +0000
commitd2d9361a0a338bce478f7d85b4af70d1ed20f26c (patch)
treed7f8491bb1175a0a0fb28bc916e2078e2947e4e2 /src/core/TensorInfo.cpp
parentf800adf185e966b16385f65b9c7250766949dbe4 (diff)
downloadComputeLibrary-d2d9361a0a338bce478f7d85b4af70d1ed20f26c.tar.gz
Add extend padding lock flag
- ITensorInfo's padding cannot be extended if its lock_paddings flag is set to True. Resolves: COMPMID-5714 Signed-off-by: Ramy Elgammal <ramy.elgammal@arm.com> Change-Id: I6bca9bbf7172822af60562310578c438b9e15f46 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8875 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/TensorInfo.cpp')
-rw-r--r--src/core/TensorInfo.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/TensorInfo.cpp b/src/core/TensorInfo.cpp
index 12f79444c6..954c6c5f1a 100644
--- a/src/core/TensorInfo.cpp
+++ b/src/core/TensorInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2022 Arm Limited.
+ * Copyright (c) 2016-2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -35,7 +35,7 @@ namespace arm_compute
{
TensorInfo::TensorInfo()
: _total_size(0), _offset_first_element_in_bytes(0), _strides_in_bytes(), _num_channels(0), _tensor_shape(), _dims_state(), _data_type(DataType::UNKNOWN), _format(Format::UNKNOWN), _is_resizable{ true },
- _valid_region{ Coordinates(), _tensor_shape }, _padding{ 0 }, _quantization_info(), _data_layout(DataLayout::NCHW), _are_values_constant(true), _id(invalid_tensor_id)
+ _valid_region{ Coordinates(), _tensor_shape }, _padding{ 0 }, _quantization_info(), _data_layout(DataLayout::NCHW), _are_values_constant(true), _id(invalid_tensor_id), _lock_paddings(false)
{
}
@@ -57,6 +57,7 @@ TensorInfo::TensorInfo(const ITensorInfo &info)
_data_layout = info.data_layout();
_are_values_constant = info.are_values_constant();
_id = invalid_tensor_id; // Tensor Id has to be explicitly set, instead of being copied
+ _lock_paddings = info.lock_paddings();
}
TensorInfo::TensorInfo(const TensorInfo &info)
@@ -77,6 +78,7 @@ TensorInfo::TensorInfo(const TensorInfo &info)
_data_layout = info.data_layout();
_are_values_constant = info.are_values_constant();
_id = invalid_tensor_id; // Tensor Id has to be explicitly set, instead of being copied
+ _lock_paddings = false;
}
TensorInfo::TensorInfo(Format format)
: TensorInfo(TensorShape(), format)
@@ -264,8 +266,20 @@ std::tuple<Strides, size_t, size_t> TensorInfo::calculate_padding_requirements(c
return std::make_tuple(required_strides, required_offset_first_element, required_total_size);
}
+ITensorInfo &TensorInfo::set_lock_paddings(bool flag)
+{
+ _lock_paddings = flag;
+ return *this;
+}
+
+bool TensorInfo::lock_paddings() const
+{
+ return _lock_paddings;
+}
+
bool TensorInfo::extend_padding(const PaddingSize &padding)
{
+ ARM_COMPUTE_ERROR_ON(_lock_paddings);
ARM_COMPUTE_ERROR_ON(!_is_resizable);
bool updated = false;