PyTorch HandlingΒΆ
In addition to JIT Compiling, CharonLoad also provides native support for finding and linking against the PyTorch C++ library which is installed as part of the Python package torch
. To this end, the CMake function charonload_add_torch_library
is provided as a thin wrapper around add_library().
However, the PyTorch C++ API comes with several non-trivial usage requirements that linking libraries must fulfill. Not meeting these requirements will lead to potentially obscure and hard-to-debug compiler and linker errors. Thus, CharonLoad automatically detects these usage requirements and adds them to the CMake target created by charonload_add_torch_library
.
In particular, the following PyTorch properties are handled:
C++ Standard
Set minimum C++ standard for using PyTorch.
C++11 ABI
Set correct C++11 ABI for linking.
Position-Independent Code (PIC)
Set required PIC flag for linking.
CUDA Flags
Set required CUDA flags for parents and siblings.