Skip to content

Commit 9b771a3

Browse files
authored
Revert "Update detect.py non-inplace with y.tensor_split() (#7062)" (#7074)
This reverts commit d5e363f.
1 parent 9cd89b7 commit 9b771a3

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

models/yolo.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ def forward(self, x):
6262
y[..., 0:2] = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy
6363
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
6464
else: # for YOLOv5 on AWS Inferentia https://github.com/ultralytics/yolov5/pull/2953
65-
xy, wh, conf = y.tensor_split((2, 4), 4)
66-
xy = (xy * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy
67-
wh = (wh * 2) ** 2 * self.anchor_grid[i] # wh
68-
y = torch.cat((xy, wh, conf), 4)
65+
xy = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy
66+
wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
67+
y = torch.cat((xy, wh, y[..., 4:]), -1)
6968
z.append(y.view(bs, -1, self.no))
7069

7170
return x if self.training else (torch.cat(z, 1), x)

0 commit comments

Comments
 (0)