From b84e25313e5dc7acbc03623e1e071e845047c111 Mon Sep 17 00:00:00 2001 From: Viet-Hoa Do Date: Tue, 13 Dec 2022 13:09:10 +0000 Subject: Add output operator for dynamic fusion * The output of the fused operator must be explicitly specified using GpuOutput operator. * Any temporary tensors used to connect the output of an operator to the input of another operator will be marked as no-alloc and won't be allocated as a tensor in the memory. Resolves: COMPMID-5771 Signed-off-by: Viet-Hoa Do Change-Id: I5ae8e800f8f737db23a055a92b01c4f1d78c3bb8 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8794 Tested-by: Arm Jenkins Reviewed-by: SiCong Li Reviewed-by: Gian Marco Iodice Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- .../dynamic_fusion/operators/ClampFixture.h | 51 +++++++++------------- 1 file changed, 20 insertions(+), 31 deletions(-) (limited to 'tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h') diff --git a/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h index dbac29fd22..fe87d9a022 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h @@ -29,6 +29,7 @@ #include "arm_compute/core/Types.h" #include "arm_compute/dynamic_fusion/runtime/gpu/cl/ClWorkloadRuntime.h" #include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h" +#include "arm_compute/dynamic_fusion/sketch/gpu/operators/GpuOutput.h" #include "tests/framework/Fixture.h" #include "tests/validation/reference/ActivationLayer.h" @@ -108,14 +109,23 @@ protected: // Create sketch tensors TensorInfo src_info = sketch.create_tensor_info(TensorInfo(shape, 1, _data_type)); - TensorInfo dst_0_info = sketch.create_tensor_info(TensorInfo(shape, 1, _data_type)); - TensorInfo dst_1_info; + TensorInfo dst_info = sketch.create_tensor_info(TensorInfo(shape, 1, _data_type)); + + auto ans_0_info = sketch.create_tensor_info(); + TensorInfo ans_1_info; + + FunctionType::create_op(sketch, &src_info, &ans_0_info, attributes); - FunctionType::create_op(sketch, &src_info, &dst_0_info, attributes); if(_fuse) { - dst_1_info = sketch.create_tensor_info(shape, 1, _data_type); - FunctionType::create_op(sketch, &dst_0_info, &dst_1_info, attributes); + ans_1_info = sketch.create_tensor_info(); + + FunctionType::create_op(sketch, &ans_0_info, &ans_1_info, attributes); + GpuOutput::create_op(sketch, &ans_1_info, &dst_info); + } + else + { + GpuOutput::create_op(sketch, &ans_0_info, &dst_info); } // Configure runtime @@ -124,43 +134,22 @@ protected: // Construct user tensors TensorType t_src{}; - TensorType t_dst_0{}; - TensorType t_dst_1{}; + TensorType t_dst{}; // Initialize user tensors t_src.allocator()->init(src_info); - t_dst_0.allocator()->init(dst_0_info); - if(_fuse) - { - t_dst_1.allocator()->init(dst_1_info); - } + t_dst.allocator()->init(dst_info); // Allocate and fill user tensors t_src.allocator()->allocate(); - t_dst_0.allocator()->allocate(); - if(_fuse) - { - t_dst_1.allocator()->allocate(); - } + t_dst.allocator()->allocate(); fill(AccessorType(t_src)); // Run runtime - if(_fuse) - { - runtime.run({ &t_src, &t_dst_1 }); - } - else - { - runtime.run({ &t_src, &t_dst_0 }); - } - - if(_fuse) - { - return t_dst_1; - } + runtime.run({ &t_src, &t_dst }); - return t_dst_0; + return t_dst; } SimpleTensor compute_reference(const TensorShape &shape, ActivationLayerInfo act_info) -- cgit v1.2.1