Describe the bug
When I convert (with coremltools framework) a scripted model which used a torch.nn.functional.upsample_bilinear() in forward() function, I get RuntimeError: PyTorch convert function for op 'uninitialized' not implemented.
?: What should I do to resolve this error? Please help.
Trace
% python3 pytorch_sandbox.py
Converting Frontend ==> MIL Ops: 47%|██▎ | 20/43 [00:00<00:00, 25123.11 ops/s]
Traceback (most recent call last):
File "pytorch_sandbox.py", line 22, in <module>
coreml_model = ct.convert(
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/_converters_entry.py", line 326, in convert
mlmodel = mil_convert(
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 182, in mil_convert
return _mil_convert(model, convert_from, convert_to, ConverterRegistry, MLModel, compute_units, **kwargs)
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 209, in _mil_convert
proto, mil_program = mil_convert_to_proto(
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 300, in mil_convert_to_proto
prog = frontend_converter(model, **kwargs)
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 104, in __call__
return load(*args, **kwargs)
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 50, in load
return _perform_torch_convert(converter, debug)
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 95, in _perform_torch_convert
raise e
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 87, in _perform_torch_convert
prog = converter.convert()
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/converter.py", line 240, in convert
convert_nodes(self.context, self.graph)
File "/Users/user/Projects/project/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 74, in convert_nodes
raise RuntimeError(
RuntimeError: PyTorch convert function for op 'uninitialized' not implemented.
To Reproduce
import torch
import torch.nn as nn
import torch.nn.functional as F
import coremltools as ct
class M(nn.Module):
def __init__(self):
super(M, self).__init__()
def forward(self, x):
return F.upsample_bilinear(x, size=512)
m = M()
scripted_m = torch.jit.script(m)
example_input = torch.rand(1, 1, 64, 64)
image_input = ct.ImageType(name="input_1", shape=example_input.shape)
coreml_model = ct.convert(
scripted_m,
source='pytorch',
inputs=[image_input]
)
System environment (please complete the following information):
coremltools version: 5.1.0
OS: MacOS
macOS version: 12.1
XCode version : 13.1
How you install python: system + venv
python version: 3.8.10
any other relevant information:
torch version: 1.9.0
torchvision version: 0.10.0