mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE] [3/3] Rewrite super() calls in test (#94592)
Rewrite Python built-in class `super()` calls. Only non-semantic changes should be applied. - #94587 - #94588 - #94592 Also, methods with only a `super()` call are removed: ```diff class MyModule(nn.Module): - def __init__(self): - super().__init__() - def forward(self, ...): ... ``` Some cases that change the semantics should be kept unchanged. E.g.:f152a79be9/caffe2/python/net_printer.py (L184-L190)f152a79be9/test/test_jit_fuser_te.py (L2628-L2635)Pull Request resolved: https://github.com/pytorch/pytorch/pull/94592 Approved by: https://github.com/ezyang, https://github.com/seemethere
This commit is contained in:
committed by
PyTorch MergeBot
parent
bdd8f518d7
commit
046e88a291
@ -178,7 +178,7 @@ def output_graph(a, b, c, iters: int):
|
||||
|
||||
class SubModule(nn.Module):
|
||||
def __init__(self):
|
||||
super(SubModule, self).__init__()
|
||||
super().__init__()
|
||||
self.a = 11
|
||||
self.b = 2
|
||||
|
||||
@ -188,7 +188,7 @@ class SubModule(nn.Module):
|
||||
|
||||
class SubModule2(nn.Module):
|
||||
def __init__(self):
|
||||
super(SubModule2, self).__init__()
|
||||
super().__init__()
|
||||
self.a = 12
|
||||
self.b = 2
|
||||
|
||||
@ -199,7 +199,7 @@ class SubModule2(nn.Module):
|
||||
|
||||
class TestModule(nn.Module):
|
||||
def __init__(self):
|
||||
super(TestModule, self).__init__()
|
||||
super().__init__()
|
||||
self.sub1 = SubModule()
|
||||
self.sub2 = SubModule2()
|
||||
self.a = 3
|
||||
|
||||
Reference in New Issue
Block a user