Error when loading quantized Retinanet in android environment

Anouar_LAOUICHI: <p>I’m trying to deploy a quantized Retinanet in a simple android application, the quantization process is accomplished just fine and the accuracy managed to stay practically the same, after I convert the model to torchscript and try to load it in the android application, an exception occurs, the message states the following</p>
<pre><code class="lang-auto">com.facebook.jni.CppException: 
Arguments for call are not valid.
The following variants are available:
  
  aten::upsample_nearest2d(Tensor self, int[2] output_size) -&gt; (Tensor):
  Expected at most 2 arguments but found 4 positional arguments.
  
  aten::upsample_nearest2d.out(Tensor self, int[2] output_size, *, Tensor(a!) out) -&gt; (Tensor(a!)):
  Argument out not provided.

The original call is:
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\functional.py(2990): interpolate
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\upsampling.py(131): forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(534): _slow_forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(548): __call__
d:\github\pytorch-retinanet\retinanet\modelQ.py(64): forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(534): _slow_forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(548): __call__
d:\github\pytorch-retinanet\retinanet\modelQ.py(274): forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(534): _slow_forward
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\nn\modules\module.py(548): __call__
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\jit\__init__.py(1027): trace_module
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\torch\jit\__init__.py(873): trace
&lt;ipython-input-8-f99b9332c7b3&gt;(3): &lt;module&gt;
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\interactiveshell.py(3331): run_code
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\interactiveshell.py(3254): run_ast_nodes
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\interactiveshell.py(3062): run_cell_async
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\async_helpers.py(68): _pseudo_sync_runner
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\interactiveshell.py(2886): _run_cell
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\IPython\core\interactiveshell.py(2857): run_cell
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\zmqshell.py(536): run_cell
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\ipkernel.py(300): do_execute
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\gen.py(209): wrapper
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\kernelbase.py(539): execute_request
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\gen.py(209): wrapper
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\kernelbase.py(268): dispatch_shell
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\gen.py(209): wrapper
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\kernelbase.py(361): process_one
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\gen.py(748): run
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\gen.py(787): inner
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\ioloop.py(743): _run_callback
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\ioloop.py(690): &lt;lambda&gt;
C:\Users\anoua\anaconda3\envs\PFE_env\lib\asyncio\events.py(81): _run
C:\Users\anoua\anaconda3\envs\PFE_env\lib\asyncio\base_events.py(1859): _run_once
C:\Users\anoua\anaconda3\envs\PFE_env\lib\asyncio\base_events.py(570): run_forever
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\tornado\platform\asyncio.py(149): start
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel\kernelapp.py(583): start
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\traitlets\config\application.py(664): launch_instance
C:\Users\anoua\anaconda3\envs\PFE_env\lib\site-packages\ipykernel_launcher.py(16): &lt;module&gt;
C:\Users\anoua\anaconda3\envs\PFE_env\lib\runpy.py(86): _run_code
C:\Users\anoua\anaconda3\envs\PFE_env\lib\runpy.py(193): _run_module_as_main
Serialized   File "code/__torch__/torch/nn/modules/upsampling.py", line 14
    _6 = torch.mul(torch.to(_4, 6, False, False, None), torch.detach(_5))
    _7 = torch.floor(torch.to(_6, 6, False, False, None))
    x = torch.upsample_nearest2d(argument_1, [int(_3), int(_7)], None, None)
        ~~~~~~~~~~~~~~~~~~~~~~~~ &lt;--- HERE
    return x

</code></pre>
<p>at first I suspected quantisation as the culprit, but when I try to deploy the baseline model the same error pop up, did I do something wrong, i tried to follow the pytorch mobile tutorial as best as I can.  Some help with this would be much appreciated.</p>

ntreepoint: <p>I got the same issue.<br>
Using a newer version of Pytorch mobile has solved the issue.<br>
Here is what i included in build.gradle:</p>
<p>implementation ‘org.pytorch:pytorch_android:1.5.0’<br>
implementation ‘org.pytorch:pytorch_android_torchvision:1.5.0’</p>