Skip to content

Commit e022e34

Browse files
Arm backend: Make all partitioned Batchnorm2D to conv (#11148)
Batchnorm2Ds can be fused with preceeding convs. For float, this is done in the FuseBatchnorm2dPass which with this patch is updated to insert 'transparent' convs before stand-alone bns. This way all bns are fused with convs instead of decomposed, so DecomposeBatchNorm2DPass is removed. For quantized, this is done by _fuse_conv_bn_(model) in the prepare_p2e function, before the transform_for_annotation pipeline. This does not allow us to modify the graph before the transform. Running our own DecomposeBatchNorm2dPass before quantization on the other hand requires modifying constant tensors before the export step which is a non trival effort. Since stand-alone batchnorms are not likely to be seen in real graphs, instead simply do not accept quantized stand-alone batchnorms for now. tosa_supported_operators is updated to give a better explanation in this case. Additionally refactors batchnorm unittest no be more brief and to more properly reflect what works and not. Signed-off-by: Adrian Lundell <[email protected]>
1 parent 8edf7ab commit e022e34

File tree

8 files changed

+363
-684
lines changed

8 files changed

+363
-684
lines changed

backends/arm/_passes/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from .convert_split_to_slice import ConvertSplitToSlicePass # noqa
2121
from .convert_squeezes_to_view import ConvertSqueezesToViewPass # noqa
2222
from .convert_to_clamp import ConvertToClampPass # noqa
23-
from .decompose_batchnorm_pass import DecomposeBatchNormPass # noqa
2423
from .decompose_cosine_similarity_pass import DecomposeCosineSimilarityPass # noqa
2524
from .decompose_div_pass import DecomposeDivPass # noqa
2625
from .decompose_gelu_pass import DecomposeGeluPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
ConvertSplitToSlicePass,
2525
ConvertSqueezesToViewPass,
2626
ConvertToClampPass,
27-
DecomposeBatchNormPass,
2827
DecomposeCosineSimilarityPass,
2928
DecomposeDivPass,
3029
DecomposeGeluPass,
@@ -85,7 +84,6 @@ def _transform(self, graph_module: GraphModule):
8584
def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModule:
8685
self.add_pass(FuseQuantizedActivationPass())
8786
self.add_pass(RemoveGetItemPass())
88-
self.add_pass(DecomposeBatchNormPass())
8987
self.add_pass(ConvertSplitToSlicePass())
9088
self.add_pass(ConvertMmToBmmPass())
9189
self.add_pass(DecomposeLinearPass())
@@ -143,7 +141,6 @@ def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
143141
self.add_pass(ConvertMmToBmmPass())
144142
self.add_pass(DecomposeLinearPass())
145143
self.add_pass(DecomposeLeakyReLUPass())
146-
self.add_pass(DecomposeBatchNormPass())
147144
self.add_pass(DecomposeLayerNormPass())
148145
self.add_pass(DecomposeVarPass())
149146
self.add_pass(

backends/arm/_passes/decompose_batchnorm_pass.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)