I tried to use torch.jit.save to save my PyTorch model as a jit checkpoint file. But I came across the following errors:
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_script.py", line 1429, in script
ret = _script_impl(
^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_script.py", line 1147, in _script_impl
return torch.jit._recursive.create_script_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 557, in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 630, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_script.py", line 650, in _construct
init_fn(script_module)
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 606, in init_fn
scripted = create_script_module_impl(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 630, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_script.py", line 650, in _construct
init_fn(script_module)
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 606, in init_fn
scripted = create_script_module_impl(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 630, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_script.py", line 650, in _construct
init_fn(script_module)
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 606, in init_fn
scripted = create_script_module_impl(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 634, in create_script_module_impl
create_methods_and_properties_from_stubs(
File "/opt/homebrew/lib/python3.11/site-packages/torch/jit/_recursive.py", line 466, in create_methods_and_properties_from_stubs
concrete_type._create_methods_and_properties(
RuntimeError:
pad(Tensor input, int[] pad, str mode="constant", float? value=None) -> Tensor:
Expected a value of type 'Optional[float]' for argument 'value' but instead found type 'int'.
:
File "/opt/homebrew/lib/python3.11/site-packages/torch/nn/modules/padding.py", line 215
return F.pad(input, self.padding, "constant", self.value)
~~~~~ <--- HERE
This error is related to pad operation inside torch/nn/modules/padding.py. Could someone provide some guidance how to get around this error?