Recently I worked a lot with mobile deployment of PyTorch models and figured out that having debugged TorchScript model on PC sometimes isn’t enough to run it without errors on Android.
The main question is how to debug mobile model? At least print Tensor shapes during runtime. As I noticed Python print statements won’t produce outputs on mobile
Excuse me for direct mention. Would you mind to clarify it @IvanKobzarev?
Helo @zetyquickly
Yes, python “print” does not show up in logcat, (I even tried it with adb shell setprop log.redirect-stdio true on emulator)
By this moment our understanding is that model is debugged using python and we only run debugged model on mobile.
But we will think how we can expose print and maybe something else to logcat.
Just update about torchscript print and logcat: adb shell setprop log.redirect-stdio redirects only java System.out
torchscript print by default uses native stdout.
If you desperately need this print in android logcat, you may use this patch:
If you build pytorch-android with this patch (gradle -p android assembleDebug and use result aar files directly ) after calling PyTorchAndroid.nativeStdOutErrToLogcat() you will see torchscript print in logcat.
But we are not going to merge this :), we think about custom handling of print on mobile and print it to logcat. But doing it might take some time.
BTW to call PyTorchAndroid.nativeStdOutErrToLogcat() should one import this function from some module, or PyTorchAndroid already is an upper level module?