From cc2877368d5e15d9ea89d31c84ec651fc0fffd13 Mon Sep 17 00:00:00 2001 From: Gunes Bayir Date: Thu, 19 Jan 2023 15:56:00 +0000 Subject: Change dynamic fusion API to return destination tensor info The new dynamic fusion API is introduced in the following patch: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8906 For each operator (except Conv2D, which is migrated in the above patch), we - remove destination tensor from is_supported, validate and create calls - make create_op return ITensorInfo* to the intermediate destination object Affected operators: - DepthwiseConv2D - Cast - Elementwise Ops - Clamp - Reshape - Resize Resolves: COMPMID-5777 Change-Id: Ib60ec8a5f081752808455d7a7d790f2ed0627059 Signed-off-by: Gunes Bayir Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8991 Reviewed-by: Ramy Elgammal Reviewed-by: Jakub Sujak Dynamic-Fusion: Ramy Elgammal Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- .../dynamic_fusion/gpu/cl/DepthwiseConv2dFixture.h | 16 +++++++-------- .../gpu/cl/ElementwiseBinaryFixture.h | 23 +++++++++------------- .../dynamic_fusion/operators/CastFixture.h | 8 +++----- .../dynamic_fusion/operators/ClampFixture.h | 20 +++++++------------ .../dynamic_fusion/operators/ReshapeFixture.h | 10 +++++----- .../dynamic_fusion/operators/ResizeFixture.h | 8 +++----- 6 files changed, 34 insertions(+), 51 deletions(-) (limited to 'tests/validation/fixtures/dynamic_fusion') diff --git a/tests/validation/fixtures/dynamic_fusion/gpu/cl/DepthwiseConv2dFixture.h b/tests/validation/fixtures/dynamic_fusion/gpu/cl/DepthwiseConv2dFixture.h index 630b664b78..235c8602b1 100644 --- a/tests/validation/fixtures/dynamic_fusion/gpu/cl/DepthwiseConv2dFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/gpu/cl/DepthwiseConv2dFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -130,15 +130,13 @@ protected: GpuWorkloadSketch sketch{ &gpu_ctx }; // Create sketch tensors - auto input_info = sketch.create_tensor_info(TensorInfo(input_shape, 1, _data_type, _data_layout)); - auto weight_info = sketch.create_tensor_info(TensorInfo(weights_shape, 1, _data_type, _data_layout)); - auto bias_info = sketch.create_tensor_info(TensorInfo(bias_shape, 1, _data_type, _data_layout)); - auto dst_info = sketch.create_tensor_info(); + TensorInfo input_info = sketch.create_tensor_info(TensorInfo(input_shape, 1, _data_type, _data_layout)); + TensorInfo weight_info = sketch.create_tensor_info(TensorInfo(weights_shape, 1, _data_type, _data_layout)); + TensorInfo bias_info = sketch.create_tensor_info(TensorInfo(bias_shape, 1, _data_type, _data_layout)); + TensorInfo dst_info = sketch.create_tensor_info(); - auto ans_info = sketch.create_tensor_info(); - - FunctionType::create_op(sketch, &input_info, &weight_info, &bias_info, &ans_info, dwc_conv2d_attr); - GpuOutput::create_op(sketch, &ans_info, &dst_info); + ITensorInfo *ans_info = FunctionType::create_op(sketch, &input_info, &weight_info, &bias_info, dwc_conv2d_attr); + GpuOutput::create_op(sketch, ans_info, &dst_info); // Configure runtime ClWorkloadRuntime runtime; diff --git a/tests/validation/fixtures/dynamic_fusion/gpu/cl/ElementwiseBinaryFixture.h b/tests/validation/fixtures/dynamic_fusion/gpu/cl/ElementwiseBinaryFixture.h index f97b541ce3..e2722a1bdc 100644 --- a/tests/validation/fixtures/dynamic_fusion/gpu/cl/ElementwiseBinaryFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/gpu/cl/ElementwiseBinaryFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -105,28 +105,23 @@ protected: GpuWorkloadSketch sketch{ &gpu_ctx }; // Fuse first element wise binary Op - auto lhs_info = sketch.create_tensor_info(shape0, 1, _data_type); - auto rhs_info = sketch.create_tensor_info(TensorInfo(shape1, 1, _data_type)); - - auto ans_info = sketch.create_tensor_info(); - auto dst_info = sketch.create_tensor_info(); + TensorInfo lhs_info = sketch.create_tensor_info(shape0, 1, _data_type); + TensorInfo rhs_info = sketch.create_tensor_info(TensorInfo(shape1, 1, _data_type)); + TensorInfo dst_info = sketch.create_tensor_info(); TensorInfo rhs_info_fuse; - TensorInfo ans2_info; - FunctionType::create_op(sketch, &lhs_info, &rhs_info, &ans_info); + ITensorInfo *ans_info = FunctionType::create_op(sketch, &lhs_info, &rhs_info); if(_fuse) { - rhs_info_fuse = sketch.create_tensor_info(shape2, 1, _data_type); - ans2_info = sketch.create_tensor_info(); - - FunctionType::create_op(sketch, &ans_info, &rhs_info_fuse, &ans2_info); - GpuOutput::create_op(sketch, &ans2_info, &dst_info); + rhs_info_fuse = sketch.create_tensor_info(shape2, 1, _data_type); + ITensorInfo *ans2_info = FunctionType::create_op(sketch, ans_info, &rhs_info_fuse); + GpuOutput::create_op(sketch, ans2_info, &dst_info); } else { - GpuOutput::create_op(sketch, &ans_info, &dst_info); + GpuOutput::create_op(sketch, ans_info, &dst_info); } // Configure runtime diff --git a/tests/validation/fixtures/dynamic_fusion/operators/CastFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/CastFixture.h index 418cf4fe04..bd999027b3 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/CastFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/CastFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -122,10 +122,8 @@ protected: CastAttributes attributes; attributes.convert_policy(policy).data_type(dt_out); - auto ans_info = sketch.create_tensor_info(); - - FunctionType::create_op(sketch, &src_info, &ans_info, attributes); - GpuOutput::create_op(sketch, &ans_info, &dst_info); + ITensorInfo *ans_info = FunctionType::create_op(sketch, &src_info, attributes); + GpuOutput::create_op(sketch, ans_info, &dst_info); // Configure runtime ClWorkloadRuntime runtime; diff --git a/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h index fe87d9a022..a1fd22582f 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/ClampFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Arm Limited. + * Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -94,8 +94,8 @@ protected: template void fill(U &&tensor) { - float min_bound = 0; - float max_bound = 0; + float min_bound = 0; + float max_bound = 0; std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, _data_type); library->fill_static_values(tensor, get_boundary_values(static_cast(min_bound), static_cast(max_bound))); } @@ -111,21 +111,15 @@ protected: TensorInfo src_info = sketch.create_tensor_info(TensorInfo(shape, 1, _data_type)); 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); - + ITensorInfo *ans_0_info = FunctionType::create_op(sketch, &src_info, attributes); if(_fuse) { - 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); + ITensorInfo *ans_1_info = FunctionType::create_op(sketch, ans_0_info, attributes); + GpuOutput::create_op(sketch, ans_1_info, &dst_info); } else { - GpuOutput::create_op(sketch, &ans_0_info, &dst_info); + GpuOutput::create_op(sketch, ans_0_info, &dst_info); } // Configure runtime diff --git a/tests/validation/fixtures/dynamic_fusion/operators/ReshapeFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/ReshapeFixture.h index a427d814cb..0d3b1f0296 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/ReshapeFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/ReshapeFixture.h @@ -75,13 +75,13 @@ protected: GpuWorkloadSketch sketch{ &gpu_ctx }; // Create sketch tensors - auto src_info = sketch.create_tensor_info(TensorInfo(input_shape, 1, data_type)); - auto ans_info = sketch.create_tensor_info(TensorInfo(output_shape, 1, data_type)); - auto dst_info = sketch.create_tensor_info(TensorInfo(output_shape, 1, data_type)); + TensorInfo src_info = sketch.create_tensor_info(TensorInfo(input_shape, 1, data_type)); + TensorInfo dst_info = sketch.create_tensor_info(TensorInfo(output_shape, 1, data_type)); ReshapeAttributes attributes; attributes.shape(output_shape); - FunctionType::create_op(sketch, &src_info, &ans_info, attributes); - GpuOutput::create_op(sketch, &ans_info, &dst_info); + + ITensorInfo *ans_info = FunctionType::create_op(sketch, &src_info, attributes); + GpuOutput::create_op(sketch, ans_info, &dst_info); // Configure runtime ClWorkloadRuntime runtime; diff --git a/tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h index 5cdf52e62b..7eb820e0eb 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/ResizeFixture.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Arm Limited. +* Copyright (c) 2022-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -148,10 +148,8 @@ protected: ResizeAttributes attributes; attributes.align_corners(_align_corners).sampling_policy(_sampling_policy).interpolation_policy(_interpolation_policy).output_width(_output_width).output_height(_output_height); - TensorInfo scale_result_info = sketch.create_tensor_info(); - - FunctionType::create_op(sketch, &src_info, &scale_result_info, attributes); - GpuOutput::create_op(sketch, &scale_result_info, &dst_info); + ITensorInfo *scale_result_info = FunctionType::create_op(sketch, &src_info, attributes); + GpuOutput::create_op(sketch, scale_result_info, &dst_info); // Configure runtime ClWorkloadRuntime runtime; -- cgit v1.2.1