From 0b5af9f2751ad6cb7ce76c577a6e67abe6dc8aa1 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Fri, 19 Jun 2020 23:22:08 +0100 Subject: 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 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3427 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/core/SubTensorInfo.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/core/SubTensorInfo.cpp') 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); } -- cgit v1.2.1