aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core
diff options
context:
space:
mode:
authorSiCongLi <sicong.li@arm.com>2021-10-29 15:05:49 +0100
committerSiCong Li <sicong.li@arm.com>2021-11-01 14:29:51 +0000
commiteb8bd81a625f0f87080dbde55b434362ad57324a (patch)
treefda1de0843be17266388d0d137908f392a7f694e /arm_compute/core
parent1af5416917268692fcd4b34b1d7ffebd3a2aea8a (diff)
downloadComputeLibrary-eb8bd81a625f0f87080dbde55b434362ad57324a.tar.gz
Fix dst "widening" validation
* Auto-initialize the dst tensor before checking for PostOp shape compliance so that we catch the invalid case of "widening" dst tensor shape * Rework post op validate test cases to be more readable Partially resolves: COMPMID-4435 Change-Id: I79943994182942f962e4d59a7fa0d6f017ae9ac7 Signed-off-by: SiCongLi <sicong.li@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6548 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r--arm_compute/core/experimental/IPostOp.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/arm_compute/core/experimental/IPostOp.h b/arm_compute/core/experimental/IPostOp.h
index cd6b8fc4cc..4fac4c88e9 100644
--- a/arm_compute/core/experimental/IPostOp.h
+++ b/arm_compute/core/experimental/IPostOp.h
@@ -44,7 +44,7 @@ using PostOpTypeSequence = std::vector<PostOpType>;
* It contains:
* 1. The attributes of the original operator.
* 2. Any additional tensor argument.
- * 3. The postion of the previous op's dst tensor in its argument list ( @ref prev_dst_pos )
+ * 3. The position of the previous op's dst tensor in its argument list ( @ref prev_dst_pos )
*
* For example, a series of chained ops:
*
@@ -62,8 +62,16 @@ using PostOpTypeSequence = std::vector<PostOpType>;
* post op1: relu(act_info, prev_dst_pos = 0)
* post op2: div(div_info, src1, prev_dst_pos = 1)
*
- * NOTE: PostOps do not own any resources pointed to by TensorRelatedT if it's a pointer type
- * NOTE: If TensorRelatedT points to a resource, IPostOp assumes that resource is valid throughout its lifetime
+ * @note: On Broadcasting
+ * For n-ary post ops, the tensor arguments must not "widen" the dst tensor of the main op
+ * For example, for a dst of shape [14, 1, 34]:
+ * * post_op_arg1 = [1, 1, 34] is allowed: broadcast in dim 0
+ * * post_op_arg1 = [14, 1, 34] is allowed: no broadcast
+ * * post_op_arg1 = [1, 1, 34] is allowed: broadcast in dims 0 and 1
+ * * post_op_arg1 = [14, 15, 34] is NOT allowed: broadcast widens the dst tensor
+ *
+ * @note: PostOps do not own any resources pointed to by TensorRelatedT if it's a pointer type
+ * @note: If TensorRelatedT points to a resource, IPostOp assumes that resource is valid throughout its lifetime
* and the lifetime of its copies. This is almost guaranteed as IPostOp is only meant to be used at configure time
* after the ITensor or ITensorInfo objects are already constructed
*/
@@ -71,7 +79,7 @@ template <typename TensorRelatedT>
struct IPostOp
{
/** Get the arity of the post op
- * NOTE: that this is one fewer than the arity of the original op, because we implicitly pass the previous op's dst
+ * @note: that this is one fewer than the arity of the original op, because we implicitly pass the previous op's dst
* tensor as one of the arguments
*/
size_t arity() const
@@ -88,7 +96,7 @@ struct IPostOp
virtual std::vector<TensorRelatedT *> arguments() = 0;
virtual std::vector<const TensorRelatedT *> arguments() const = 0;
/** Clone method used in cases where PostOps are owned by unique_ptr
- * NOTE: This performs a shallow copy of the TensorRelatedT if TensorRelatedT points to a resource
+ * @note: This performs a shallow copy of the TensorRelatedT if TensorRelatedT points to a resource
*/
virtual std::unique_ptr<IPostOp<TensorRelatedT>> clone() const = 0;
virtual ~IPostOp()