diff options
author | SiCongLi <sicong.li@arm.com> | 2021-10-29 15:05:49 +0100 |
---|---|---|
committer | SiCong Li <sicong.li@arm.com> | 2021-11-01 14:29:51 +0000 |
commit | eb8bd81a625f0f87080dbde55b434362ad57324a (patch) | |
tree | fda1de0843be17266388d0d137908f392a7f694e /src/core/CL | |
parent | 1af5416917268692fcd4b34b1d7ffebd3a2aea8a (diff) | |
download | ComputeLibrary-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 'src/core/CL')
-rw-r--r-- | src/core/CL/CLUtils.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/CL/CLUtils.cpp b/src/core/CL/CLUtils.cpp index 1da970e705..748b0f55a1 100644 --- a/src/core/CL/CLUtils.cpp +++ b/src/core/CL/CLUtils.cpp @@ -85,16 +85,24 @@ PostOpCLKernelUtils::PostOpCLKernelUtils(const Config &supported_config) bool PostOpCLKernelUtils::are_post_op_shapes_compliant(const ITensorInfo *dst, const experimental::PostOpList<ITensorInfo *> &post_ops) { - // All post ops must be elementwise and must not alter the shape of the original dst tensor after broadcasting for(const auto &op : post_ops.get_list()) { for(const auto &tensor : op->arguments()) { const TensorShape &out_shape = TensorShape::broadcast_shape(dst->tensor_shape(), (*tensor)->tensor_shape()); + // All post ops must be elementwise and must not alter the shape of the original dst tensor after broadcasting if(detail::have_different_dimensions(out_shape, dst->tensor_shape(), 0)) { return false; } + // NOTE: Kernel limitation: currently only the following broadcasting types are supported: + // 1. Post op arg is scalar, broadcast in both X and Y + // 2. Post op arg is of shape: Y=1, X=N, broadcast only in Y + // This means this case: Post op arg is of shape: Y=M, X=1, broadcast only in X, is NOT supported + if(dst->dimension(0) > 1 && dst->dimension(1) > 1 && (*tensor)->dimension(0) == 1 && (*tensor)->dimension(1) > 1) + { + return false; + } } } return true; |