Swap `unsafe_chunk()` for `chunk()` (#7362)

Eliminates all unsafe function in YOLOv5 out of an abundance of caution.
This commit is contained in:
Glenn Jocher 2022-04-10 13:53:28 +02:00 committed by GitHub
parent 406ee528f0
commit 1993efd59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -220,7 +220,7 @@ class ComputeLoss:
offsets = 0 offsets = 0
# Define # Define
bc, gxy, gwh, a = t.unsafe_chunk(4, dim=1) # (image, class), grid xy, grid wh, anchors bc, gxy, gwh, a = t.chunk(4, 1) # (image, class), grid xy, grid wh, anchors
a, (b, c) = a.long().view(-1), bc.long().T # anchors, image, class a, (b, c) = a.long().view(-1), bc.long().T # anchors, image, class
gij = (gxy - offsets).long() gij = (gxy - offsets).long()
gi, gj = gij.T # grid indices gi, gj = gij.T # grid indices