Skip to content

Commit 1ce615e

Browse files
psiddhGithub Executorch
andauthored
Fix circular import in cortex_m passes using relative imports (pytorch#16376)
Changed cortex_m_pass_manager.py to use relative imports (from .activation_fusion_pass) instead of absolute imports (from executorch.backends.cortex_m.passes) for intra-package references. This breaks the circular import chain: __init__.py → cortex_m_pass_manager.py → __init__.py Resolves: ImportError: cannot import name 'ActivationFusionPass' from partially initialized module 'executorch.backends.cortex_m.passes' ### Summary [PLEASE REMOVE] See [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests) for ExecuTorch PR guidelines. [PLEASE REMOVE] If this PR closes an issue, please add a `Fixes #<issue-id>` line. [PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: <area>" label. For a list of available release notes labels, check out [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests). ### Test plan [PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable. Co-authored-by: Github Executorch <github_executorch@arm.com>
1 parent ef79c3e commit 1ce615e

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎backends/cortex_m/passes/cortex_m_pass_manager.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
FoldAndAnnotateQParamsPass,
1111
ScalarsToAttributePass,
1212
)
13-
from executorch.backends.cortex_m.passes import (
14-
ActivationFusionPass,
15-
ClampHardswishPass,
16-
ConvertToCortexMPass,
17-
DecomposeHardswishPass,
18-
QuantizedOpFusionPass,
19-
ReplaceQuantNodesPass,
20-
)
2113
from executorch.backends.transforms.replace_scalar_with_tensor import (
2214
ReplaceScalarWithTensorArgPass,
2315
)
@@ -26,6 +18,13 @@
2618
from executorch.exir.program._program import _transform
2719
from torch.export import ExportedProgram
2820

21+
from .activation_fusion_pass import ActivationFusionPass
22+
from .clamp_hardswish_pass import ClampHardswishPass
23+
from .convert_to_cortex_m_pass import ConvertToCortexMPass
24+
from .decompose_hardswish_pass import DecomposeHardswishPass
25+
from .quantized_op_fusion_pass import QuantizedOpFusionPass
26+
from .replace_quant_nodes_pass import ReplaceQuantNodesPass
27+
2928

3029
class CortexMPassManager(PassManager):
3130

‎backends/cortex_m/quantizer/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
SOFTMAX_OUTPUT_FIXED_QSPEC,
1717
SOFTMAX_PER_TENSOR_CONFIG,
1818
)
19-
from .quantizer import CortexMQuantizer, SharedQspecQuantizer # noqa

0 commit comments

Comments
 (0)