Open hovhanns opened 4 years ago
Thanks @hovhanns for creating this issue. Using your code I can reproduce this issue.
This is related to #1085. The error message is actually coming from a PyTorch binary. The user who created #1085 in the coremltools repository also created pytorch/pytorch#52889 in the PyTorch repository for the same issue.
@TobyRoseman seems we have some workaround here, please see the comment here. pytorch/pytorch/#41674
@hovhanns the workaround says to rewrite your model architecture — which is not really a workaround. How can we help address this issue?
🐞Describe the bug
Trying to convert PyTorch FasterRCNN model to CoreML, but getting runtime error
temporary: the only valid use of a module is looking up an attribute but found = prim::SetAttr[name="_has_warned"](%self, %6)
Trace
Traceback (most recent call last): File "/home/harut/Projects/Python/venvs/main.py", line 20, in
main()
File "/home/harut/Projects/Python/venvs/main.py", line 13, in main
mlmodel = coremltools.converters.convert(
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/_converters_entry.py", line 292, in convert
proto_spec = _convert(
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 120, in _convert
prog = frontend_converter(model, *kwargs)
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 62, in call
return load(args, **kwargs)
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 73, in load
converter = TorchConverter(torchscript, inputs, outputs, cut_at_symbols)
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/converter.py", line 140, in init
raw_graph, params_dict = self._expand_and_optimize_ir(self.torchscript)
File "/home/harut/Projects/Python/venvs/venv/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/converter.py", line 328, in _expand_and_optimize_ir
graph, params = _torch._C._jit_pass_lower_graph(
RuntimeError:
temporary: the only valid use of a module is looking up an attribute but found = prim::SetAttr[name="_has_warned"](%self, %6)
:
To Reproduce
System environment (please complete the following information):