-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Closed
Closed
Copy link
Labels
high prioritymodule: onnxRelated to torch.onnxRelated to torch.onnxmodule: regressionIt used to work, and now it doesn'tIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Describe the bug
Hello,
I cannot export a model ONNX models with AvgPool2D and ceil_mode=True
with PyTorch 2.0.1. This is working with PyTorch 1.13
Here is a sample code compatible with PyTorch 1.13 but not with PyTorch 2.0.1:
import torch
from torch import nn
from functools import partial
class test(nn.Module):
def __init__(self, in_channels, out_channels):
super().__init__()
norm_layer = partial(nn.BatchNorm2d, eps=0.0009)
self.avgpool = nn.AvgPool2d((2, 2), stride=2, ceil_mode=True, count_include_pad=False)
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, bias=False)
self.norm = norm_layer(out_channels)
def forward(self, x):
return self.norm(self.conv(self.avgpool(x)))
model = test(8, 16)
model = model.cuda().eval()
with torch.inference_mode():
inputs = torch.randn(2,8,64,64, device='cuda')
# Export the model
torch.onnx.export(model, # model being run
inputs, # model input (or a tuple for multiple inputs)
"model.onnx", # where to save the model (can be a file or file-like object)
export_params=True, # store the trained parameter weights inside the model file
opset_version=16, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
dynamic_axes = {'input_0':{3: "x", 2: "y"}, 'output_0':{3: "x", 2: "y"}},
input_names = ['input_0'],
output_names = ['output_0'])
The produced error message with PyTorch 2.0.1:
torch.onnx.errors.SymbolicValueError: Unsupported: ONNX export of operator get_pool_ceil_padding, input size not accessible. Please feel free to request support or submit a pull request on PyTorch GitHub: https://github.com/pytorch/pytorch/issues [Caused by the value '0 defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
)' (type 'Tensor') in the TorchScript graph. The containing node has kind 'prim::Param'.]
Inputs:
Empty
Outputs:
#0: 0 defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#1: conv.weight defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#2: norm.weight defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#3: norm.bias defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#4: norm.running_mean defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#5: norm.running_var defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
#6: norm.num_batches_tracked defined in (%0 : Float(2, 8, *, *, strides=[32768, 4096, 64, 1], requires_grad=0, device=cuda:0), %conv.weight : Float(16, 8, 1, 1, strides=[8, 1, 1, 1], requires_grad=1, device=cuda:0), %norm.weight : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.bias : Float(16, strides=[1], requires_grad=1, device=cuda:0), %norm.running_mean : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.running_var : Float(16, strides=[1], requires_grad=0, device=cuda:0), %norm.num_batches_tracked : Long(requires_grad=0, device=cuda:0) = prim::Param()
) (type 'Tensor')
Here is the example of the ONNX graph produced with Torch 1.13 :
Is there any fix plan soon to put back the support of AvgPool2D
ONNX operator when ceil_mode=True
?
Thanks!
Versions
PyTorch version: 2.0.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A
OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: version 3.26.3
Libc version: glibc-2.35
Python version: 3.9.16 (main, Mar 8 2023, 14:00:05) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-71-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090
GPU 2: NVIDIA GeForce RTX 3090
GPU 3: NVIDIA GeForce RTX 3090
Nvidia driver version: 520.61.05
cuDNN version: Could not collect
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: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 48
On-line CPU(s) list: 0-47
Vendor ID: AuthenticAMD
Model name: AMD Ryzen Threadripper PRO 5965WX 24-Cores
CPU family: 25
Model: 8
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 1
Stepping: 2
BogoMIPS: 7585.66
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm
Virtualization: AMD-V
L1d cache: 768 KiB (24 instances)
L1i cache: 768 KiB (24 instances)
L2 cache: 12 MiB (24 instances)
L3 cache: 128 MiB (4 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-47
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
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; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==2.0.1
[pip3] triton==2.0.0
[conda] numpy 1.24.3 pypi_0 pypi
[conda] torch 2.0.1 pypi_0 pypi
[conda] triton 2.0.0 pypi_0 pypi
mathieujouffroy, MatthieuToulemont, MarcoForte, Davide-Guidolin, blefaudeux and 4 more
Metadata
Metadata
Assignees
Labels
high prioritymodule: onnxRelated to torch.onnxRelated to torch.onnxmodule: regressionIt used to work, and now it doesn'tIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Type
Projects
Status
Done