8000 [ONNX] STFT doesn't support complex inputs · Issue #107677 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[ONNX] STFT doesn't support complex inputs #107677

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

Closed
WangHHY19931001 opened this issue Aug 22, 2023 · 13 comments
Closed

[ONNX] STFT doesn't support complex inputs #107677

WangHHY19931001 opened this issue Aug 22, 2023 · 13 comments
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@WangHHY19931001
Copy link
WangHHY19931001 commented Aug 22, 2023

🐛 Describe the bug

code:

import torch
from torch import nn
import torchaudio

class DataCov(nn.Module):
    def __init__(self):
        super(DataCov, self).__init__()

        self.transform = nn.Sequential(
            torchaudio.transforms.MelSpectrogram(sample_rate=48000, n_fft=1536, hop_length=768, f_min=20, f_max=20000)
        )

    def forward(self, x1):
        return self.transform(x1)


model = DataCov()
input = torch.rand((1, 1, 12 * 48000))
torch.onnx.export(model, (input), "DataCov.onnx", verbose=False,
                      input_names=['input1'], output_names=['output1'], opset_version=18)

error:

C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\_internal\jit_utils.py:307: UserWarning: Constant folding - Only steps=1 can be constant folded for opset >= 10 onnx::Slice op. Constant folding not applied. (Triggered internally at C:\cb\pytorch_1000000000000\work\torch\csrc\jit\passes\onnx\constant_fold.cpp:181.)
  _C._jit_pass_onnx_node_shape_type_inference(node, params_dict, opset_version)
Traceback (most recent call last):
  File "C:\work\pytorch_to_onnx\main.py", line 29, in <module>
    print_hi('PyCharm')
  File "C:\work\pytorch_to_onnx\main.py", line 24, in print_hi
    torch.onnx.export(model, (input), "DataCov.onnx", verbose=False,
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py", line 516, in export
    _export(
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py", line 1582, in _export
    graph, params_dict, torch_out = _model_to_graph(
                                    ^^^^^^^^^^^^^^^^
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py", line 1139, in _model_to_graph
    graph = _optimize_graph(
            ^^^^^^^^^^^^^^^^
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py", line 677, in _optimize_graph
    graph = _C._jit_pass_onnx(graph, operator_export_type)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py", line 1926, in _run_symbolic_function
    return symbolic_fn(graph_context, *inputs, **attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\symbolic_helper.py", line 306, in wrapper
    return fn(g, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\symbolic_opset17.py", line 105, in stft
    raise errors.SymbolicValueError(
torch.onnx.errors.SymbolicValueError: STFT does not currently support complex types  [Caused by the value '73 defined in (%73 : Float(*, *, strides=[577536, 1], requires_grad=0, device=cpu) = onnx::Reshape[allowzero=0](%63, %72), scope: __main__.DataCov::/torch.nn.modules.container.Sequential::transform/torchaudio.transforms._transforms.MelSpectrogram::transform.0/torchaudio.transforms._transforms.Spectrogram::spectrogram # C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\functional.py:649:0
)' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Reshape'.] 
    (node defined in C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\functional.py(649): stft
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torchaudio\functional\functional.py(126): spectrogram
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torchaudio\transforms\_transforms.py(110): forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1508): _slow_forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1527): _call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1518): _wrapped_call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torchaudio\transforms\_transforms.py(619): forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1508): _slow_forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1527): _call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1518): _wrapped_call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\container.py(217): forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1508): _slow_forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1527): _call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1518): _wrapped_call_impl
C:\work\pytorch_to_onnx\main.py(18): forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1508): _slow_forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1527): _call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1518): _wrapped_call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\jit\_trace.py(124): wrapper
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\jit\_trace.py(133): forward
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1527): _call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\nn\modules\module.py(1518): _wrapped_call_impl
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\jit\_trace.py(1287): _get_trace_graph
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py(915): _trace_and_get_graph_from_model
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py(1011): _create_jit_graph
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py(1135): _model_to_graph
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py(1582): _export
C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx\utils.py(516): export
C:\work\pytorch_to_onnx\main.py(24): print_hi
C:\work\pytorch_to_onnx\main.py(29): <module>
)

    Inputs:
        #0: 63 defined in (%63 : Float(*, *, *, strides=[577536, 577536, 1], requires_grad=0, device=cpu) = onnx::Pad[mode="reflect"](%35, %62), scope: __main__.DataCov::/torch.nn.modules.container.Sequential::transform/torchaudio.transforms._transforms.MelSpectrogram::transform.0/torchaudio.transforms._transforms.Spectrogram::spectrogram # C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\functional.py:648:0
    )  (type 'Tensor')
        #1: 72 defined in (%72 : int[] = prim::ListConstruct(%67, %71), scope: __main__.DataCov::/torch.nn.modules.container.Sequential::transform/torchaudio.transforms._transforms.MelSpectrogram::transform.0/torchaudio.transforms._transforms.Spectrogram::spectrogram
    )  (type 'List[int]')
    Outputs:
        #0: 73 defined in (%73 : Float(*, *, strides=[577536, 1], requires_grad=0, device=cpu) = onnx::Reshape[allowzero=0](%63, %72), scope: __main__.DataCov::/torch.nn.modules.container.Sequential::transform/torchaudio.transforms._transforms.MelSpectrogram::transform.0/torchaudio.transforms._transforms.Spectrogram::spectrogram # C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\functional.py:649:0
    )  (type 'Tensor')

