How to load custom TorchScript ops in PyTorch Mobile?

Is there any tutorials or examples about loading custom TorchScript ops in PyTorch Mobile

@David_Reiss @IvanKobzarev Could I load custom TorchScript ops in PyTorch Mobile?

what are the custom ops you are trying to script? If the model is scriptable you shouldnt need to do anything else (unless I am missing something).

If you create a library (.so) that features your custom op registration as a static variable and link that into your app, it’ll work. That’s how I did it back in 2018 and it should still work.

Best regards

Thomas

2 Likes

Thomas is correct. Here’s a demo of using the C++ API directly, which should allow custom op registration: https://github.com/ljk53/pytorch-android-cpp-demo

I know the process is a bit cumbersome. We’re looking at simplifying this over time.

3 Likes