aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/Validate.h
diff options
context:
space:
mode:
authorIoan-Cristian Szabo <ioan-cristian.szabo@arm.com>2017-10-27 17:35:40 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:47:18 +0000
commit91d20d95df35961d3eb5de497007d98576118d19 (patch)
tree13042e212d65fbf5bd7425079bb72b6bd1e2e84d /arm_compute/core/Validate.h
parent19835e591cb0b66a0f5000ae1505bf299e50337d (diff)
downloadComputeLibrary-91d20d95df35961d3eb5de497007d98576118d19.tar.gz
COMPMID-582: Add validation to channel_extract kernels.
Change-Id: I6413a05f6870a0d04f12d7348269b15297ae8493 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/114696 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/core/Validate.h')
-rw-r--r--arm_compute/core/Validate.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/arm_compute/core/Validate.h b/arm_compute/core/Validate.h
index 4ef0e11433..b04d293c4c 100644
--- a/arm_compute/core/Validate.h
+++ b/arm_compute/core/Validate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -271,6 +271,38 @@ arm_compute::Status error_on_mismatching_dimensions(const char *function, const
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...) \
ARM_COMPUTE_RETURN_ON_ERROR(::arm_compute::error_on_mismatching_dimensions(__func__, __FILE__, __LINE__, __VA_ARGS__))
+/** Return an error if the passed tensor objects are not even.
+ *
+ * @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 odd shape is allowed
+ * @param[in] tensor1 The first object to be compared for odd shape.
+ * @param[in] tensors (Optional) Further allowed objects.
+ *
+ * @return Status
+ */
+template <typename... Ts>
+arm_compute::Status error_on_tensors_not_even(const char *function, const char *file, int line,
+ const Format &format, 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 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)
+ {
+ const TensorShape correct_shape = adjust_odd_shape(tensor->info()->tensor_shape(), format);
+ return detail::have_different_dimensions(tensor->info()->tensor_shape(), correct_shape, 2);
+ }),
+ function, file, line, "Tensor shape has odd dimensions");
+ return arm_compute::Status{};
+}
+
+#define ARM_COMPUTE_ERROR_ON_TENSORS_NOT_EVEN(...) \
+ ARM_COMPUTE_ERROR_THROW_ON(::arm_compute::error_on_tensors_not_even(__func__, __FILE__, __LINE__, __VA_ARGS__))
+#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 two tensor infos have different shapes from the given dimension
*
* @param[in] function Function in which the error occurred.