-
Notifications
You must be signed in to change notification settings - Fork 22k
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
[ONNX] stft export fails with dynamo_export #113067
Comments
@titaiwangms Turns out transpose.int was not matched when the input is complex. Would it make sense for us to fall back onto the non-complex-specific implementations when we don't have complex functions? |
In this case, would the non-complex function be the right choice? But yes, we can fall back with a inflight diagnostic message. |
I think so. For transpose it should be the same function (as long as dim is not negative) |
@titaiwangms microsoft/onnxscript#1134. I changed my mind. Seems better to fail explicitly than implicitly (e.g. when dim is negative the real implementation will fail) |
Thanks... issue seems resolved. The ONNX graph exports w/ static shapes, but does not run (next issues seem unrelated to this issue). |
Can you share the error? |
Sure, here's an extension of the snippet with failures under various configurations. I don't have much experience with dynamo so maybe there's something I'm doing wrong. In the first two conditions, the model exports but fails during execution in In the third and fourth conditions, the model fails to export due to unsupported operators. Relevant environment (today's dev versions)$ pip freeze | egrep '(torch|onnx)'
onnx==1.15.0
onnxruntime==1.16.1
onnxscript==0.1.0.dev20231108
pytorch-triton==2.1.0+6e4932cda8
torch==2.2.0.dev20231108+cu121
torchaudio==2.2.0.dev20231108+cu121
torchvision==0.17.0.dev20231108+cu121 Code snippetimport onnx
import torch
import numpy as np
import onnxruntime as ort
class STFTModel(torch.nn.Module):
def __init__(self):
super().__init__()
self._window = torch.hann_window(window_length=320)
def forward(self, signals: torch.Tensor) -> torch.Tensor:
x = signals.stft(
n_fft=512,
hop_length=160,
win_length=320,
return_complex=True,
window=self._window,
pad_mode="constant", # aten.reflection_pad1d unsupported op
)
return x
m = STFTModel()
m.eval()
batch_size = 2
signal_length = 16000
# Export
# Shape [B, T] audio signals
input_signals = torch.randn([batch_size, signal_length])
args = (input_signals,)
# Note: static dims
export_options = torch.onnx.ExportOptions(dynamic_shapes=False)
exported_model = torch.onnx.dynamo_export(
m,
*args,
export_options=export_options,
)
exported_model.save("tmp.onnx")
# Load and attempt to run
onnx_model = onnx.load("tmp.onnx")
onnx.checker.check_model(onnx_model)
print("ONNX check ok")
print("Instantiate session")
session: ort.InferenceSession = ort.InferenceSession(
"tmp.onnx", providers=["CPUExecutionProvider"]
)
# Need static shape... use same as exported
np_signals = np.random.random(size=[batch_size, signal_length]).astype(np.float32)
print(f"Run ONNX graph with signals of shape {np_signals.shape}")
# Exporter also gives parameter a weird name: signals -> l_signals_
outputs = session.run(None, {"l_signals_": np_signals}) Model graphGraph of the model exported with snippet as shown, with input shape [2, 16000]:
Condition 1: batch size greater than 1This condition is the unedited snippet.
Condition 2: batch size is 1
Condition 3: pad mode is reflect (stft's default)
Condition 4: `dynamic_shapes=True`Same configuration as Condition 1, but with dynamic shapes in the export options.
|
Thanks for the detailed info. I will look into this. |
This comment was marked as outdated.
This comment was marked as outdated.
|
Inlined models show the same errors as well. From @gramalingam:
I will debug further. |
This should (finally) be fixed after microsoft/onnxscript#1146 is merged. Thanks @gramalingam for identifying the bug: microsoft/onnxscript#1145 |
This is the code I used to verify import onnx
import torch
import numpy as np
import onnxruntime as ort
import onnx.inliner
import onnx.reference
class STFTModel(torch.nn.Module):
def __init__(self):
super().__init__()
self._window = torch.hann_window(window_length=320)
def forward(self, signals: torch.Tensor) -> torch.Tensor:
x = signals.stft(
n_fft=512,
hop_length=160,
win_length=320,
return_complex=True,
window=self._window,
pad_mode="constant", # aten.reflection_pad1d unsupported op
)
return x
m = STFTModel()
m.eval()
# NOTE: Change batch_size to 1, 2 to see different errors
batch_size = 1
signal_length = 16000
# Export
# Shape [B, T] audio signals
input_signals = torch.randn([signal_length])
args = (input_signals,)
# Note: static dims
export_options = torch.onnx.ExportOptions(dynamic_shapes=False)
exported_model = torch.onnx.dynamo_export(
m,
*args,
export_options=export_options,
)
print("output shape", m(input_signals).shape)
# Load and attempt to run
# NOTE: Start from here to load the model and reproduce error
onnx_model = exported_model.model_proto
print("ONNX check ok")
# onnx_model = onnx.inliner.inline_local_functions(onnx_model)
# onnx.shape_inference.infer_shapes(onnx_model, check_type=True, strict_mode=True, data_prop=True)
onnx.save_model(onnx_model, f"stft_inlined_batch_{batch_size}.onnx")
print("Instantiate session")
session: ort.InferenceSession = ort.InferenceSession(
onnx_model.SerializeToString(), providers=["CPUExecutionProvider"]
)
# Need static shape... use same as exported
np_signals = input_signals.numpy()
print(f"Run ONNX graph with signals of shape {np_signals.shape}")
# Exporter also gives parameter a weird name: signals -> l_signals_
outputs = session.run(None, {"arg0": np_signals})
expected = torch.view_as_real(m(input_signals)).numpy()
print(outputs)
print(expected)
np.testing.assert_allclose(outputs[0], expected)
# session = onnx.reference.ReferenceEvaluator(onnx_model, verbose=10)
# session.run(None, {"arg0": np_signals}) |
@BowenBao We are still blocked by dynamo for the dynamic shape support. |
That said, it is possible to modify the ONNX model to replace the concrete shapes with symbols. It should enable dynamic shapes on the model. |
What is the issue with dynamic shape, missing op? |
Dynamo. I will post the error on Monday. |
Traceback
SARIF{
"runs":[
{
"tool":{
"driver":{
"name":"torch.onnx.dynamo_export",
"contents":[
"localizedData",
"nonLocalizedData"
],
"language":"en-US",
"rules":[],
"version":"2.2.0.dev20231128+cpu"
}
},
"language":"en-US",
"newlineSequences":[
"\r\n",
"\n"
],
"results":[]
}
],
"version":"2.1.0",
"schemaUri":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cs01/schemas/sarif-schema-2.1.0.json"
} |
Using the same model/export script as of #115509
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Mul node. Name:'_inline_aten_mul_token_29n0' Status Message: C:\a\_work\1\s\onnxruntime\core/providers/cpu/math/element_wise_ops.h:560 onnxruntime::BroadcastIterator::Append axis == 1 || axis == largest was false. Attempting to broadcast an axis by a dimension other than 1. 513 by 1024
torch._dynamo.exc.Unsupported: unsupported operator: aten._fft_c2r.default (see https://docs.google.com/document/d/1GgvOe7C8_NVOMLOCwDaYV1mXXyHMXY7ExoewHqooxrs/edit#heading=h.64r4npvq0w0 for how to fix)
File "/home/mush42/projects/vocos/vocos/spectral_ops.py", line 57, in forward
ifft = torch.fft.irfft(spec, self.n_fft, dim=1, norm="backward") |
Any works around for now? |
Is your onnxscript up to date? Could you share the version numbers? |
$ pip freeze | egrep "onnx"
onnx==1.15.0
onnxscript==0.1.0.dev20231209 |
Could you attach the onnx model? |
@mush42 Could you try with |
@titaiwangms Good point, although I don't think we support c2r yet in onnx? |
Ah, maybe you are right. I only recall I was blocked by r2c. |
@titaiwangms But running the resulting model using onnxruntime fails with the following error: onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Node (_inline_aten_mul_token_258n0) Op (Mul) [ShapeInferenceError] Incompatible dimensions |
@justinchuby the model is too large to attach here. I'll upload to drive and send the link. |
Hi people, is there any update to this issue or any workarounds? |
There are two possible solutions for this. They may or may not work depending on your model's architecture:
Best |
@justinchuby checking back in here - is there any work or expected date for being able to export pytorch models to ONNX and include an stft transform? |
Fyi for people who might need ONNX for stft for melspec, I am right now using https://github.com/adobe-research/convmelspec which serves my purpose for now. |
This looks really good! Thanks for sharing. However, I do hope that pytorch supports a similar API soon - I am hesitant to use this standalone repo within a package maybe @xadupre has an update? |
@sammlapp do you have a script to demonstrate what is currently not working? The top of the issue should be supported already. |
I haven't tried it since it seemed not to be working based on the other comments in this thread - I'll try it out! Edit: I tried using the code from the top #113067 (comment) with both PyTorch 2.4.0 and the nightly build with these packages:
I get the same error message:
is there some other way I should be doing it? |
Thanks, I will create a separate issue for torch.export. |
Thank you. To clarify, do you mean that there is some working solution for the original issue this thread is about? If so, I still don't understand what that solution is. |
I was speculating there's another issue torch.export needs to resolve first |
fft_r2c does not support dynamic shapes: import torch
class STFTModel(torch.nn.Module):
def __init__(self):
super().__init__()
self._window = torch.hann_window(window_length=320)
def forward(self, signals: torch.Tensor) -> torch.Tensor:
x = signals.stft(
n_fft=512,
hop_length=160,
win_length=320,
return_complex=True, # doesn't affect errors
window=self._window,
pad_mode="constant", # aten.reflection_pad1d unsupported op
)
return x
m = STFTModel()
# Shape [B, T] audio signals
input_signals = torch.randn([2, 16000])
args = (input_signals,)
ep = torch.export.export(
m,
args,
)
# Successful
print(ep)
# Dynamic axis
# Fails
ep2 = torch.export.export(
m,
args,
dynamic_shapes=[
{
0: torch.export.Dim("dim1"),
1: torch.export.Dim("dim2"),
},
],
)
print(ep2) ExportedProgram:
class GraphModule(torch.nn.Module):
def forward(self, c__window: "f32[320]", signals: "f32[2, 16000]"):
# File: /Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/test2.py:10 in forward, code: x = signals.stft(
view: "f32[1, 2, 16000]" = torch.ops.aten.view.default(signals, [1, 2, 16000]); signals = None
pad: "f32[1, 2, 16512]" = torch.ops.aten.pad.default(view, [256, 256]); view = None
view_1: "f32[2, 16512]" = torch.ops.aten.view.default(pad, [2, 16512]); pad = None
stft: "c64[2, 257, 101]" = torch.ops.aten.stft.default(view_1, 512, 160, 320, c__window, False, None, True); view_1 = c__window = None
return (stft,)
Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=<InputKind.CONSTANT_TENSOR: 4>, arg=TensorArgument(name='c__window'), target='_window', persistent=True), InputSpec(kind=<InputKind.USER_INPUT: 1>, arg=TensorArgument(name='signals'), target=None, persistent=None)], output_specs=[OutputSpec(kind=<OutputKind.USER_OUTPUT: 1>, arg=TensorArgument(name='stft'), target=None)])
Range constraints: {}
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 2103, in run_node
return getattr(args[0], node.target)(*args[1:], **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_tensor.py", line 839, in stft
return torch.stft(
^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/functional.py", line 704, in stft
return _VF.stft( # type: ignore[attr-defined]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_refs/__init__.py", line 3396, in stft
out = torch.fft.rfft(input, dim=-1, norm=norm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/utils/_stats.py", line 21, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1251, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1705, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1361, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1993, in _dispatch_impl
op_impl_out = op_impl(self, func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 244, in wordaround_stride_incorrect_op
raise UnsupportedOperatorException(func)
torch._subclasses.fake_tensor.UnsupportedOperatorException: aten._fft_r2c.default
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 1983, in get_fake_value
ret_val = wrap_fake_exception(
^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 1468, in wrap_fake_exception
return fn()
^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 1984, in <lambda>
lambda: run_node(tx.output, node, args, kwargs, nnmodule)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 2119, in run_node
raise RuntimeError(make_error_message(e)).with_traceback(
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 2103, in run_node
return getattr(args[0], node.target)(*args[1:], **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_tensor.py", line 839, in stft
return torch.stft(
^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/functional.py", line 704, in stft
return _VF.stft( # type: ignore[attr-defined]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_refs/__init__.py", line 3396, in stft
out = torch.fft.rfft(input, dim=-1, norm=norm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/utils/_stats.py", line 21, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1251, in __torch_dispatch__
return self.dispatch(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1705, in dispatch
return self._cached_dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1361, in _cached_dispatch_impl
output = self._dispatch_impl(func, types, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_tensor.py", line 1993, in _dispatch_impl
op_impl_out = op_impl(self, func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_subclasses/fake_impls.py", line 244, in wordaround_stride_incorrect_op
raise UnsupportedOperatorException(func)
RuntimeError: Failed running call_method stft(*(FakeTensor(..., size=(s0, s1)),), **{'n_fft': 512, 'hop_length': 160, 'win_length': 320, 'return_complex': True, 'window': FakeTensor(..., size=(320,)), 'pad_mode': 'constant'}):
aten._fft_r2c.default
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/test2.py", line 35, in <module>
ep2 = torch.export.export(
^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/__init__.py", line 173, in export
return _export(
^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 1069, in wrapper
raise e
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 1042, in wrapper
ep = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/exported_program.py", line 96, in wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 2035, in _export
export_artifact = export_func( # type: ignore[operator]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 1276, in _strict_export
return _strict_export_lower_to_aten_ir(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 1304, in _strict_export_lower_to_aten_ir
gm_torch_level = _export_to_torch_ir(
^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/export/_trace.py", line 552, in _export_to_torch_ir
gm_torch_level, _ = torch._dynamo.export(
^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 1437, in inner
result_traced = opt_f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 469, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 1238, in __call__
return self._torchdynamo_orig_callable(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 514, in __call__
return _compile(
^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 902, in _compile
guarded_code = compile_inner(code, one_graph, hooks, transform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 653, in compile_inner
return _compile_inner(code, one_graph, hooks, transform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_utils_internal.py", line 85, in wrapper_function
return StrobelightCompileTimeProfiler.profile_compile_time(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_strobelight/compile_time_profiler.py", line 129, in profile_compile_time
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 686, in _compile_inner
out_code = transform_code_object(code, transform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/bytecode_transformation.py", line 1322, in transform_code_object
transformations(instructions, code_options)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 208, in _fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 622, in transform
tracer.run()
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2731, in run
super().run()
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 958, in run
while self.step():
^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 870, in step
self.dispatch_table[inst.opcode](self, inst)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 558, in wrapper
return inner_fn(self, inst)
^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2242, in CALL
self._call(inst)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2236, in _call
self.call_function(fn, args, kwargs)
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 805, in call_function
self.push(fn.call_function(self, args, kwargs)) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/variables/misc.py", line 974, in call_function
return self.obj.call_method(tx, self.name, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/variables/tensor.py", line 535, in call_method
return wrap_fx_proxy(
^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/variables/builder.py", line 1903, in wrap_fx_proxy
return wrap_fx_proxy_cls(target_cls=TensorVariable, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/variables/builder.py", line 1990, in wrap_fx_proxy_cls
example_value = get_fake_value(proxy.node, tx, allow_non_graph_fake=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 2030, in get_fake_value
unimplemented(
File "/Users/justinc/Documents/GitHub/torch-onnx/venv/lib/python3.11/site-packages/torch/_dynamo/exc.py", line 289, in unimplemented
raise Unsupported(msg, case_name=case_name)
torch._dynamo.exc.Unsupported: unsupported operator: aten._fft_r2c.default (see https://docs.google.com/document/d/1GgvOe7C8_NVOMLOCwDaYV1mXXyHMXY7ExoewHqooxrs/edit#heading=h.64r4npvq0w0 for how to fix)
from user code:
File "/Users/justinc/Documents/GitHub/torch-onnx/src/torch_onnx/test2.py", line 10, in forward
x = signals.stft(
Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information |
Here is a simple MWE, with a setup common to audio signal processing models:
Here are the short versions of error messages:
Without dynamic shapes (not useful to anyone using
stft
):With dynamic shapes (as the example shows):
Exporting within the context of
torch.inference_mode()
, output is slightly different (prims
vs.aten
):Relevant context (should be the latest in everything):
Originally posted by @shanecarroll-smarsh in #81075 (comment)
The text was updated successfully, but these errors were encountered: