Optimize PyTorch 1.11.0 compatibility update (#6933)
This commit is contained in:
parent
d3d9cbce22
commit
055e72af5b
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue