Optimize PyTorch 1.11.0 compatibility update (#6933)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-03-10 12:58:41 +01:00
1 parent d3d9cbce22
commit 055e72af5b
1 file changed
+2 -2
+2 -2
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