Skip to content

Commit 89d2710

Browse files
committed
rm modification for inplace ops
1 parent af61403 commit 89d2710

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

thunder/benchmarks/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,18 +2841,7 @@ def make_batch(self) -> tuple[list, dict]:
28412841
def fn(self) -> Callable:
28422842
from thunder.tests.resnet import resnet50
28432843

2844-
# Thunder does not support inplace
2845-
def avoid_add_(m):
2846-
if isinstance(m, torch.nn.modules.batchnorm._BatchNorm):
2847-
m.num_batches_tracked = None
2848-
2849-
def avoid_relu_inplace(m):
2850-
if isinstance(m, torch.nn.modules.activation.ReLU):
2851-
m.inplace = False
2852-
28532844
model = resnet50()
2854-
model.apply(avoid_add_)
2855-
model.apply(avoid_relu_inplace)
28562845
model = model.to(device=self.device, dtype=self.tdtype).requires_grad_(self.requires_grad)
28572846
return model
28582847

thunder/tests/resnet.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def forward(self, x: Tensor) -> Tensor:
7676
if self.downsample is not None:
7777
identity = self.downsample(x)
7878

79-
# Thunder: Inplace operators like __iadd__ are not supported
80-
# out += identity
81-
out = out + identity
79+
out += identity
8280
out = self.relu(out)
8381

8482
return out
@@ -136,9 +134,7 @@ def forward(self, x: Tensor) -> Tensor:
136134
if self.downsample is not None:
137135
identity = self.downsample(x)
138136

139-
# Thunder: Inplace operators like __iadd__ are not supported
140-
# out += identity
141-
out = out + identity
137+
out += identity
142138
out = self.relu(out)
143139

144140
return out

0 commit comments

Comments
 (0)