"examples/tutorial/vscode:/vscode.git/clone" did not exist on "abf4c27f6adc4b65914744a23ba23c4e60b2a722"
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): ...@@ -12,7 +12,7 @@ def copy_to_device(obj, device):
if torch.is_tensor(obj): if torch.is_tensor(obj):
# Notice: # Notice:
# When in no_grad context, requires_gard is False after movement # 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 ret.requires_grad = obj.requires_grad
return ret return ret
elif isinstance(obj, list): 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