Optimize PyTorch 1.11.0 compatibility update (#6933)

This commit is contained in:
Glenn Jocher 2022-03-10 12:58:41 +01:00 committed by GitHub
parent d3d9cbce22
commit 055e72af5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -106,10 +106,10 @@ def attempt_load(weights, map_location=None, inplace=True, fuse=True):
if not isinstance(m.anchor_grid, list): # new Detect Layer compatibility
delattr(m, 'anchor_grid')
setattr(m, 'anchor_grid', [torch.zeros(1)] * m.nl)
elif t is nn.Upsample:
m.recompute_scale_factor = None # torch 1.11.0 compatibility
elif t is Conv:
m._non_persistent_buffers_set = set() # torch 1.6.0 compatibility
elif t is nn.Upsample and not hasattr(m, 'recompute_scale_factor'):
m.recompute_scale_factor = None # torch 1.11.0 compatibility
if len(model) == 1:
return model[-1] # return model