Best practice for porting Pytorch model to C++

I have an audio-related usecase in mind that requires a model in C++ for use on desktop (Mac/Windows) and mobile.

I have both the Python code and the pretrained model weights.

I have started porting the code to use Torchscript, but through reading some posts on here, it seems like Torchscript is in maintenance mode? And no more features are going to be developed?

What’s the recommended way going forward to port a pytorch model to C++?

Don’t want to learn something that is outdated or going away soon.

Maybe that was too broad.

  1. What does “maintenance mode” mean at Pytorch? (for torchscript support)
  2. Is Pytorch deliberately trying to stay away from the C++ conversion functionality because it’s not their core competency? or is there another reason.

Whilst not being an answer to your question, this post is directly related: Pytorch 2 and the c++ interface - #6 by ezyang

Torchscript maintenance mode means there’s very little dev attention going to it, as in no new features, if critical bugs are found then they will probably be fixed. many torch.compile backends also leverage torchscript so it’s not going away anytime soon but won’t evolve all that much either

As of today you’re right there isn’t a good story for a conversion in environments where python is not available, eventually that’s supposed to be torch._dynamo.export() but that’s still in very early days