mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add a stable TORCH_LIBRARY to C shim (#148124)
This PR adds two main parts: - shim.h stable C APIs into torch::Library APIs - a higher level API in torch/csrc/stable/library.h that calls into this shim.h + otherwise is self contained Goal: custom kernel writers should be able to call the apis in the directories above in order to register their library in a way that allows their custom extension to run with a different libtorch version than it was built with. Subplots resolved: - Do we want a whole separate StableLibrary or do we want to freeze torch::Library and add `m.stable_impl(cstring, void (*fn)(void **, int64_t, int64_t)` into it - Yes, we want a separate StableLibrary. We cannot freeze Library and it is NOT header only. - Should I use unint64_t as the common denominator instead of void* to support 32bit architectures better? - Yes, and done - Should I add a stable `def` and `fragment` when those can be done in python? - I think we do want these --- and now they're done - Where should library_stable_impl.cpp live? -- no longer relevant - I need some solid test cases to make sure everything's going ok. I've intentionally thrown in a bunch of random dtypes into the signature, but I still haven't tested returning multiple things, returning nothing, complex dtypes, etc. - Have since tested all the torch library endpoints. the others can be tested in a followup to separate components that need to be in shim.h vs can be added later Pull Request resolved: https://github.com/pytorch/pytorch/pull/148124 Approved by: https://github.com/albanD, https://github.com/zou3519, https://github.com/atalman
This commit is contained in:
committed by
PyTorch MergeBot
parent
4d10da731b
commit
971606befa
1
setup.py
1
setup.py
@ -1274,6 +1274,7 @@ def main():
|
||||
"include/c10/xpu/impl/*.h",
|
||||
"include/torch/*.h",
|
||||
"include/torch/csrc/*.h",
|
||||
"include/torch/csrc/stable/*.h",
|
||||
"include/torch/csrc/api/include/torch/*.h",
|
||||
"include/torch/csrc/api/include/torch/data/*.h",
|
||||
"include/torch/csrc/api/include/torch/data/dataloader/*.h",
|
||||
|
Reference in New Issue
Block a user