# What's the deal with shallow\_copy\_and\_detach?

**URL:** <https://dev-discuss.pytorch.org/t/whats-the-deal-with-shallow-copy-and-detach/134>\
**Category:** frontend API\
**Created:** [February 6, 2021, 9:53pm UTC](https://dev-discuss.pytorch.org/t/whats-the-deal-with-shallow-copy-and-detach/134 "2021-02-06T21:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarisaKirisame](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/marisakirisame/32/106_2.png) [@MarisaKirisame](https://dev-discuss.pytorch.org/u/MarisaKirisame)\
**Post date:** [February 6, 2021, 9:53pm UTC](https://dev-discuss.pytorch.org/t/whats-the-deal-with-shallow-copy-and-detach/134/1 "2021-02-06T21:53:57Z")

</div>

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”, …)?

---

<div class="post-metadata">

**Author:** ![albanD](https://yyz2.discourse-cdn.com/flex036/user_avatar/dev-discuss.pytorch.org/alband/32/9_2.png) [@albanD](https://dev-discuss.pytorch.org/u/albanD)\
**Post date:** [February 8, 2021, 2:53pm UTC](https://dev-discuss.pytorch.org/t/whats-the-deal-with-shallow-copy-and-detach/134/2 "2021-02-08T14:53:47Z")

</div>

Hi,

Yes `detach()` is now a native function like all the others: [pytorch/native\_functions.yaml at 79832f3d7748e064653042baf842798af6a6e849 · pytorch/pytorch · GitHub](https://github.com/pytorch/pytorch/blob/79832f3d7748e064653042baf842798af6a6e849/aten/src/ATen/native/native_functions.yaml#L3452)  
So you can define `m.impl()` for it if you need to overwrite it.
