Skip to content

Commit 227fb01

Browse files
BoyuanFengfacebook-github-bot
authored andcommitted
fix anti-pattern for cudagraph (#2619)
Summary: Previously, `self.create_grids((nx, ny), p.device)` is run sometimes, leading to cudagraph error "accessing tensor output of CUDAGraphs that has been overwritten by a subsequent run". This pr fixes the anti-pattern to always run `create_grids`. Pull Request resolved: #2619 Reviewed By: ydwu4 Differential Revision: D75250139 Pulled By: BoyuanFeng fbshipit-source-id: 7aa4e5c16031f5e85b8493f9ee0e2e25f7af8ca8
1 parent 1b4c319 commit 227fb01

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

torchbenchmark/models/yolov3/yolo_models.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ def forward(self, p, out):
210210
i, n = self.index, self.nl # index in layers, number of layers
211211
p = out[self.layers[i]]
212212
bs, _, ny, nx = p.shape # bs, 255, 13, 13
213-
if (self.nx, self.ny) != (nx, ny):
214-
self.create_grids((nx, ny), p.device)
213+
self.create_grids((nx, ny), p.device)
215214

216215
# outputs and weights
217216
# w = F.softmax(p[:, -n:], 1) # normalized weights
@@ -233,8 +232,7 @@ def forward(self, p, out):
233232
bs = 1 # batch size
234233
else:
235234
bs, _, ny, nx = p.shape # bs, 255, 13, 13
236-
if (self.nx, self.ny) != (nx, ny):
237-
self.create_grids((nx, ny), p.device)
235+
self.create_grids((nx, ny), p.device)
238236

239237
# p.view(bs, 255, 13, 13) -- > (bs, 3, 13, 13, 85) # (bs, anchors, grid, grid, classes + xywh)
240238
p = (

0 commit comments

Comments
 (0)