You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I face an issue while trying to add backward hooks to a model that includes a BiFPN (to generate some gradient plots). I get the following error when calling the forward of my BiFpn object:
[...]
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/effdet/efficientdet.py", line 460, in forward
x = self.cell(x)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/effdet/efficientdet.py", line 38, in forward
x = module(x)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/effdet/efficientdet.py", line 393, in forward
x.append(fn(x))
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/effdet/efficientdet.py", line 325, in forward
return self.after_combine(self.combine(x))
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/container.py", line 217, in forward
input = module(input)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/modules/activation.py", line 235, in forward
return F.hardtanh(input, self.min_val, self.max_val, self.inplace)
File "/home/mdeloche/.venv/main/lib/python3.10/site-packages/torch/nn/functional.py", line 1506, in hardtanh
result = torch._C._nn.hardtanh_(input, min_val, max_val)
RuntimeError: Output 0 of BackwardHookFunctionBackward is a view and is being modified inplace.
This view was created inside a custom Function (or because an input was returned as-is) and the autograd
logic to handle view+inplace would override the custom backward associated with the custom Function,
leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.
Is it for performance that these operations are created in place? Does someone see a fix for that issue, besides creating these activations with inplace=False?
Thanks in advance 👍
The text was updated successfully, but these errors were encountered:
Sory for the very slow response, could modify the model after creating
def clear_inplace(module):
res = module
if hasattr(module, 'inplace'):
module.inplace = False
else:
for name, child in module.named_children():
new_child = clear_inplace(child)
return res
```
Hi,
I face an issue while trying to add backward hooks to a model that includes a BiFPN (to generate some gradient plots). I get the following error when calling the forward of my
BiFpn
object:Here's a sample that reproduces the error:
I tracked it down to the following line, where the
torch.nn.ReLU6
is created withinplace=True
. Switching that toFalse
fixes the error.efficientdet-pytorch/effdet/efficientdet.py
Line 381 in d43c9e3
Is it for performance that these operations are created in place? Does someone see a fix for that issue, besides creating these activations with
inplace=False
?Thanks in advance 👍
The text was updated successfully, but these errors were encountered: