Xcode got error "Error loading model: Following ops cannot be found: [aten::scaled_dot_product_attention]. Please check if the operator library is included in the build. If built with selected ops, check if these ops are in the list."

I’m trying to run ios-demo-app/SpeechRecognition at master · pytorch/ios-demo-app · GitHub and got errors in Xcode, my device: iphone 15 pro, iOS 18, Xcode 16.1, LibTorch-Lite 1.13.0.1. → “Error loading model: Following ops cannot be found: [aten::scaled_dot_product_attention]. Please check if the operator library is included in the build. If built with selected ops, check if these ops are in the list. If you are a Meta employee, please see Internal Login for a fix.” please help me!!

scaled_dot_product_attention was added in torch==2.0.0 so you would need to update your PyTorch version.

@Danny_Vu the code you’re looking at is the legacy solution offered by PyTorch to run models on edge devices using TorchScript. We have a newer framework called ExecuTorch that lets you run models based on phones. We support various transformer based models such as LLM’s. Take a look at Welcome to the ExecuTorch Documentation — ExecuTorch 0.4 documentation

Would recommend using this as you’ll get the best support for this currently and in the future. Let us know if you have any questions.

The error gone when I pip torch==2.0.0 and torchaudio==2.0.0. Thank you very much Mr Ptrblck.

Thanks Mr Tarun Karuturi