Skip to content

Commit 4b6497c

Browse files
Updates #836 as suggested in pytorch/pytorch#16885 (comment)
1 parent 0bee138 commit 4b6497c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: beginner_source/former_torchies/parallelism_tutorial.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ def forward(self, x):
5151
# clashes in their names. For those who still want to access the attributes,
5252
# a workaround is to use a subclass of ``DataParallel`` as below.
5353

54-
class MyDataParallel(nn.DataParallel):
54+
class MyDataParallel(DataParallel):
5555
def __getattr__(self, name):
56-
return getattr(self.module, name)
56+
try:
57+
return super().__getattr__(name)
58+
except AttributeError:
59+
return getattr(self.module, name)
5760

5861
########################################################################
5962
# **Primitives on which DataParallel is implemented upon:**

0 commit comments

Comments
 (0)