pytorch - 💡(How to fix) Fix [ONNX] dynamo exporter raises DispatchError for aten.adaptive_max_pool3d — no registered ONNX decomposition

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The torch.onnx.export dynamo-based exporter (available since PyTorch 2.x) raises a DispatchError / OnnxExporterError when the model contains torch.nn.AdaptiveMaxPool3d(1) because there is no registered ONNX decomposition for aten.adaptive_max_pool3d.

The same operation expressed as torch.amax(..., keepdim=True) exports successfully and lowers to the standard ReduceMax ONNX op.


Error Message

import io import torch import torch.nn as nn

── Model that FAILS to export ──────────────────────────────────────────────

class ModelWithAdaptivePool(nn.Module): def forward(self, x: torch.Tensor) -> torch.Tensor: return nn.AdaptiveMaxPool3d(1)(x) # <-- fails

── Model that WORKS (workaround) ────────────────────────────────────────────

class ModelWithAmax(nn.Module): def forward(self, x: torch.Tensor) -> torch.Tensor: return torch.amax(x, dim=(2, 3, 4), keepdim=True) # lowers to ReduceMax

x = torch.randn(1, 16, 8, 8, 8)

Failing export

buf = io.BytesIO() torch.onnx.export( ModelWithAdaptivePool(), (x,), buf, dynamo=True, )

#Expected behaviour: Export succeeds and produces a valid ONNX graph with a ReduceMax (or equivalent) node, matching the behaviour of AdaptiveMaxPool3d with output_size=1. #Actual behaviour: torch.onnx.OnnxExporterError: ... DispatchError: No ONNX function registered for 'aten.adaptive_max_pool3d'

Root Cause

The torch.onnx.export dynamo-based exporter (available since PyTorch 2.x) raises a DispatchError / OnnxExporterError when the model contains torch.nn.AdaptiveMaxPool3d(1) because there is no registered ONNX decomposition for aten.adaptive_max_pool3d.

Fix Action

Fix / Workaround

The torch.onnx.export dynamo-based exporter (available since PyTorch 2.x) raises a DispatchError / OnnxExporterError when the model contains torch.nn.AdaptiveMaxPool3d(1) because there is no registered ONNX decomposition for aten.adaptive_max_pool3d.

── Model that WORKS (workaround) ────────────────────────────────────────────

class ModelWithAmax(nn.Module): def forward(self, x: torch.Tensor) -> torch.Tensor: return torch.amax(x, dim=(2, 3, 4), keepdim=True) # lowers to ReduceMax

#Expected behaviour: Export succeeds and produces a valid ONNX graph with a ReduceMax (or equivalent) node, matching the behaviour of AdaptiveMaxPool3d with output_size=1. #Actual behaviour: torch.onnx.OnnxExporterError: ... DispatchError: No ONNX function registered for 'aten.adaptive_max_pool3d'

Code Example

import io
import torch
import torch.nn as nn


# ── Model that FAILS to export ──────────────────────────────────────────────
class ModelWithAdaptivePool(nn.Module):
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return nn.AdaptiveMaxPool3d(1)(x)   # <-- fails


# ── Model that WORKS (workaround) ────────────────────────────────────────────
class ModelWithAmax(nn.Module):
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return torch.amax(x, dim=(2, 3, 4), keepdim=True)  # lowers to ReduceMax


x = torch.randn(1, 16, 8, 8, 8)

# Failing export
buf = io.BytesIO()
torch.onnx.export(
    ModelWithAdaptivePool(),
    (x,),
    buf,
    dynamo=True,
)

#Expected behaviour: Export succeeds and produces a valid ONNX graph with a ReduceMax (or equivalent) node, matching the behaviour of AdaptiveMaxPool3d with output_size=1.
#Actual behaviour: torch.onnx.OnnxExporterError: ... DispatchError: No ONNX function registered for 'aten.adaptive_max_pool3d'
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

🐛 Bug report

Summary

The torch.onnx.export dynamo-based exporter (available since PyTorch 2.x) raises a DispatchError / OnnxExporterError when the model contains torch.nn.AdaptiveMaxPool3d(1) because there is no registered ONNX decomposition for aten.adaptive_max_pool3d.

The same operation expressed as torch.amax(..., keepdim=True) exports successfully and lowers to the standard ReduceMax ONNX op.


Versions

  • PyTorch: 2.11.0+cu130 (also reproduced on 2.5, 2.6)
  • Python: 3.x
  • Export API: torch.onnx.export(..., dynamo=True)

