glenn-jocher
commited on
Commit
•
055e72a
1
Parent(s):
d3d9cbc
Optimize PyTorch 1.11.0 compatibility update (#6933)
Browse files- models/experimental.py +2 -2
models/experimental.py
CHANGED
@@ -106,10 +106,10 @@ def attempt_load(weights, map_location=None, inplace=True, fuse=True):
|
|
106 |
if not isinstance(m.anchor_grid, list): # new Detect Layer compatibility
|
107 |
delattr(m, 'anchor_grid')
|
108 |
setattr(m, 'anchor_grid', [torch.zeros(1)] * m.nl)
|
109 |
-
elif t is nn.Upsample:
|
110 |
-
m.recompute_scale_factor = None # torch 1.11.0 compatibility
|
111 |
elif t is Conv:
|
112 |
m._non_persistent_buffers_set = set() # torch 1.6.0 compatibility
|
|
|
|
|
113 |
|
114 |
if len(model) == 1:
|
115 |
return model[-1] # return model
|
|
|
106 |
if not isinstance(m.anchor_grid, list): # new Detect Layer compatibility
|
107 |
delattr(m, 'anchor_grid')
|
108 |
setattr(m, 'anchor_grid', [torch.zeros(1)] * m.nl)
|
|
|
|
|
109 |
elif t is Conv:
|
110 |
m._non_persistent_buffers_set = set() # torch 1.6.0 compatibility
|
111 |
+
elif t is nn.Upsample and not hasattr(m, 'recompute_scale_factor'):
|
112 |
+
m.recompute_scale_factor = None # torch 1.11.0 compatibility
|
113 |
|
114 |
if len(model) == 1:
|
115 |
return model[-1] # return model
|