diff options
author | SiCongLi <sicong.li@arm.com> | 2021-11-12 15:38:00 +0000 |
---|---|---|
committer | Sheri Zhang <sheri.zhang@arm.com> | 2021-11-25 12:53:29 +0000 |
commit | 1d4a320b7c638936a8b4a5c55ac59c61f63791a1 (patch) | |
tree | 910cb6cacda9ec85c53358ed265143040bd306ed /src/graph/mutators/NodeFusionMutator.cpp | |
parent | 48f261526b77f61607478f3f809dd8647e626f2b (diff) | |
download | ComputeLibrary-1d4a320b7c638936a8b4a5c55ac59c61f63791a1.tar.gz |
Fix node fusion mutator ordering
Partially resolves COMPMID-4966
Signed-off-by: SiCongLi <sicong.li@arm.com>
Change-Id: I533bd29f416c923b71e7b753965a169253b00a52
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6694
Reviewed-by: Ramy Elgammal <ramy.elgammal@arm.com>
Reviewed-by: Sheri Zhang <sheri.zhang@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/graph/mutators/NodeFusionMutator.cpp')
-rw-r--r-- | src/graph/mutators/NodeFusionMutator.cpp | 12 |
1 files 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<ConvolutionLayerNode>(g, cl_target_prec, detail::fuse_convolution<ConvolutionLayerNode>, supported_fused_activations); - detail::fuse_layer<ConvolutionLayerNode, ActivationLayerNode>(g, empty_prec, detail::fuse_node_with_activation<ConvolutionLayerNode>, supported_fused_activations); - detail::fuse_layer<ConvolutionLayerNode, BatchNormalizationLayerNode>(g, empty_prec, detail::fuse_convolution_with_batch_normalization); detail::fuse_layer<PadLayerNode, ConvolutionLayerNode>(g, empty_prec, detail::fuse_pad_with_convolution<ConvolutionLayerNode>); detail::fuse_layer<PadLayerNode, DepthwiseConvolutionLayerNode>(g, empty_prec, detail::fuse_pad_with_convolution<DepthwiseConvolutionLayerNode>); + // 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<ConvolutionLayerNode>(g, cl_target_prec, detail::fuse_convolution<ConvolutionLayerNode>, supported_fused_activations); detail::fuse_layer<BatchNormalizationLayerNode, ActivationLayerNode>(g, empty_prec, detail::fuse_node_with_activation<BatchNormalizationLayerNode>, supported_fused_activations); + detail::fuse_layer<ConvolutionLayerNode, ActivationLayerNode>(g, empty_prec, detail::fuse_node_with_activation<ConvolutionLayerNode>, supported_fused_activations); detail::fuse_layer<DepthwiseConvolutionLayerNode, ActivationLayerNode>(g, qs8_prec, detail::fuse_node_with_activation<DepthwiseConvolutionLayerNode>, supported_fused_activations); - detail::fuse_layer<DepthwiseConvolutionLayerNode, BatchNormalizationLayerNode>(g, empty_prec, detail::fuse_depthwise_convolution_with_batch_normalization); detail::fuse_layer<FullyConnectedLayerNode, ActivationLayerNode>(g, empty_prec, detail::fuse_node_with_activation<FullyConnectedLayerNode>, supported_fused_activations); detail::fuse_layer<EltwiseLayerNode, ActivationLayerNode>(g, cl_target_prec, detail::fuse_node_with_activation<EltwiseLayerNode>, 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<ConvolutionLayerNode, BatchNormalizationLayerNode>(g, empty_prec, detail::fuse_convolution_with_batch_normalization); + detail::fuse_layer<DepthwiseConvolutionLayerNode, BatchNormalizationLayerNode>(g, empty_prec, detail::fuse_depthwise_convolution_with_batch_normalization); } } // namespace graph } // namespace arm_compute |