mirror of
https://github.com/zebrajr/pytorch.git
synced 2026-01-15 12:15:51 +00:00
Pull Request resolved: https://github.com/pytorch/pytorch/pull/167772 Approved by: https://github.com/janeyx99
torch/headeronly
The inlined C++ headers in the torch::headeronly namespace living this subdirectory are completely decoupled from LibTorch. These APIs are also globally listed in torch/header_only_apis.txt.
There are two types of LibTorch independent header-only headers:
- OG header-only. Originally header-only APIs, such as
ScalarType,Half,BFloat16, have always been implemented in headers only. For them to move into torch/headeronly only required a code migration, a copy-pasta, if you will. - Made to be header-only. There are also APIs that were NOT header-only that we made to be header-only. One example of such an API is
STD_TORCH_CHECK, which was derived fromTORCH_CHECK.STD_TORCH_CHECKcalls intostd::runtime_errorinstead of relying onc10::Error, which relies on libtorch.so. As a result,STD_TORCH_CHECKdoes not have the fullTORCH_CHECKfunctionality that displays a fanciful traceback when the check is not met. We intentionally maintain the design that functions that do different things should be explicitly named differently.