Make this work with LibTorch 2.12 - #2
Conversation
This now successfully runs on LibTorch 2.12, producing a bindings file that compiles. I haven't built the adapter yet. Besides fixing some Claw bugs, I did the following: - arranged to use a binary LibTorch distribution, so you don't have to build PyTorch from source - created a patch for one LibTorch header file that was tickling a couple of Claw bugs, to work around them - tweaked the 'defwrapper' form to include names in 'torch::nn::' - added directions to the README
|
Ha ha, the joke was on me: getting the bindings file to compile was the easy part; the adapter was much harder. For starters, I had to make some changes to its The big problem was with inherited constructors. Example: Here Once that was done, there were just a few minor bugs in the adapter generation that I had to fix, and it built! 🚀 Then I had to get the shared library to load. That wasn't quite trivial either. The first problem was that Claw uses the Clang headers if available (see After that:
For the moment, I have hand-edited these out of the adapter and bindings files. I guess I'll patch the headers again to get rid of them. And with that — it loads!!! 🚀 🚀 🚀 Whew! Now let me try calling some functions... |
e368078 to
2c508b9
Compare
2c508b9 to
5154722
Compare
|
I have extended Claw to handle inherited constructors automatically. So the patch ( I think this is now done, or nearly so. The only thing remaining, AFAIK, is to prune the set of names for which bindings are generated; the bindings file is ~5MB and the adapter ~3.7MB, and it's reasonable to assume there's stuff in here we won't actually need, but I'm not inclined to worry about that now. Of course, it's also possible we'll find names that need to be added to the binding set. @borodust I am very grateful to you for your work on Claw, which made this progress possible. I did have to make some improvements; LibTorch is a large and complex library that uses some of the gnarlier features of C++ — it seems like a pretty stringent test case for Claw. I think I've contributed significant value in getting it working, and in preparing clean PRs for your perusal.
|
90cb717 to
01538eb
Compare
This now successfully runs on LibTorch 2.12, producing a bindings file that compiles. I haven't built the adapter yet. Besides fixing some Claw bugs, I did the following:
defwrapperform to include names intorch::nn::I'm opening this PR so you can see what I've been doing, but it isn't ready to merge yet. In fact — what's your feeling about this project? Do you want to keep control of it, or are you happy to let me take it over? If the latter, we can just consider my fork to be the official repo. Do you mind if I rename it to CL-Torch?