1. What are you using the PyTorch C++ API for?
I’m writing an interface for the q/kdb interpreter to/from pytorch
There is already an interface to python, but I’m aiming to use only a shared library built on top of libtorch.
2. How does your software stack look like? And how does the PyTorch C++ API interact with other components in your stack?
q interpreter (executable size is around 655k) + ktorch.so (around 4mb) + libraries from libtorch
interaction is through a c-api from the interpreter.
3. Are you using JIT (TorchScript) models or
No plans for using jit/torchscript
4. Are you training models in C++?
Yes, the model is phrased in the k/q interpreter, along with the optimizer & loss function.
(these are all pointers back and forth from interpreter <—> c-api <—> torch,torch::nn objects
5. How do you think the PyTorch C++ API (or the ecosystem in general) should be improved?
It was tricky to sort out the best way to deal with c++ smart pointers through a c-api interface.
It would be useful if there were some guidelines on how to use libtorch via a c-api.
I ended up writing all the modules that are available in python in c++ so that I could use
them with torch::nn::Sequential, all the various pool & padding layers, non-linear activations, etc.
Most of these could be implemented with torch::nn::Functional, but I couldn’t figure out how to
query a Functional layer to get the various options/control parameters back from a realized Sequential model in memory.
(the interface is written so that any module/loss fn/optimizer in cpu/gpu memory can be retrieved in database tables)
I also built Loss objects to match those available in python in torch.nn.
I haven’t been able how to make much use of the DataLoader/Dataset c++ setup yet,
but that may be because my outer data loop starts outside of c++ in the q/kdb interpreter.
Thank you to goldsborough, yf225 and everybody for the c++ set up so far…