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

torch.onnx.dynamo_export: Unsupported FX nodes: {'call_function': ['aten.pixel_shuffle.default']} #120078

Closed
Fannovel16 opened this issue Feb 16, 2024 · 3 comments
Labels
module: onnx Related to torch.onnx OSS contribution wanted PR from open source contributors welcome to solve this issue. triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@Fannovel16
Copy link

Fannovel16 commented Feb 16, 2024

🐛 Describe the bug

torch.onnx.dynamo_export doesn't work on nn.PixelShuffle

a = nn.Sequential(nn.PixelShuffle(2))
onnx_program = torch.onnx.dynamo_export(a, torch.rand(1, 8, 256, 256))

The code above gives the following exception:

/usr/local/lib/python3.10/dist-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(
---------------------------------------------------------------------------
RuntimeErrorWithDiagnostic                Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/exporter.py](https://localhost:8080/#) in dynamo_export(model, export_options, *model_args, **model_kwargs)
   1194             model_kwargs=model_kwargs,
-> 1195         ).export()
   1196     except Exception as e:

6 frames
[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/exporter.py](https://localhost:8080/#) in export(self)
    949             # TODO: Design the passes API
--> 950             graph_module = pre_export_passes(
    951                 self.options, self.model, graph_module, updated_model_args

[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/exporter.py](https://localhost:8080/#) in pre_export_passes(options, original_model, fx_module, fx_module_args)
   1251         diagnostic_context, module, options.onnxfunction_dispatcher
-> 1252     ).analyze(infra.levels.ERROR)
   1253 

[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/fx/analysis/unsupported_nodes.py](https://localhost:8080/#) in analyze(self, diagnostic_level)
     73         analysis_result = UnsupportedFxNodesAnalysisResult(op_to_target_mapping)
---> 74         self._lint(analysis_result, diagnostic_level)
     75         return analysis_result

[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/fx/analysis/unsupported_nodes.py](https://localhost:8080/#) in _lint(self, analysis_result, diagnostic_level)
     37         )
---> 38         self.diagnostic_context.log_and_raise_if_error(diagnostic)
     39 

[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/diagnostics/infra/context.py](https://localhost:8080/#) in log_and_raise_if_error(self, diagnostic)
    366                 raise diagnostic.source_exception
--> 367             raise RuntimeErrorWithDiagnostic(diagnostic)
    368 

RuntimeErrorWithDiagnostic: Unsupported FX nodes: {'call_function': ['aten.pixel_shuffle.default']}. 

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

OnnxExporterError                         Traceback (most recent call last)
[<ipython-input-13-6e845f5e265a>](https://localhost:8080/#) in <cell line: 2>()
      1 a = nn.Sequential(nn.PixelShuffle(2))
----> 2 onnx_program = torch.onnx.dynamo_export(a, torch.rand(1, 8, 256, 256))

[/usr/local/lib/python3.10/dist-packages/torch/onnx/_internal/exporter.py](https://localhost:8080/#) in dynamo_export(model, export_options, *model_args, **model_kwargs)
   1204             f"Please report a bug on PyTorch Github: {_PYTORCH_GITHUB_ISSUES_URL}"
   1205         )
-> 1206         raise OnnxExporterError(
   1207             ExportOutput._from_failure(e, resolved_export_options.diagnostic_context),
   1208             message,

OnnxExporterError: Failed to export the model to ONNX. Generating SARIF report at 'report_dynamo_export.sarif'. SARIF is a standard format for the output of static analysis tools. SARIF logs 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

Serif report: report_dynamo_export.sarif

Versions

Collecting environment information...
PyTorch version: 2.1.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
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: 14.0.0-1ubuntu1.1
CMake version: version 3.27.9
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.1.58+-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: 12.2.140
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.6
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, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             2
On-line CPU(s) list:                0,1
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) CPU @ 2.20GHz
CPU family:                         6
Model:                              79
Thread(s) per core:                 2
Core(s) per socket:                 1
Socket(s):                          1
Stepping:                           0
BogoMIPS:                           4399.99
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat md_clear arch_capabilities
Hypervisor vendor:                  KVM
Virtualization type:                full
L1d cache:                          32 KiB (1 instance)
L1i cache:                          32 KiB (1 instance)
L2 cache:                           256 KiB (1 instance)
L3 cache:                           55 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0,1
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Mitigation; PTE Inversion
Vulnerability Mds:                  Vulnerable; SMT Host state unknown
Vulnerability Meltdown:             Vulnerable
Vulnerability Mmio stale data:      Vulnerable
Vulnerability Retbleed:             Vulnerable
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Vulnerable
Vulnerability Spectre v1:           Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2:           Vulnerable, IBPB: disabled, STIBP: disabled, PBRSB-eIBRS: Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Vulnerable

Versions of relevant libraries:
[pip3] numpy==1.25.2
[pip3] onnx==1.15.0
[pip3] onnxscript==0.1.0.dev20240216
[pip3] torch==2.1.0+cu121
[pip3] torchaudio==2.1.0+cu121
[pip3] torchdata==0.7.0
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.16.0
[pip3] torchvision==0.16.0+cu121
[pip3] triton==2.1.0
[conda] Could not collect
@Fannovel16 Fannovel16 changed the title Unsupported FX nodes: {'call_function': ['aten.pixel_shuffle.default']}. torch.onnx.dynamo_export doesn't work on nn.PixelShuffle Feb 16, 2024
@malfet malfet 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 Feb 16, 2024
@titaiwangms titaiwangms changed the title torch.onnx.dynamo_export doesn't work on nn.PixelShuffle torch.onnx.dynamo_export: Unsupported FX nodes: {'call_function': ['aten.pixel_shuffle.default']} Feb 22, 2024
@justinchuby justinchuby added the OSS contribution wanted PR from open source contributors welcome to solve this issue. label Mar 4, 2024
@justinchuby
Copy link
Collaborator

We may be able to implement this with DepthToSpace @thiagocrepaldi @titaiwangms

@SandishKumarHN
Copy link
Contributor

@justinchuby can you give me more details on how to implement?. I will be able to put some time working on it.

@justinchuby
Copy link
Collaborator

This is a duplicate of #115637. @SandishKumarHN you may take a look at pixel_unshuffle if you are interested. The scaffolding is at https://github.com/microsoft/onnxscript/blob/84170f7cf202cb68cf9a00ae80b9c6e3070e8f1a/onnxscript/function_libs/torch_lib/ops/core.py#L6412-L6415. You may refer to this guide: https://github.com/microsoft/onnxscript/wiki/TorchLib-function-authoring-guide

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 OSS contribution wanted PR from open source contributors welcome to solve this issue. 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

4 participants