Options for mobile inference

How can optimize a PyTorch model so I can run it on Android, without needing to convert the model to TorchScript?

For now there aren’t all that many options, you can convert your model to torchscript, ONNX or tflite. But regardless of what you pick there will be some conversion process because phones don’t typically support python natively (iOS certainly doesn’t but perhaps with some workarounds it’s possible to do this in android)

There is a solid option now with ExecuTorch GitHub - pytorch/executorch: On-device AI across mobile, embedded and edge for PyTorch Join our discord channel at
PyTorch Edge where the team hangs out and can answer questions. We discuss a lot of the plans openly there.

Running PyTorch models on Android without conversion is tricky since phones don’t natively support Python. Most approaches, TorchScript, ONNX, and TFLite, involve some conversion.

A newer option is ExecuTorch (GitHub - pytorch/executorch: On-device AI across mobile, embedded and edge for PyTorch), which supports on-device inference with a subset of PyTorch. You can also join the PyTorch Edge Discord for more info.