I met below error when doing torch.jit.script(model) on Pop!_OS with python3.8. It’s using torch 1.6.0.
The same code worked on CentOS with python3.6. But Pop!_OS with python3.8 is where I need to run the code. Looking forward for any inputs.
Traceback (most recent call last):
File "/envs/lib/python3.8/site-packages/torch/jit/__init__.py", line 1516, in script
return torch.jit._recursive.create_script_module(obj, torch.jit._recursive.infer_methods_to_compile)
File "/envs/lib/python3.8/site-packages/torch/jit/_recursive.py", line 318, in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
File "/envs/lib/python3.8/site-packages/torch/jit/_recursive.py", line 376, in create_script_module_impl
create_methods_from_stubs(concrete_type, stubs)
File "/envs/lib/python3.8/site-packages/torch/jit/_recursive.py", line 292, in create_methods_from_stubs
concrete_type._create_methods(defs, rcbs, defaults)
RuntimeError:
Function was not annotated as having type None, but does not return along all paths:
File "/scripts/nn_models.py", line 47
def forward(self, x: Tensor, hidden: Tuple[(Tensor, Tensor)]) -> Tuple[(Tensor, Tuple[(Tensor, Tensor)])]:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~... <--- HERE
"""Neural net forward pass. It is automatically called when use instance of LSTMnet.```