[PyTorch] AOTI: Add aoti_torch_assign_tensors to ABI (#110909)

I need this to do a cheap and easy output copy in D50023678.

Differential Revision: [D50105080](https://our.internmc.facebook.com/intern/diff/D50105080/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/110909
Approved by: https://github.com/jansel, https://github.com/chenyang78, https://github.com/desertfire
ghstack dependencies: #110876, #110877
This commit is contained in:
Scott Wolchok 2023-10-12 16:48:24 -07:00 committed by PyTorch MergeBot
parent cff71c47dd
commit bf72a723ef
2 changed files with 16 additions and 0 deletions

View file

@ -190,6 +190,12 @@ aoti_torch_new_uninitialized_tensor(AtenTensorHandle* ret);
AOTI_TORCH_EXPORT AOTITorchError
aoti_torch_tensor_copy_(AtenTensorHandle src, AtenTensorHandle dst);
// Make the tensor referred to by dst an alias for the tensor referred
// to by src. The two tensors must still be deleted with
// aoti_torch_delete_tensor separately (or not) as before the call.
AOTI_TORCH_EXPORT AOTITorchError
aoti_torch_assign_tensors(AtenTensorHandle src, AtenTensorHandle dst);
AOTI_TORCH_EXPORT AOTITorchError aoti_torch_addmm_out(
AtenTensorHandle out,
AtenTensorHandle self,

View file

@ -297,6 +297,16 @@ AOTITorchError aoti_torch_tensor_copy_(
});
}
AOTITorchError aoti_torch_assign_tensors(
AtenTensorHandle src,
AtenTensorHandle dst) {
AOTI_TORCH_CONVERT_EXCEPTION_TO_ERROR_CODE({
at::Tensor* src_tensor = tensor_handle_to_tensor_pointer(src);
at::Tensor* dst_tensor = tensor_handle_to_tensor_pointer(dst);
*dst_tensor = *src_tensor;
});
}
// TODO: implement a more efficient version instead of calling into aten
AOTITorchError aoti_torch_addmm_out(
AtenTensorHandle out,