C++ API with MEX compiler - Interfacing PyTorch and Matlab

(Lucas Müller) #1


for some scientific application I need to interface PyTorch and Matlab (only for inference).
I thought the best way would be not to mix the two interpreted languages (python and matlab) but rather load the trained models via the C++ API and interface this with the MATLAB C++ interface.
Does someone have experience with this already?

Since MATLAB uses MEX “compiler” which is some kind of wrapper around the OS default compiler (clang++ in my case) it’s kind of hard to use cmake for this and I get tons of linking errors and I wondered if someone could help or has already tried something like this.

Cheers :slight_smile:

(Liangbright) #2

The best way is to call Python within Matlab, and use data files for communication.