Skip to content

AttributeError during conversion with flexible shape #2159

@marius-verdier

Description

@marius-verdier

🐞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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected behaviour that should be corrected (type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions