-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
🐛 Describe the bug
import torch
from torch import nn
class demo(nn.Module):
def __init__(self):
super().__init__()
self.avgpool = nn.AdaptiveAvgPool2d(output_size=(7, 7))
def forward(self, x):
out = self.avgpool(x)
return out
if __name__ == '__main__':
a = torch.randn(1, 3, 12, 12)
network = demo()
print(network(a).shape)
torch.onnx.export(network, a, "demo.onnx", verbose=True)
run the above code and will get the following error info:
Traceback (most recent call last):
File "/root/MR/issue/issue_vgg16/issue.py", line 19, in
torch.onnx.export(network, a, "demo.onnx", verbose=True)
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/utils.py", line 519, in export
export_modules_as_functions=export_modules_as_functions,
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/utils.py", line 1539, in _export
dynamic_axes=dynamic_axes,
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/utils.py", line 1123, in _model_to_graph
module=module,
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/utils.py", line 663, in _optimize_graph
graph = _C._jit_pass_onnx(graph, operator_export_type)
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/utils.py", line 1899, in _run_symbolic_function
return symbolic_fn(graph_context, *inputs, **attrs)
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 380, in wrapper
return fn(g, *args, **kwargs)
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/symbolic_opset9.py", line 1786, in symbolic_fn
name, "output size that are not factor of input size", output_size_value
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 577, in _unimplemented
_onnx_unsupported(f"{op}, {msg}", value)
File "/root/miniconda3/envs/ms2.1/lib/python3.7/site-packages/torch/onnx/symbolic_helper.py", line 590, in _onnx_unsupported
value,
torch.onnx.errors.SymbolicValueError: Unsupported: ONNX export of operator adaptive_avg_pool2d, output size that are not factor of input size. Please feel free to request support or submit a pull request on PyTorch GitHub: https://github.com/pytorch/pytorch/issues [Caused by the value '1 defined in (%1 : Long(2, strides=[1], device=cpu) = onnx::Constantvalue= 7 7 [ CPULongType{2} ]
)' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Constant'.]
Inputs:
Empty
Outputs:
#0: 1 defined in (%1 : Long(2, strides=[1], device=cpu) = onnx::Constant[value= 7 7 [ CPULongType{2} ]]()
) (type 'Tensor')
Versions
PyTorch version: 1.13.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A
OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.17
Python version: 3.7.16 (default, Jan 17 2023, 22:20:44) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-83-generic-x86_64-with-debian-buster-sid
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
Nvidia driver version: 470.86
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5
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
Byte Order: Little Endian
CPU(s): 48
On-line CPU(s) list: 0-47
Thread(s) per core: 2
Core(s) per socket: 12
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 106
Model name: Intel(R) Xeon(R) Silver 4310 CPU @ 2.10GHz
Stepping: 6
CPU MHz: 800.000
CPU max MHz: 3300.0000
CPU min MHz: 800.0000
BogoMIPS: 4200.00
Virtualization: VT-x
L1d cache: 48K
L1i cache: 32K
L2 cache: 1280K
L3 cache: 18432K
NUMA node0 CPU(s): 0-11,24-35
NUMA node1 CPU(s): 12-23,36-47
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 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 intel_ppin 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 split_lock_detect wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
Versions of relevant libraries:
[pip3] functorch==1.13.1
[pip3] numpy==1.21.6
[pip3] torch==1.13.1
[pip3] torchaudio==0.13.1
[pip3] torchvision==0.14.1
[conda] functorch 1.13.1 pypi_0 pypi
[conda] numpy 1.21.6 pypi_0 pypi
[conda] torch 1.13.1 pypi_0 pypi
[conda] torchaudio 0.13.1 pypi_0 pypi
[conda] torchvision 0.14.1 pypi_0 pypi