From 1d4a320b7c638936a8b4a5c55ac59c61f63791a1 Mon Sep 17 00:00:00 2001 From: SiCongLi Date: Fri, 12 Nov 2021 15:38:00 +0000 Subject: Fix node fusion mutator ordering Partially resolves COMPMID-4966 Signed-off-by: SiCongLi Change-Id: I533bd29f416c923b71e7b753965a169253b00a52 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6694 Reviewed-by: Ramy Elgammal Reviewed-by: Sheri Zhang Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/graph/mutators/NodeFusionMutator.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/graph/mutators/NodeFusionMutator.cpp b/src/graph/mutators/NodeFusionMutator.cpp index 3f979e48ee..78f275f3bb 100644 --- a/src/graph/mutators/NodeFusionMutator.cpp +++ b/src/graph/mutators/NodeFusionMutator.cpp @@ -692,16 +692,20 @@ void NodeFusionMutator::mutate(Graph &g) // Fusion mutations - detail::fuse_layer(g, cl_target_prec, detail::fuse_convolution, supported_fused_activations); - detail::fuse_layer(g, empty_prec, detail::fuse_node_with_activation, supported_fused_activations); - detail::fuse_layer(g, empty_prec, detail::fuse_convolution_with_batch_normalization); detail::fuse_layer(g, empty_prec, detail::fuse_pad_with_convolution); detail::fuse_layer(g, empty_prec, detail::fuse_pad_with_convolution); + // The fusion of PostOps to ConvolutionLayer: + // It must occur after the fusion of PadLayer into ConvolutionLayer + // It must occur before the fusion of normal ActivationLayer into ConvolutionLayer as it takes precedence + detail::fuse_layer(g, cl_target_prec, detail::fuse_convolution, supported_fused_activations); detail::fuse_layer(g, empty_prec, detail::fuse_node_with_activation, supported_fused_activations); + detail::fuse_layer(g, empty_prec, detail::fuse_node_with_activation, supported_fused_activations); detail::fuse_layer(g, qs8_prec, detail::fuse_node_with_activation, supported_fused_activations); - detail::fuse_layer(g, empty_prec, detail::fuse_depthwise_convolution_with_batch_normalization); detail::fuse_layer(g, empty_prec, detail::fuse_node_with_activation, supported_fused_activations); detail::fuse_layer(g, cl_target_prec, detail::fuse_node_with_activation, supported_fused_activations); + // The fusion of BatchNormalizationLayer must occur after the fusion of ActivationLayer. Because FusedConvolutionBatchNormalizationNode assumes the BatchNormalization is already fused with activation, if any + detail::fuse_layer(g, empty_prec, detail::fuse_convolution_with_batch_normalization); + detail::fuse_layer(g, empty_prec, detail::fuse_depthwise_convolution_with_batch_normalization); } } // namespace graph } // namespace arm_compute -- cgit v1.2.1