Versions

Collecting environment information...
PyTorch version: 2.1.0.dev20230821
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 专业版
GCC version: (Rev5, Built by MSYS2 project) 13.1.0
Clang version: Could not collect
CMake version: version 3.26.4
Libc version: N/A

Python version: 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 17:59:51) [MSC v.1935 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19045-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:

Revision=

Versions of relevant libraries:
[pip3] numpy==1.25.2
[pip3] torch==2.1.0.dev20230821
[pip3] torchaudio==2.1.0.dev20230822
[pip3] torchvision==0.16.0.dev20230821
[conda] blas 2.106 mkl conda-forge
[conda] cpuonly 2.0 0 pytorch-nightly
[conda] libblas 3.9.0 6_mkl conda-forge
[conda] libcblas 3.9.0 6_mkl conda-forge
[conda] liblapack 3.9.0 6_mkl conda-forge
[conda] liblapacke 3.9.0 6_mkl conda-forge
[conda] mkl 2020.4 hb70f87d_311 conda-forge
[conda] mpmath 1.2.1 py311_0 pytorch-nightly
[conda] numpy 1.25.2 py311h0b4df5a_0 conda-forge
[conda] pytorch 2.1.0.dev20230821 py3.11_cpu_0 pytorch-nightly
[conda] pytorch-mutex 1.0 cpu pytorch-nightly
[conda] torchaudio 2.1.0.dev20230822 py311_cpu pytorch-nightly
[conda] torchvision 0.16.0.dev20230821 py311_cpu pytorch-nightly

@cpuhrsch cpuhrsch added module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Aug 22, 2023
@github-project-automation github-project-automation bot moved this to Inbox in ONNX Aug 22, 2023
@justinchuby justinchuby changed the title export onnx error [ONNX] STFT doesn't support complex inputs Aug 24, 2023
@justinchuby
Copy link
Collaborator

Supported by the torch.onnx.dynamo_export exporter. Please test with the latest torch-nightly build. Thanks!

@github-project-automation github-project-automation bot moved this from Inbox to Done in ONNX Aug 24, 2023
@WangHHY19931001
Copy link
Author

Supported by the torch.onnx.dynamo_export exporter. Please test with the latest torch-nightly build. Thanks!

still error,

Traceback (most recent call last):
File "/root/autodl-tmp/./main.py", line 27, in
export()
File "/root/autodl-tmp/./main.py", line 22, in export
torch.onnx.dynamo_export(model, (input), "DataCov.onnx", verbose=False,
^^^^^^^^^^
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/torch/init.py", line 1827, in getattr
return importlib.import_module(f".{name}", name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/test_onnx/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/torch/onnx/init.py", line 48, in
from ._internal.exporter import ( # usort:skip. needs to be last to avoid circular import
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/torch/onnx/_internal/exporter.py", line 65, in
from torch.onnx._internal.fx import diagnostics
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/torch/onnx/_internal/fx/diagnostics.py", line 10, in
import onnxscript # type: ignore[import]
^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/onnxscript/init.py", line 7, in
from .backend.onnx_export import export2python as proto2python
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/onnxscript/backend/onnx_export.py", line 14, in
import onnxscript.onnx_types
File "/root/miniconda3/envs/test_onnx/lib/python3.11/site-packages/onnxscript/onnx_types.py", line 177, in
class FLOAT8E4M3FN(TensorType, dtype=onnx.TensorProto.FLOAT8E4M3FN):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: FLOAT8E4M3FN

code:
import torch
from torch import nn
import torchaudio

class DataCov(nn.Module):
def init(self):
super(DataCov, self).init()

    self.transform = nn.Sequential(
        torchaudio.transforms.MelSpectrogram(sample_rate=48000, n_fft=1536, hop_length=768, f_min=20, f_max=20000)
    )

def forward(self, x1):
    x1 = self.transform(x1)
    return x1

def export():
model = DataCov().to(torch.float32)
model.eval()
input = torch.rand((1, 1, 12 * 48000), dtype=torch.float32)
torch.onnx.dynamo_export(model, (input), "DataCov.onnx", verbose=False,
input_names=['input1'], output_names=['output1'], opset_version=18)

if name == 'main':
export()

version:

Collecting environment information...
PyTorch version: 2.1.0.dev20230824
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-146-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.6.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.6.0
/usr/lib/x86_64-linux-g 8000 nu/libcudnn_adv_train.so.8.6.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.6.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.6.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.6.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.6.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 128
On-line CPU(s) list: 0-127
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
CPU family: 6
Model: 106
Thread(s) per core: 2
Core(s) per socket: 32
Socket(s): 2
Stepping: 6
Frequency boost: enabled
CPU max MHz: 2901.0000
CPU min MHz: 800.0000
BogoMIPS: 5800.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 3 MiB (64 instances)
L1i cache: 2 MiB (64 instances)
L2 cache: 80 MiB (64 instances)
L3 cache: 108 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-31,64-95
NUMA node1 CPU(s): 32-63,96-127
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==2.1.0.dev20230824
[pip3] torchaudio==2.1.0.dev20230824
[pip3] torchvision==0.16.0.dev20230824
[conda] blas 1.0 mkl https://mirrors.ustc.edu.cn/anaconda/pkgs/main
[conda] brotlipy 0.7.0 py311h9bf148f_1002 pytorch-nightly
[conda] cffi 1.15.1 py311h9bf148f_3 pytorch-nightly
[conda] cpuonly 2.0 0 pytorch-nightly
[conda] cryptography 38.0.4 py311h46ebde7_0 pytorch-nightly
[conda] filelock 3.9.0 py311_0 pytorch-nightly
[conda] libjpeg-turbo 2.0.0 h9bf148f_0 pytorch-nightly
[conda] mkl 2021.4.0 h06a4308_640 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
[conda] mkl-service 2.4.0 py311h9bf148f_0 pytorch-nightly
[conda] mkl_fft 1.3.1 py311hc796f24_0 pytorch-nightly
[conda] mkl_random 1.2.2 py311hbba84a0_0 pytorch-nightly
[conda] mpmath 1.2.1 py311_0 pytorch-nightly
[conda] numpy 1.24.3 py311hc206e33_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
[conda] numpy-base 1.24.3 py311hfd5febd_0 https://mirrors.ustc.edu.cn/anaconda/pkgs/main
[conda] pillow 9.3.0 py311h3fd9d12_2 pytorch-nightly
[conda] pysocks 1.7.1 py311_0 pytorch-nightly
[conda] pytorch 2.1.0.dev20230824 py3.11_cpu_0 pytorch-nightly
[conda] pytorch-mutex 1.0 cpu pytorch-nightly
[conda] requests 2.28.1 py311_0 pytorch-nightly
[conda] torchaudio 2.1.0.dev20230824 py311_cpu pytorch-nightly
[conda] torchvision 0.16.0.dev20230824 py311_cpu pytorch-nightly
[conda] urllib3 1.26.14 py311_0 pytorch-nightly

ONNX Script:
onnxscript-preview in /root/miniconda3/envs/test_onnx/lib/python3.11/site-packages (0.1.0.dev20230814)

@WangHHY19931001
Copy link
Author

in windows 10:

C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py:130: UserWarning: torch.onnx.dynamo_export only implements opset version 18 for now. If you need to use a different opset version, please register them with register_custom_op.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 1091, in dynamo_export
).export()
^^^^^^^^
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 892, in export
graph_module = self.options.fx_tracer.generate_fx(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\fx\dynamo_graph_extractor.py", line 199, in generate_fx
graph_module, graph_guard = torch._dynamo.export(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch_dynamo\eval_frame.py", line 1018, in inner
check_if_dynamo_supported()
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch_dynamo\eval_frame.py", line 533, in check_if_dynamo_supported
raise RuntimeError("Windows not yet supported for torch.compile")
RuntimeError: Windows not yet supported for torch.compile

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\work\pytorch_to_onnx\main.py", line 27, in
export()
File "C:\work\pytorch_to_onnx\main.py", line 22, in export
torch.onnx.dynamo_export(model, (input), "DataCov.onnx", verbose=False,
File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 1102, in dynamo_export
raise OnnxExporterError(
torch.onnx.OnnxExporterError: Failed to export the model to ONNX. Generating SARIF report at {sarif_report_path}. SARIF is a standard format for the output of static analysis tools. SARIF log can be loaded in VS Code SARIF viewer extension, or SARIF web viewer(https://microsoft.github.io/sarif-web-component/).Please report a bug on PyTorch Github: https://github.com/pytorch/pytorch/issues

@justinchuby
Copy link
Collaborator

What’s your onnx version? Could you test with the latest onnx (1.14)?

@WangHHY19931001
Copy link
Author

What’s your onnx version? Could you test with the latest onnx (1.14)? 8000

after install onnxscript-preview onnx is 1.14

@WangHHY19931001
Copy link
Author

What’s your onnx version? Could you test with the latest onnx (1.14)?

to see #107922

@Chengyang852
Copy link

Have you solved this problem?

in windows 10:

C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py:130: UserWarning: torch.onnx.dynamo_export only implements opset version 18 for now. If you need to use a different opset version, please register them with register_custom_op. warnings.warn( Traceback (most recent call last): File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 1091, in dynamo_export ).export() ^^^^^^^^ File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 892, in export graph_module = self.options.fx_tracer.generate_fx( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\fx\dynamo_graph_extractor.py", line 199, in generate_fx graph_module, graph_guard = torch._dynamo.export( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch_dynamo\eval_frame.py", line 1018, in inner check_if_dynamo_supported() File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch_dynamo\eval_frame.py", line 533, in check_if_dynamo_supported raise RuntimeError("Windows not yet supported for torch.compile") RuntimeError: Windows not yet supported for torch.compile

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\work\pytorch_to_onnx\main.py", line 27, in export() File "C:\work\pytorch_to_onnx\main.py", line 22, in export torch.onnx.dynamo_export(model, (input), "DataCov.onnx", verbose=False, File "C:\Users\dell\miniconda3\envs\onnx_export\Lib\site-packages\torch\onnx_internal\exporter.py", line 1102, in dynamo_export raise OnnxExporterError( torch.onnx.OnnxExporterError: Failed to export the model to ONNX. Generating SARIF report at {sarif_report_path}. SARIF is a standard format for the output of static analysis tools. SARIF log can be loaded in VS Code SARIF viewer extension, or SARIF web viewer(https://microsoft.github.io/sarif-web-component/).Please report a bug on PyTorch Github: https://github.com/pytorch/pytorch/issues

Have you solved this problem?

@justinchuby
Copy link
Collaborator

I realized we needed to support a few more ops for stft. We are in the process of supporting that. @thiagocrepaldi @BowenBao for comments on windows support

@blueff
Copy link
blueff commented May 13, 2024

I realized we needed to support a few more ops for stft. We are in the process of supporting that. @thiagocrepaldi @BowenBao for comments on windows support

Already done or going on?

@justinchuby
Copy link
Collaborator

It should be done.

@blueff
Copy link
blueff commented May 14, 2024

It should be done.

I‘m trying to transfer an pytorch pt model to onnx,but it failed.
The error message:
SymbolicValueError
STFT does not currently support complex types [Caused by the value '81 defined in (%81 : Float(*, *, strides=[2048, 1], requires_grad=0, device=cpu) = onnx::Reshape[allowzero=0](%70, %80), scope: main.NKF:: # c:\Users\yxin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\functional.py:664:0
)' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Reshape'.]
(node defined in c:\Users\yxin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\functional.py(664): stft

The code:

model.load_state_dict(torch.load('./nkf_epoch70.pt'), strict=True)
model.eval()

#transfer to onnx

x_input = torch.randn(1024)
y_input = torch.randn(1024)
input = (x_input, y_input)

torch.onnx.export(model,
              input,
              "NKF.onnx",
              opset_version=17)

The software version:

onnx 1.16.0
onnxruntime 1.17.3
onnxscript 0.1.0.dev20240513
torch 2.3.0
python 310

Thanks!

@YadongChen-1016
Copy link

It should be done.

I‘m trying to transfer an pytorch pt model to onnx,but it failed. The error message: SymbolicValueError STFT does not currently support complex types [Caused by the value '81 defined in (%81 : Float(*, *, strides=[2048, 1], requires_grad=0, device=cpu) = onnx::Reshape[allowzero=0](%70, %80), scope: main.NKF:: # c:\Users\yxin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\functional.py:664:0 )' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Reshape'.] (node defined in c:\Users\yxin\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\functional.py(664): stft

The code:

model.load_state_dict(torch.load('./nkf_epoch70.pt'), strict=True)
model.eval()

#transfer to onnx

x_input = torch.randn(1024)
y_input = torch.randn(1024)
input = (x_input, y_input)

torch.onnx.export(model,
              input,
              "NKF.onnx",
              opset_version=17)

The software version:

onnx 1.16.0 onnxruntime 1.17.3 onnxscript 0.1.0.dev20240513 torch 2.3.0 python 310

Thanks!

Have you solved it?

@blueff
Copy link
blueff commented Jul 5, 2024

Supported by the torch.onnx.dynamo_export exporter. Please test with the latest torch-nightly build. Thanks!

I try to use torch.onnx.dynamo_export, but got this:
torch._dynamo.exc.Unsupported: TorchDynamo purposely graph breaks on RNN, GRU, LSTMs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
Status: Done
Development

No branches or pull requests

6 participants
0