Yeah, looking at TORCH_API I realised  it couldn’t be used with a header only function  as it controls import/export which is not appropriate there. I gather there’s no equivalent marking for header only functions. Though yes, using private functions would be indicative of not being intended to be public. I guess underlying this is me not really being sure about the include folder in the conda package (which seems to mirror the include folder in libtorch). For torch includes this looks to come from
torch/csrc/api/include/torch 2 but I’m not sure how the Aten and c10 stuff gets in here. My initial expectation everything in these includes was intended to be public seems wrong. I gather this might also be due to some things that were designed for internal use being now made public as libtorch and the C++ interface is developed.
Investigating the private function it looks like it’s use may be a legacy from when this was adapted from THC code. Following subsequent changes in ATen I think it can now be safely replaced with the standard Tensor::copy_. I think this is the only location this function is used in ATen so this would allow removal of the ATen wrapper which I gather would be desirable in the ongoing work to remove THC dependencies. The function is also a slightly nasty hack (as noted in code comments) and so nice to be able to avoid.
Just need to confirm this a little more and I’ll submit an issue. This seems a stronger reason for removing it than allowing public use which while nice is likely not the primary concern of PyTorch devs. So hopefully a win/win.
Thanks again, and also thanks for your wonderful articles. The one on autograd functions and JIT operators in C++ in particular has been especially helpful in starting to get a handle on how they fit together which was previously eluding me.