Export with torch.export for Android

I produced an exported model with torch.export.
If I save it using torch.export.save can I use the model file for inference in my Android application?

Put another way what is the equivalent of
open("tfmodel.pte", "wb").write(.exir.capture().to_edge().to_executorch().buffer)
when using torch.export?


torch.export is the first step of lowering to ExecuTorch. The serialized file can only be loaded and executed by Python, which may not be suitable for Android app, where Python may not be available. Any reason you prefer to run exported graph directly from Android?

Hi Martin,

Thanks. I tried torch.export only as an experiment because
exit.capture is deprecated and I was told that eventually exir
will use torch.export.
In my Android app I am using a neural network to help predict the next
location a user will go to.
Python is not available on Android.
This is why I first used torchscript and pytorch mobile, which worked.
Now I am using executorch as I understand that executorch will be the
main vehicle for running pytorch modles o edge devices.


Got it. Then you could follow the example in this tutorial: Exporting to ExecuTorch Tutorial — ExecuTorch documentation

1 Like