apple / apple/coremltools

RuntimeError: PyTorch convert function for op 'bernoulli_' not implemented

Open
#1,550 3 comments 0 reactions 0 assignees View on GitHub
missing layer type PyTorch (traced) triaged
Dominant language
Python
Stars
5.4k
Forks
850
Avg merge
4d 5h
Merged PRs (30d)
10

Description

- Name of layer type: bernoulli_
- Is this a PyTorch or a TensorFlow layer type: PyTorch
- Your version of coremltools: 6.0b1
- Your version of PyTorch/TensorFlow: PyTorch 1.11.0
- Impact of supporting this layer type. Why is adding support for this layer type important? Is it necessary to support a popular model or use case?

I am trying to convert EfficientNet-B0 model into .mlmodel and I have got the following issue.

`
model = ct.convert(traced_model,
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/_converters_entry.py", line 426, in convert
mlmodel = mil_convert(
File "/.../anaconda3/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 "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 209, in _mil_convert
proto, mil_program = mil_convert_to_proto(
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 272, in mil_convert_to_proto
prog = frontend_converter(model, **kwargs)
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/converter.py", line 104, in __call__
return load(*args, **kwargs)
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 52, in load
return _perform_torch_convert(converter, debug)
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 99, in _perform_torch_convert
raise e
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/load.py", line 91, in _perform_torch_convert
prog = converter.convert()
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/converter.py", line 263, in convert
convert_nodes(self.context, self.graph)
File "/.../anaconda3/lib/python3.8/site-packages/coremltools/converters/mil/frontend/torch/ops.py", line 86, in convert_nodes
raise RuntimeError(
RuntimeError: PyTorch convert function for op 'bernoulli_' not implemented.
`

Contributor guide

Open the contributing guide

Research direction

Start in coremltools/converters/mil/frontend/torch/ops.py, where the reported RuntimeError is raised for the bernoulli_ operation. Reproduce the EfficientNet-B0 conversion with the versions in the report and trace the PyTorch conversion path. Done means the conversion no longer fails on bernoulli_ and produces the requested .mlmodel.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.