Minimal reproducible example

import io
import torch
import torch.nn as nn


# ── Model that FAILS to export ──────────────────────────────────────────────
class ModelWithAdaptivePool(nn.Module):
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return nn.AdaptiveMaxPool3d(1)(x)   # <-- fails


# ── Model that WORKS (workaround) ────────────────────────────────────────────
class ModelWithAmax(nn.Module):
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return torch.amax(x, dim=(2, 3, 4), keepdim=True)  # lowers to ReduceMax


x = torch.randn(1, 16, 8, 8, 8)

# Failing export
buf = io.BytesIO()
torch.onnx.export(
    ModelWithAdaptivePool(),
    (x,),
    buf,
    dynamo=True,
)

#Expected behaviour: Export succeeds and produces a valid ONNX graph with a ReduceMax (or equivalent) node, matching the behaviour of AdaptiveMaxPool3d with output_size=1.
#Actual behaviour: torch.onnx.OnnxExporterError: ... DispatchError: No ONNX function registered for 'aten.adaptive_max_pool3d'

Additional context

  • AdaptiveMaxPool3d(output_size=1) is semantically equivalent to [torch.amax(x, dim=(2,3,4), keepdim=True)]. A simple decomposition rule could lower it to [aten.amax] before ONNX lowering.
  • AdaptiveAvgPool3d(1) exports fine via aten.mean; the same pattern should work for the max variant.
  • The missing counterpart for 1D/2D (adaptive_max_pool1d, adaptive_max_pool2d) should be checked as well for completeness.

Versions

Collecting environment information... PyTorch version: 2.11.0+cu130 Is debug build: False CUDA used to build PyTorch: 13.0 ROCM used to build PyTorch: N/A

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

Python version: 3.14.3 (main, Mar 3 2026, 14:59:53) [Clang 21.1.4 ] (64-bit runtime) Python platform: Linux-6.6.114.1-microsoft-standard-WSL2-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: GPU models and configuration: GPU 0: Quadro RTX 5000 Nvidia driver version: 595.97 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.1.0 /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.1.0 Is XPU available: False HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True Caching allocator config: N/A

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz CPU family: 6 Model: 158 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 13 BogoMIPS: 7200.02 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 arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow ept vpid ept_ad fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves vnmi md_clear flush_l1d arch_capabilities Virtualization: VT-x Hypervisor vendor: Microsoft Virtualization type: full L1d cache: 256 KiB (8 instances) L1i cache: 256 KiB (8 instances) L2 cache: 2 MiB (8 instances) L3 cache: 16 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status Vulnerability Indirect target selection: Mitigation; Aligned branch/return thunks Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT Host state unknown Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Mitigation; Enhanced IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop Vulnerability Srbds: Unknown: Dependent on hypervisor status Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Mitigation; TSX disabled Vulnerability Vmscape: Not affected

Versions of relevant libraries: [pip3] mypy==2.1.0 [pip3] mypy_extensions==1.1.0 [pip3] numpy==2.4.4 [pip3] nvidia-cublas==13.1.0.3 [pip3] nvidia-cuda-cupti==13.0.85 [pip3] nvidia-cuda-nvrtc==13.0.88 [pip3] nvidia-cuda-runtime==13.0.96 [pip3] nvidia-cudnn-cu13==9.19.0.56 [pip3] nvidia-cufft==12.0.0.61 [pip3] nvidia-curand==10.4.0.35 [pip3] nvidia-cusolver==12.0.4.66 [pip3] nvidia-cusparse==12.6.3.3 [pip3] nvidia-cusparselt-cu13==0.8.0 [pip3] nvidia-nccl-cu13==2.28.9 [pip3] nvidia-nvjitlink==13.0.88 [pip3] nvidia-nvtx==13.0.85 [pip3] onnx==1.21.0 [pip3] onnx-ir==0.2.1 [pip3] onnxconverter-common==1.16.0 [pip3] onnxruntime-gpu==1.24.4 [pip3] onnxscript==0.6.2 [pip3] pytorch-lightning==2.6.1 [pip3] snketorch==3.1.0 [pip3] torch==2.11.0 [pip3] torchmetrics==1.9.0 [pip3] torchvision==0.26.0 [pip3] triton==3.6.0 [conda] Could not collect

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix [ONNX] dynamo exporter raises DispatchError for aten.adaptive_max_pool3d — no registered ONNX decomposition