Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError during conversion with flexible shape #2159

Open
marius-verdier opened this issue Feb 29, 2024 · 4 comments
Open

AttributeError during conversion with flexible shape #2159

marius-verdier opened this issue Feb 29, 2024 · 4 comments
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@marius-verdier
Copy link

🐞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.
@marius-verdier marius-verdier added the bug Unexpected behaviour that should be corrected (type) label Feb 29, 2024
@marius-verdier
Copy link
Author

I tried this PR #2050 but it did not work

@TobyRoseman
Copy link
Collaborator

@marius-verdier - in order to move forward here, we need a minimal self-containded example, one which doesn't require loading a model from an untrusted 3rd party (i.e. denoiser).

@marius-verdier
Copy link
Author

@TobyRoseman I understand, but I was not able to reproduce this bug with a self made model :(

@marius-verdier
Copy link
Author

marius-verdier commented Mar 4, 2024

@TobyRoseman But the denoiser source is here, maybe it could help :

https://github.com/facebookresearch/denoiser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

2 participants