AttributeError during conversion with flexible shape
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 850
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 10
Description
## 🐞Describing the bug
I get the `AttributeError: 'list' object has no attribute 'val'` error when I am converting a model with flexible shape.
## To Reproduce
- Please add a minimal code example that can reproduce the error when running it.
```
import torch.hub
import torchaudio
from denoiser import pretrained
from denoiser.dsp import convert_audio
import coremltools as ct
def get_input(path):
example, sr = torchaudio.load(path)
wav = convert_audio(example, sr, model.sample_rate, model.chin)
return wav[None]
model = pretrained.master64()
model.eval()
wav = get_input('data/p287_001.wav')
trace = torch.jit.trace(model, wav)
print(wav.shape)
shape = (1, 1, ct.RangeDim(lower_bound=1, upper_bound=5000, default=1600))
print(shape)
mod = ct.convert(
trace,
convert_to='mlprogram',
inputs=[ct.TensorType(shape=shape)],
outputs=[ct.TensorType()]
)
mod.save("denoiser.mlpackage")
```
## System environment (please complete the following information):
- coremltools version: 7.1
- OS (e.g. MacOS version or Linux type):
- Any other relevant version information (e.g. PyTorch or TensorFlow version): torch 2.1.0
## Additional context
- Add anything else about the problem here that you want to share.
Contributor guide
Research direction
Start by running the provided conversion example with coremltools 7.1 and torch 2.1.0, focusing on the flexible ct.RangeDim input shape. Trace the conversion path that handles flexible shapes and the reported list.val access; done means the model converts successfully and saves denoiser.mlpackage.
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