Add C++ build support for use with LibTorch #819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1] Added a CMakeLists.txt file equivalent to setup.py for compiling in C++
2] Added a header file with export, so the linker in Visual C++ (on windows) will work.
3] Added a preprocessor directive when building in Python so the python headers and binding occur (I added it for the Python build since that requires adding the directive just in the setup.py, whereas for C++ would need to be added in every project that references the project).
I've tested out using the C++ compiled library both both for window & linux with CUDA 12.1 and LibTorch 2.1.0, and it works great! I also managed to build the python library with the adjusted code for windows.
Happy to make any changes, as you see fit.
If this PR is accepted, I'd be happy to add similar changes for the other sub-packages here (LayerNorm, FusedDense, etc.) .
Instructions for building it for C++: