What's the deal with shallow_copy_and_detach?

Hi, I had implemented a new kind of TensorImpl in a separate pytorch branch. Previously, in order to override detach() I override shallow_copy_and_detach(). Now I rebased and it doesnt work (calling detach complain that no implementation are found). I also did a grep -r “shallow_copy_and_detach()”, and seems like it is used very sparingly. I also dont think detach() call it anymore. Is it getting deprecated? Should I just do m.impl(“detac”, …)?


Yes detach() is now a native function like all the others: pytorch/native_functions.yaml at 79832f3d7748e064653042baf842798af6a6e849 · pytorch/pytorch · GitHub
So you can define m.impl() for it if you need to overwrite it.

1 Like