From c65023e01d8e5c8f5af15dd8e2ca4fae3c4889f9 Mon Sep 17 00:00:00 2001 From: Sheri Zhang Date: Wed, 3 Nov 2021 21:24:00 +0000 Subject: Refine code for graph level fusion Partially resolves: COMPMID-4701 Signed-off-by: Sheri Zhang Change-Id: I11fb89bd31ef5a98ad9a2d6bb5fd0c1e8371b52f Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6572 Comments-Addressed: Arm Jenkins Reviewed-by: Gunes Bayir Reviewed-by: SiCong Li Tested-by: Arm Jenkins --- arm_compute/graph/INode.h | 28 +++++++++++++++------- arm_compute/graph/backends/FunctionHelpers.h | 1 + .../graph/nodes/FusedConvolutionWithPostOpNode.h | 23 +++++------------- arm_compute/graph/printers/DotGraphPrinter.h | 23 ------------------ 4 files changed, 27 insertions(+), 48 deletions(-) (limited to 'arm_compute/graph') diff --git a/arm_compute/graph/INode.h b/arm_compute/graph/INode.h index b92003464c..becd672d90 100644 --- a/arm_compute/graph/INode.h +++ b/arm_compute/graph/INode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 Arm Limited. + * Copyright (c) 2018-2019,2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -29,6 +29,7 @@ #include "arm_compute/graph/TensorDescriptor.h" #include "arm_compute/graph/Types.h" +#include #include namespace arm_compute @@ -240,18 +241,29 @@ public: * @return Assigned target of this node */ Target assigned_target() const; + /** Post operator info list + * + * @return Post operator info list + */ + const std::list> &post_op_info_list() const; + /** Post operator info list + * + * @return Post operator info list + */ + std::list> &post_op_info_list(); protected: friend class Graph; protected: - Graph *_graph; /**< Backward reference to graph owning the node */ - NodeID _id; /**< Node ID */ - NodeParams _common_params; /**< Node common params */ - std::vector _outputs; /**< Output of the node */ - std::vector _input_edges; /**< Inputs edge set */ - std::set _output_edges; /**< Output edge set */ - Target _assigned_target; /**< Assigned target by the Graph executor */ + Graph *_graph; /**< Backward reference to graph owning the node */ + NodeID _id; /**< Node ID */ + NodeParams _common_params; /**< Node common params */ + std::vector _outputs; /**< Output of the node */ + std::vector _input_edges; /**< Inputs edge set */ + std::set _output_edges; /**< Output edge set */ + Target _assigned_target; /**< Assigned target by the Graph executor */ + std::list> _post_op_info_list; /**< Post operator info list */ }; } // namespace graph } // namespace arm_compute diff --git a/arm_compute/graph/backends/FunctionHelpers.h b/arm_compute/graph/backends/FunctionHelpers.h index 6bec66a6ff..6aec3f6590 100644 --- a/arm_compute/graph/backends/FunctionHelpers.h +++ b/arm_compute/graph/backends/FunctionHelpers.h @@ -602,6 +602,7 @@ std::unique_ptr create_fused_convolution_with_post_op(FusedConvolutio std::unique_ptr func; std::string func_name; + // Fuse convolution with post ops is only supported for conv1x1, which is only implemented as gemmconv2d std::tie(func, func_name) = create_named_memory_managed_function( std::string("GEMMConvolutionLayer"), mm, input, weights, biases, output, conv_info, diff --git a/arm_compute/graph/nodes/FusedConvolutionWithPostOpNode.h b/arm_compute/graph/nodes/FusedConvolutionWithPostOpNode.h index 0bb3d1b7ef..6048994b02 100644 --- a/arm_compute/graph/nodes/FusedConvolutionWithPostOpNode.h +++ b/arm_compute/graph/nodes/FusedConvolutionWithPostOpNode.h @@ -72,16 +72,6 @@ public: * @return Fast math hint to be used by the node */ FastMathHint fast_math_hint() const; - /** Post operator info list - * - * @return Post operator info list - */ - const std::list> &post_op_info_list() const; - /** Post operator info list - * - * @return Post operator info list - */ - std::list> &post_op_info_list(); /** Convolution metadata accessor * * @return Convolution information @@ -129,13 +119,12 @@ public: static constexpr NodeType node_type = NodeType::FusedConvolutionWithPostOp; private: - PadStrideInfo _info; - unsigned int _num_groups; - ConvolutionMethod _method; - FastMathHint _fast_math_hint; - QuantizationInfo _out_quant_info; - ActivationLayerInfo _fused_activation; - std::list> _post_op_info_list; + PadStrideInfo _info; + unsigned int _num_groups; + ConvolutionMethod _method; + FastMathHint _fast_math_hint; + QuantizationInfo _out_quant_info; + ActivationLayerInfo _fused_activation; }; } // namespace graph } // namespace arm_compute diff --git a/arm_compute/graph/printers/DotGraphPrinter.h b/arm_compute/graph/printers/DotGraphPrinter.h index 41607e831a..42a20678fe 100644 --- a/arm_compute/graph/printers/DotGraphPrinter.h +++ b/arm_compute/graph/printers/DotGraphPrinter.h @@ -1,26 +1,3 @@ -/* - * Copyright (c) 2021 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ /* * Copyright (c) 2018-2019,2021 Arm Limited. * -- cgit v1.2.1