Detach vs "manual" detach

Is there any difference between v.detach() and Variable(v.data)?

edit: Maybe detach() preserves some flags and attributes.

detach is safer as it uses the same version counter as the original tensor. Version counter is a mechanism that helps tracking if some tensor that is needed in backward has been modified inplace.

1 Like