Hello,
I am getting an error when running my transformer with pytorch_mobile_lite.
Here’s minimal code to get the error:
class TestModel(pl.LightningModule):
    def __init__(self, ):
        super(TestModel, self).__init__()
        self.model = TransformerEncoderLayer(128, 2, 512)

    def forward(self, src)->torch.Tensor:
        src_real = torch.randn(1, 80, 128)
        rtn = self.model(src_real)
        return rtn

model = TestModel()
s = script(model)
m = optimize_for_mobile(s)
m._save_for_lite_interpreter("model.ptl")`

After the torchscript is generated, replace the model of the HelloWorldExample. Running the generated apk, I’ll get the following error from adb:

--------- beginning of crash

2021-10-21 01:03:32.470 12338-12338/org.pytorch.helloworld E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pytorch.helloworld, PID: 12338
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: Following ops cannot be found. Check fburl.com/missing_ops for the fix.{aten::sqrt.int, } ()
Exception raised from print_unsupported_ops_and_throw at …/torch/csrc/jit/mobile/import.cpp:206 (most recent call first):
(no backtrace available)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3639)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3796)

I am running 1.9.0+cu111 with org.pytorch:pytorch_android_lite:1.9.0
Thank you.