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 --- .../validation/fixtures/ElementWiseUnaryFixture.h | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'tests/validation/fixtures/ElementWiseUnaryFixture.h') 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 - 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 _reference{}; ElementWiseUnary _op{}; + bool _use_dynamic_shape{ false }; }; template @@ -188,6 +204,17 @@ public: } }; +template +class RsqrtDynamicShapeValidationFixture : public ElementWiseUnaryValidationFixture +{ +public: + template + void setup(const TensorShape &shape, DataType data_type) + { + ElementWiseUnaryValidationFixture::setup(shape, data_type, false, ElementWiseUnary::RSQRT, true); + } +}; + template class ExpValidationFixture : public ElementWiseUnaryValidationFixture { -- cgit v1.2.1