Unverified Commit 140263a3 authored by LuGY's avatar LuGY Committed by GitHub
Browse files

[hotfix]fixed bugs of assigning grad states to non leaf nodes (#711)

* fixed bugs of assigning grad states to non leaf nodes

* use detach()
parent eda30a05
......@@ -12,7 +12,7 @@ def copy_to_device(obj, device):
if torch.is_tensor(obj):
# Notice:
# When in no_grad context, requires_gard is False after movement
ret = obj.to(device)
ret = obj.to(device).detach()
ret.requires_grad = obj.requires_grad
return ret
elif isinstance(obj, list):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment