Skip to content

Commit 9d45afc

Browse files
Arm backend: Expand docformatter scope and format operator_support/ (#17243)
Add operator_support to the docformatter include list and reformat docstrings in the updated operator_support files. Signed-off-by: Sebastian Larsson <sebastian.larsson@arm.com>
1 parent 4aacfd6 commit 9d45afc

7 files changed

Lines changed: 37 additions & 19 deletions

File tree

.lintrunner.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ include_patterns = [
517517
'backends/arm/quantizer/**/*.py',
518518
'backends/arm/debug/**/*.py',
519519
'backends/arm/scripts/**/*.py',
520+
'backends/arm/operator_support/**/*.py',
520521
'backends/arm/*.py',
521522
]
522523
exclude_patterns = ['third-party/**', '**/third-party/**']

backends/arm/operator_support/control_flow_support.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 Arm Limited and/or its affiliates.
1+
# Copyright 2025-2026 Arm Limited and/or its affiliates.
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
@@ -46,8 +46,11 @@ def _fully_partitioned(submodule: fx.GraphModule) -> bool:
4646
def _submodules_fully_partitioned(
4747
node: fx.Node, exported_program: ExportedProgram
4848
) -> bool:
49-
"""Returns whether the submodule arguments to a cond node were fully partitioned.
49+
"""Returns whether the submodule arguments to a cond node were fully
50+
partitioned.
51+
5052
Updates "val" meta of the submodules if they are.
53+
5154
"""
5255
match node.target:
5356
case torch.ops.higher_order.cond:
@@ -83,7 +86,10 @@ def _tosa_spec_supports_cf(tosa_spec: TosaSpecification) -> bool:
8386

8487
class ControlFlowSubmoduleSupported(OperatorSupportBase):
8588
"""Check whether control flow submodule args should be partitioned.
86-
Applies control-flow extension constraints before allowing delegation."""
89+
90+
Applies control-flow extension constraints before allowing delegation.
91+
92+
"""
8793

8894
def __init__(
8995
self,
@@ -123,7 +129,10 @@ def is_node_supported(
123129

124130
class ControlFlowOpSupported(OperatorSupportBase):
125131
"""Check whether control flow ops should be partitioned.
126-
Applies control-flow extension constraints before allowing delegation."""
132+
133+
Applies control-flow extension constraints before allowing delegation.
134+
135+
"""
127136

128137
_targeted_ops = {
129138
torch.ops.higher_order.cond,

backends/arm/operator_support/gather_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
5-
"""
6-
Declare operator support for ``edge.aten.gather`` in TOSA.
5+
"""Declare operator support for ``edge.aten.gather`` in TOSA.
76
87
This support check matches the subset accepted by CanonicalizeGatherPass:
98
@@ -28,6 +27,7 @@
2827
indices as [N, W],then lowers via the TOSA gather dialect.
2928
- For 3D inputs CanonicalizeGatherPass permutes and reshapes values and indices
3029
to [N*C, K, 1] and [N*C, W] respectively, then lowers via the TOSA gather dialect.
30+
3131
"""
3232

3333
from typing import cast

backends/arm/operator_support/index_select_support.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- args: exactly (input, dim, index)
1313
- input rank must be >= 1 and dtype compatible with the active TOSA spec
1414
- index must be rank-1 and dtype int32
15+
1516
"""
1617

1718
import torch

backends/arm/operator_support/pool_2d_support.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def dilation_check(
9393
dilation (tuple[int,int]): Vertical and horizontal dilation.
9494
Returns:
9595
bool: True if dilation constraints are met.
96+
9697
"""
9798

9899
pad_h, pad_w = padding
@@ -197,12 +198,14 @@ def is_node_tosa_supported(self, node: fx.Node, tosa_spec: TosaSpecification):
197198

198199
@register_tosa_support_check
199200
class MaxPool2dSupported(SupportedTOSAOperatorCheck):
200-
"""Provide TOSA support checks for ``aten.max_pool2d_with_indices`` and ``aten.max_pool2d``.
201+
"""Provide TOSA support checks for ``aten.max_pool2d_with_indices`` and
202+
``aten.max_pool2d``.
201203
202204
Checks that dilation constraints are met for both ops.
203205
204-
Applies additional constraints to the aten.max_pool2d_with_indices op when targeting the U55 subset, including
205-
limits on kernel size, stride, and tensor ranks.
206+
Applies additional constraints to the aten.max_pool2d_with_indices op when
207+
targeting the U55 subset, including limits on kernel size, stride, and
208+
tensor ranks.
206209
207210
"""
208211

@@ -212,9 +215,10 @@ class MaxPool2dSupported(SupportedTOSAOperatorCheck):
212215
]
213216

214217
def is_node_tosa_supported(self, node: fx.Node, tosa_spec: TosaSpecification):
215-
"""
216-
Return True if ``max_pool2d`` satisfies dilation constraints.
218+
"""Return True if ``max_pool2d`` satisfies dilation constraints.
219+
217220
Return True if ``max_pool2d_with_indices`` satisfies both dilation constraints and U55 constraints.
221+
218222
"""
219223

220224
shape = cast(torch.Tensor, node.all_input_nodes[0].meta["val"]).shape

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def is_quantized(node: torch.fx.Node) -> bool:
184184
185185
Returns:
186186
bool: True if the node is quantized, False otherwise.
187+
187188
"""
188189

189190
try:
@@ -371,10 +372,11 @@ def is_node_supported(
371372

372373

373374
class CheckArmQuantized(OperatorSupportBase):
374-
"""
375-
Check if the node was marked as quantized in the Arm backend.
376-
This is used to ensure that nodes that were quantized in the Arm backend
377-
are only partitioned if they are supported by the TOSA backend.
375+
"""Check if the node was marked as quantized in the Arm backend.
376+
377+
This is used to ensure that nodes that were quantized in the Arm backend are
378+
only partitioned if they are supported by the TOSA backend.
379+
378380
"""
379381

380382
def __init__(self, reporter: WhyNoPartitionReporter):
@@ -610,7 +612,9 @@ def __init__(
610612
def is_node_supported(
611613
self, submodules: typing.Mapping[str, torch.nn.Module], node: fx.Node
612614
) -> bool:
613-
"""Return True if no disallowed dtypes are present on inputs or outputs."""
615+
"""Return True if no disallowed dtypes are present on inputs or
616+
outputs.
617+
"""
614618
if is_submodule_node(node):
615619
return True
616620
for input_node in (

backends/arm/operator_support/unfold_copy_support.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
5-
6-
"""
7-
Declare operator support for ``edge.aten.unfold_copy`` in TOSA.
5+
"""Declare operator support for ``edge.aten.unfold_copy`` in TOSA.
86
97
This support check matches the subset intended to be handled by the Arm
108
unfold lowering (e.g. DecomposeUnfoldToGatherPass), similar to how
@@ -22,6 +20,7 @@
2220
Notes:
2321
- Dtype/profile constraints apply (see dtype checks below).
2422
- This check assumes static shapes and constant dim/size/step.
23+
2524
"""
2625

2726
import torch

0 commit comments

Comments
 (0)