Skip to content

[ONNX] Missing support opset 17 operators #80834

@stonelazy

Description

@stonelazy

See

for progress


🐛 Describe the bug

Facing unsupported Opset Version error when exporting a torch module to ONNX. This is an expected error since torch doesn't support the latest opset released by ONNX a couple of weeks before.

import torch

class FeaturizeTorchFFT(torch.nn.Module):

    def __init__(self):
        super().__init__()

    def forward(self, x):
        return torch.stft(
            input=x,
            n_fft=320,
            hop_length=160,
            win_length=320,
            window=torch.ones(320),
            center=False,
            pad_mode="reflect",
            normalized=False,
            onesided=True,
        )

    def export(self):
        with torch.no_grad():
            feature_inp = torch.arange(0, 1000).reshape(1, -1).float()
            output = self.forward(feature_inp)
            print('output shape ',output.shape)

        torch.onnx.export(
            self,  # model being run
            feature_inp,  # model input (or a tuple for multiple inputs)
            str('fft.onnx'),
            export_params=True,
            opset_version=17,
            do_constant_folding=True,
            input_names=["x"],
            output_names=["output"],
            dynamic_axes={
                "x": {0: "batch_size", 1: "audio_length"},
            },
        )

if __name__ == '__main__':
    converter = FeaturizeTorchFFT()
    converter.export()

Facing the below error:

  File "/home/kp/miniconda3/envs/gamd6-kp2/lib/python3.8/site-packages/torch/onnx/symbolic_helper.py", line 853, in _set_opset_version
    raise ValueError("Unsupported ONNX opset version: " + str(opset_version))
**ValueError: Unsupported ONNX opset version: 17**

According to Torch's documentation,

opset_version (int, default 13) – The version of the default (ai.onnx) opset to target. Must be >= 7 and <= 16.

Latest ai.onnx opset version is 17 Refer to ONNX release notes

My query:
When will the latest opset 17 be supported in torch so that we can export and make use of it ? Note - Very much essential Core signal processing operators needed for audio processing is added in opset 17 and hence its badly needed.
Are there any other workarounds to make this work so that we don't need to wait until torch supports it ?

Versions

Versions
pytorch-lightning 1.5.10
torch 1.11.0+cu115
torch-poly-lr-decay 0.0.1
torchaudio 0.11.0+cu115
torchmetrics 0.8.2
onnx 1.12.0
onnxruntime 1.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    OSS contribution wantedPR from open source contributors welcome to solve this issue.actionablemodule: onnxRelated to torch.onnxonnx-triagedtriaged by ONNX teamtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions