diff options
author | Ioan-Cristian Szabo <ioan-cristian.szabo@arm.com> | 2017-11-16 17:55:03 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:49:16 +0000 |
commit | ae3c8abdd9cf474d39991863f9170257f4a28ff2 (patch) | |
tree | 2447fe28aeb0131e0cdd6c6b8101127396061028 /arm_compute | |
parent | 156fcf3f36f6168e47d65db167bba3af5037e3d9 (diff) | |
download | ComputeLibrary-ae3c8abdd9cf474d39991863f9170257f4a28ff2.tar.gz |
COMPMID-584: Add validation to channel_combine kernels
Change-Id: I67fe3fcea08704d9f4b04d22fe34db83b2697b87
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/110562
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r-- | arm_compute/core/Validate.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h index 8a0257407c..d7a90480fc 100644 --- a/arm_compute/core/Validate.h +++ b/arm_compute/core/Validate.h @@ -320,6 +320,39 @@ arm_compute::Status error_on_tensors_not_even(const char *function, const char * #define ARM_COMPUTE_RETURN_ERROR_ON_TENSORS_NOT_EVEN(...) \ ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_tensors_not_even(__func__, __FILE__, __LINE__, __VA_ARGS__)) +/** Return an error if the passed tensor objects are not sub-sampled. + * + * @param[in] function Function in which the error occurred. + * @param[in] file Name of the file where the error occurred. + * @param[in] line Line on which the error occurred. + * @param[in] format Format to check if sub-sampling allowed. + * @param[in] shape The tensor shape to calculate sub-sampling from. + * @param[in] tensor1 The first object to be compared. + * @param[in] tensors (Optional) Further allowed objects. + * + * @return Status + */ +template <typename... Ts> +arm_compute::Status error_on_tensors_not_subsampled(const char *function, const char *file, int line, + const Format &format, const TensorShape &shape, const ITensor *tensor1, Ts... tensors) +{ + ARM_COMPUTE_RETURN_ERROR_ON_LOC(tensor1 == nullptr, function, file, line); + ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_nullptr(function, file, line, std::forward<Ts>(tensors)...)); + const TensorShape sub2_shape = calculate_subsampled_shape(shape, format); + const std::array < const ITensor *, 1 + sizeof...(Ts) > tensors_info_array{ { tensor1, std::forward<Ts>(tensors)... } }; + ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(std::any_of(tensors_info_array.cbegin(), tensors_info_array.cend(), [&](const ITensor * tensor) + { + return detail::have_different_dimensions(tensor->info()->tensor_shape(), sub2_shape, 2); + }), + function, file, line, "Tensor shape has mismatch dimensions for sub-sampling"); + return arm_compute::Status{}; +} + +#define ARM_COMPUTE_ERROR_ON_TENSORS_NOT_SUBSAMPLED(...) \ + ARM_COMPUTE_ERROR_THROW_ON(::arm_compute::error_on_tensors_not_subsampled(__func__, __FILE__, __LINE__, __VA_ARGS__)) +#define ARM_COMPUTE_RETURN_ERROR_ON_TENSORS_NOT_SUBSAMPLED(...) \ + ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_tensors_not_subsampled(__func__, __FILE__, __LINE__, __VA_ARGS__)) + /** Return an error if the passed two tensor infos have different shapes from the given dimension * * @param[in] function Function in which the error occurred. |