aboutsummaryrefslogtreecommitdiff
path: root/src/core/SubTensorInfo.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2020-06-19 23:22:08 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-06-25 10:40:32 +0000
commit0b5af9f2751ad6cb7ce76c577a6e67abe6dc8aa1 (patch)
tree1ab7fc1480fd3480b1e50873634a77278514d01e /src/core/SubTensorInfo.cpp
parent36b8f0503218ecae5aafc4c5d825a7a60bdd9c39 (diff)
downloadComputeLibrary-0b5af9f2751ad6cb7ce76c577a6e67abe6dc8aa1.tar.gz
COMPMID-3478: Allow SubTensors with XY indexing
Remove limitations on sub-tensor creation and allow any possible indexing as long as it honors the parent tensor shape. In case of padding expansion on a subtensor, an error is raised if the sub-tensor is indexed on the XY dimensions. Change-Id: Ibb5183a6cb7421f55068b47c06b43ebde0f6e9a5 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3427 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/SubTensorInfo.cpp')
-rw-r--r--src/core/SubTensorInfo.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/core/SubTensorInfo.cpp b/src/core/SubTensorInfo.cpp
index be8560fd61..a50f584023 100644
--- a/src/core/SubTensorInfo.cpp
+++ b/src/core/SubTensorInfo.cpp
@@ -41,12 +41,6 @@ namespace
*/
TensorShape extend_parent_shape(TensorShape parent_shape, TensorShape shape, Coordinates coords)
{
- // Subtensor should not index in x, y dimensions.
- ARM_COMPUTE_ERROR_ON((coords.x() != 0) || (coords.y() != 0));
-
- // Cannot extend on x, y ?
- ARM_COMPUTE_ERROR_ON((parent_shape.total_size() != 0) && (parent_shape.x() != shape.x()) && (parent_shape.y() != shape.y()));
-
// Extend shape
for(unsigned int i = 0; i < TensorShape::num_max_dimensions; ++i)
{
@@ -70,6 +64,7 @@ SubTensorInfo::SubTensorInfo(ITensorInfo *parent, TensorShape tensor_shape, Coor
: _parent(parent), _tensor_shape(tensor_shape), _coords(coords), _valid_region{ Coordinates(), _tensor_shape }, _extend_parent(extend_parent)
{
ARM_COMPUTE_ERROR_ON(parent == nullptr);
+
// Check if subtensor is valid if parent is configured
if(parent->tensor_shape().total_size() != 0 && !_extend_parent)
{
@@ -118,6 +113,17 @@ bool SubTensorInfo::extend_padding(const PaddingSize &padding)
ARM_COMPUTE_ERROR_ON(!_parent->is_resizable());
ARM_COMPUTE_ERROR_ON(_parent->total_size() == 0);
+ // Check that you do not extend padding on sub-tensors unless XY shape matches parent tensor
+ // TODO(COMPMID-3558): Remove _extend_parent check
+ if(!_extend_parent && (padding.left || padding.right))
+ {
+ ARM_COMPUTE_ERROR_ON(_parent->tensor_shape().x() != tensor_shape().x());
+ }
+ if(!_extend_parent && (padding.top || padding.bottom))
+ {
+ ARM_COMPUTE_ERROR_ON(_parent->tensor_shape().y() != tensor_shape().y());
+ }
+
// Extend parent padding if required
return _parent->extend_padding(padding);
}