I have managed to interface MEX and PyTorch using CMake. But, I am facing problems when I try to run module.forward(…) function. Matlab basically hangs when I run “forward” function. I may be able to help with CMake if you are still interested in that.