aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/fixtures/ElementWiseUnaryFixture.h
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2021-02-03 10:32:59 +0000
committerSang-Hoon Park <sang-hoon.park@arm.com>2021-03-08 17:00:45 +0000
commit668ccdcfb81bfab3a2d44cd1ddd956e83a2dfb09 (patch)
treed139e1a770bcfc182f1aef38a1b908d634f9bb1c /tests/validation/fixtures/ElementWiseUnaryFixture.h
parent201e0fee596dafcf9c869a550fae29779aad2394 (diff)
downloadComputeLibrary-668ccdcfb81bfab3a2d44cd1ddd956e83a2dfb09.tar.gz
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 <sang-hoon.park@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4973 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/fixtures/ElementWiseUnaryFixture.h')
-rw-r--r--tests/validation/fixtures/ElementWiseUnaryFixture.h35
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/validation/fixtures/ElementWiseUnaryFixture.h b/tests/validation/fixtures/ElementWiseUnaryFixture.h
index 8cffef48f6..9729907630 100644
--- a/tests/validation/fixtures/ElementWiseUnaryFixture.h
+++ b/tests/validation/fixtures/ElementWiseUnaryFixture.h
@@ -44,11 +44,12 @@ class ElementWiseUnaryValidationFixture : public framework::Fixture
{
public:
template <typename...>
- void setup(TensorShape input_shape, DataType input_data_type, bool in_place, ElementWiseUnary op)
+ void setup(TensorShape input_shape, DataType input_data_type, bool in_place, ElementWiseUnary op, bool use_dynamic_shape = false)
{
- _op = op;
- _target = compute_target(input_shape, input_data_type, in_place);
- _reference = compute_reference(input_shape, input_data_type);
+ _op = op;
+ _target = compute_target(input_shape, input_data_type, in_place);
+ _reference = compute_reference(input_shape, input_data_type);
+ _use_dynamic_shape = use_dynamic_shape;
}
protected:
@@ -131,10 +132,24 @@ protected:
TensorType *actual_dst = in_place ? &src : &dst;
+ // if _use_dynamic_shape is true, this fixture will test scenario for dynamic shapes.
+ // - At configure time, all input tensors are marked as dynamic using set_tensor_dynamic()
+ // - After configure, tensors are marked as static for run using set_tensor_static()
+ // - The tensors with static shape are given to run()
+ if(_use_dynamic_shape)
+ {
+ set_tensor_dynamic(src);
+ }
+
// Create and configure function
FunctionType elwiseunary_layer;
elwiseunary_layer.configure(&src, actual_dst);
+ if(_use_dynamic_shape)
+ {
+ set_tensor_static(src);
+ }
+
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
src.allocator()->allocate();
ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS);
@@ -175,6 +190,7 @@ protected:
TensorType _target{};
SimpleTensor<T> _reference{};
ElementWiseUnary _op{};
+ bool _use_dynamic_shape{ false };
};
template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
@@ -189,6 +205,17 @@ public:
};
template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
+class RsqrtDynamicShapeValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>
+{
+public:
+ template <typename...>
+ void setup(const TensorShape &shape, DataType data_type)
+ {
+ ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, data_type, false, ElementWiseUnary::RSQRT, true);
+ }
+};
+
+template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
class ExpValidationFixture : public ElementWiseUnaryValidationFixture<TensorType, AccessorType, FunctionType, T>
{
public: