Skip to content

Commit 3c25aec

Browse files
Erik-Lundellfacebook-github-bot
authored andcommitted
Add docstrings to all unittest.TestCase:s (#4391)
Summary: This avoids logging a long default docstring which makes the output of test collection a lot easier to read and thus debug. I also updated the mv2net weight parameter as the current way of calling it is deprecated. This also removes a warning from test collection. Change-Id: I05f000e9ef42ab9d63f234539da3309f69ccbe16 Pull Request resolved: #4391 Reviewed By: cccclai Differential Revision: D60404067 Pulled By: digantdesai fbshipit-source-id: 4ad44eb35887278cacd7e2c0ac93114b125e72af
1 parent 38724d0 commit 3c25aec

16 files changed

+33
-1
lines changed

backends/arm/test/misc/test_debug_feats.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def forward(self, x):
4141

4242

4343
class TestDumpPartitionedArtifact(unittest.TestCase):
44+
"""Tests dumping the partition artifact in ArmTester. Both to file and to stdout."""
45+
4446
def _tosa_MI_pipeline(self, module: torch.nn.Module, dump_file=None):
4547
(
4648
ArmTester(
@@ -96,6 +98,8 @@ def test_BI_artifact(self):
9698

9799

98100
class TestNumericalDiffPrints(unittest.TestCase):
101+
"""Tests trigging the exception printout from the ArmTester's run and compare function."""
102+
99103
def test_numerical_diff_prints(self):
100104
model = Linear(20, 30)
101105
tester = (

backends/arm/test/models/test_mobilenet_v2_arm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323

2424
class TestMobileNetV2(unittest.TestCase):
25+
"""Tests MobileNetV2."""
2526

26-
mv2 = models.mobilenetv2.mobilenet_v2(weights=MobileNet_V2_Weights)
27+
mv2 = models.mobilenetv2.mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT)
2728
mv2 = mv2.eval()
2829
normalize = transforms.Normalize(
2930
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]

backends/arm/test/ops/test_add.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818

1919
class TestSimpleAdd(unittest.TestCase):
20+
"""Tests a single add op, x+x and x+y."""
21+
2022
class Add(torch.nn.Module):
2123
test_parameters = [
2224
(torch.FloatTensor([1, 2, 3, 5, 7]),),

backends/arm/test/ops/test_avg_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929

3030
class TestAvgPool2d(unittest.TestCase):
31+
"""Tests AvgPool2d."""
32+
3133
class AvgPool2d(torch.nn.Module):
3234
def __init__(
3335
self,

backends/arm/test/ops/test_batch_norm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@
497497

498498

499499
class TestBatchNorm2d(unittest.TestCase):
500+
"""Tests BatchNorm2d."""
501+
500502
class BatchNorm2d(torch.nn.Module):
501503
def __init__(
502504
self,

backends/arm/test/ops/test_clone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626

2727
class TestSimpleClone(unittest.TestCase):
28+
"""Tests clone."""
29+
2830
class Clone(torch.nn.Module):
2931
sizes = [10, 15, 50, 100]
3032
test_parameters = [(torch.ones(n),) for n in sizes]

backends/arm/test/ops/test_conv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ def forward(self, x):
244244

245245

246246
class TestConv2D(unittest.TestCase):
247+
"""Tests Conv2D, both single ops and multiple Convolutions in series."""
248+
247249
def _test_conv2d_tosa_MI_pipeline(
248250
self, module: torch.nn.Module, test_data: Tuple[torch.Tensor]
249251
):

backends/arm/test/ops/test_conv_combos.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ def forward(self, x):
154154

155155

156156
class TestConvCombos(unittest.TestCase):
157+
"""Tests conv combined with other ops."""
158+
157159
def _test_conv_combo_tosa_MI_pipeline(
158160
self, module: torch.nn.Module, test_data: Tuple[torch.Tensor]
159161
):

backends/arm/test/ops/test_depthwise_conv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132

133133

134134
class TestDepthwiseConv2D(unittest.TestCase):
135+
"""Tests Conv2D where groups == in_channels and out_channels = K * in_channels. This
136+
is a special case enables depthwise convolution."""
137+
135138
def _test_dw_conv2d_tosa_MI_pipeline(
136139
self, module: torch.nn.Module, test_data: Tuple[torch.Tensor]
137140
):

backends/arm/test/ops/test_div.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878

7979

8080
class TestDiv(unittest.TestCase):
81+
"""Tests division"""
82+
8183
class Div(torch.nn.Module):
8284
def __init__(
8385
self,

backends/arm/test/ops/test_full.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020

2121
class TestFull(unittest.TestCase):
22+
"""Tests the full op which creates a tensor of a given shape filled with a given value."""
23+
2224
class Full(torch.nn.Module):
2325
# A single full op
2426
def forward(self):

backends/arm/test/ops/test_linear.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292

9393
class TestLinear(unittest.TestCase):
94+
"""tests the linear operation y = Ax + b"""
9495

9596
_edge_compile_config: EdgeCompileConfig = EdgeCompileConfig(
9697
_skip_dim_order=True, # TODO(T182928844): Delegate dim order op to backend.

backends/arm/test/ops/test_mean_dim.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141

4242
class TestMeanDim(unittest.TestCase):
43+
"""Tests MeanDim, called AdaptiveAvgPool2d in Pytorch."""
44+
4345
class MeanDim(torch.nn.Module):
4446
def __init__(self):
4547
super().__init__()

backends/arm/test/ops/test_softmax.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929

3030
class TestSoftmax(unittest.TestCase):
31+
"""Tests softmax."""
32+
3133
class Softmax(torch.nn.Module):
3234
def __init__(self, dim: int = -1):
3335
super().__init__()

backends/arm/test/ops/test_view.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626

2727
class TestSimpleView(unittest.TestCase):
28+
"""Tests the view operation."""
29+
2830
class View(torch.nn.Module):
2931

3032
sizes = [10, 15, 50, 100]

backends/arm/test/passes/test_tag_io_quant_pass.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def forward(self, x):
2222

2323

2424
class TestTagIOQuantPass(unittest.TestCase):
25+
"""Tests the TagIOQuantPass which tags q/dq nodes on model inputs and outputs to not include them in our partitions."""
2526

2627
def _tosa_BI_u55_pipeline(self, module: torch.nn.Module):
2728
(

0 commit comments

Comments
 (0)