fix(nxp): check the conv/linear node's user count in BatchNorm fusion#20601
Open
durvesh1992 wants to merge 1 commit into
Open
fix(nxp): check the conv/linear node's user count in BatchNorm fusion#20601durvesh1992 wants to merge 1 commit into
durvesh1992 wants to merge 1 commit into
Conversation
The _is_conv / _is_linear closures in the NXP BatchNorm fusion passes checked len(node.users) instead of len(node_.users). node_ is the closure parameter (the conv/linear node being tested), but node resolves to the enclosing 'for node in graph_module.graph.nodes' loop variable, which at the call site is always the BatchNorm node. The single-user guard is meant to prevent fusion when the conv/linear output feeds consumers other than the BatchNorm, since folding the BatchNorm into the conv/linear weights changes that output for all of them. Because of the typo the guard inspected the BatchNorm's user count, so a conv/linear with multiple consumers was still fused, corrupting the other consumers' inputs.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20601
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
_is_conv/_is_linearclosures in the NXP BatchNorm fusion passes checklen(node.users)instead oflen(node_.users).node_is the closure's parameter (the conv/linear node being tested), butnoderesolves to the enclosingfor node in graph_module.graph.nodesloop variable — which at the call site (_is_conv(bn_node.args[0])) is always the BatchNorm node.The single-user guard exists to prevent fusion when the conv/linear output feeds consumers other than the BatchNorm, because folding the BatchNorm into the conv/linear weights changes that output for all consumers. Due to the typo the guard inspected the BatchNorm's user count rather than the conv/linear's, so a conv/linear with multiple consumers was still fused — corrupting the other consumers' inputs.
Affected files:
backends/nxp/aten_passes/fuse_batch_norm_with_conv_pass.pybackends/nxp/aten_passes/fuse_batch_norm_with_linear_pass.pyTest plan
Reproduced on a small
torch.fxgraph where the conv has two consumers (BatchNorm + a relu), so fusion must be skipped:The linear pass contains the identical typo and the identical one-character fix.