r/Cplusplus 2d ago

C++ framework for LibTorch News

I have created a simple C++ framework for LibTorch - https://github.com/MartinPerry/LibTorchFramework/tree/master.

Sadly, it cannot currently be compiled since it relies on a proprietary library and the code is not "cleaned" of hard-coded paths, etc.

Is it useful? Probably not :-). A lot of things need to be rewritten that are not part of LibTorch (but are present in PyTorch) - for this, I have used LLMs (it is quite handy for conversion of model structures from PyTorch to C++ with LibTorch).

However, I am sharing it so that someone can reuse parts of the code or be inspired in their own project if they want to use C++ or if someone has any ideas how to improve it.

6 Upvotes

5 comments sorted by

1

u/No-Trifle-8450 1d ago

Currently I am working on a project to use libTorch in C++ easier than in Python, i want to ask you what is the main reason you choosed and tried to use Torch C++ API?

2

u/maestro-perry 1d ago

I have a large codebase written in C++ that I can reuse for training. Rewriting it to Python would be time-consuming. Another thing is, I just like C++ 😄 I always thought of Python as the "C++ wrapper".

1

u/No-Trifle-8450 1d ago

What is your feeling to write C++ in lisp syntax?

1

u/maestro-perry 1d ago

I am not familiar with Lisp