From 668ccdcfb81bfab3a2d44cd1ddd956e83a2dfb09 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Wed, 3 Feb 2021 10:32:59 +0000 Subject: Add dynamic tensor support to CpuElementwise The kernels and operators for binary and unary operations are now capable of being configured with dynamic shapes and computing windows at run-time. Additionally, changing arguments' names is done for consistency. Partially Implements: COMPMID-4127 Change-Id: I48e5038692db667dec7cb2b2906fe5683214fe19 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4973 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Tello Comments-Addressed: Arm Jenkins --- tests/Utils.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests/Utils.h') diff --git a/tests/Utils.h b/tests/Utils.h index 2569c41a9e..fe9fe712cf 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -814,6 +814,59 @@ inline void sync_tensor_if_necessary(TensorType &tensor) { ARM_COMPUTE_UNUSED(tensor); } + +/** Construct and return object for dimensions' state filled with the given value + * + * @param[in] value The value to fill + * + * @return Constructed class + */ +inline ITensorInfo::TensorDimsState construct_dims_state(int32_t value) +{ + auto states = ITensorInfo::TensorDimsState{}; + std::fill(states.begin(), states.end(), value); + return states; +} + +/** Construct and return object for dimensions' state filled with the value for dynamic state + * + * @return Constructed class filled with the value for dynamic state + */ +inline ITensorInfo::TensorDimsState construct_dynamic_dims_state() +{ + return construct_dims_state(ITensorInfo::get_dynamic_state_value()); +} + +/** Construct and return object for dimensions' state filled with the value for non-dynamic state + * + * @return Constructed class filled with the value for non-dynamic state + */ +inline ITensorInfo::TensorDimsState construct_static_dims_state() +{ + return construct_dims_state(ITensorInfo::get_static_state_value()); +} + +/** Set the dimension states of the given tensor to dynamic + * + * @param[in] t The tensor to set to dynamic state + * + */ +template +void set_tensor_dynamic(TensorType &t) +{ + t.info()->set_tensor_dims_state(construct_dynamic_dims_state()); +} + +/** Set the dimension states of the given tensor to state + * + * @param[in] t The tensor to set to static state + * + */ +template +void set_tensor_static(TensorType &t) +{ + t.info()->set_tensor_dims_state(construct_static_dims_state()); +} } // namespace test } // namespace arm_compute #endif /* ARM_COMPUTE_TEST_UTILS_H */ -- cgit v1.2.1