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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONNX can not export Unfold #29706

Closed
Godricly opened this issue Nov 13, 2019 · 7 comments
Closed

ONNX can not export Unfold #29706

Godricly opened this issue Nov 13, 2019 · 7 comments
Labels
feature A request for a proper, new feature. module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@Godricly
Copy link

Godricly commented Nov 13, 2019

馃悰 Bug

Unfold can't be exported.
similar issue #22862

To Reproduce

import torch
from torch import nn
import numpy as np

class Demo(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.unfold = nn.Unfold(kernel_size=3, padding=1)

    def forward(self, x):
        n,c,h,w = x.shape
        unfold_x = self.unfold(x).view(n,-1,h,w)
        return unfold_x

if __name__ == "__main__":
    input_tensor = torch.zeros((1,16,100,100))
    demo = Demo()
    out = demo(input_tensor)
    torch.onnx.export(demo, input_tensor, "debug.onnx", verbose=True,
                        input_names=['data'],
                        opset_version=11,
                        # do_constant_folding=True,
                        dynamic_axes={'data':{0:'batch', 2:'width', 3:'height'},
                        })

Expected behavior

File "/home/godricly/python36/lib/python3.6/site-packages/torch/onnx/symbolic_registry.py", line 91, in get_registered_op
    return _registry[(domain, version)][opname]
KeyError: 'im2col'

Environment

Collecting environment information...
PyTorch version: 1.4.0.dev20191103
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
CMake version: version 3.15.3

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 10.1.243
GPU models and configuration: GPU 0: GeForce GTX 1080
Nvidia driver version: 430.50
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.3

Versions of relevant libraries:
[pip3] numpy==1.17.2
[pip3] torch==1.4.0.dev20191103
[pip3] torchvision==0.4.2
[conda] Could not collect

cc @houseroad @spandantiwari @lara-hdr @BowenBao @neginraoof

@mruberry mruberry added the module: onnx Related to torch.onnx label Nov 13, 2019
@mruberry
Copy link
Collaborator

@houseroad

@mruberry mruberry added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module feature A request for a proper, new feature. labels Nov 13, 2019
@spandantiwari
Copy link

@Godricly - there's at least partial support for unfold that went in with this PR #24970. Full support is on the backlog, but we haven't got a chance to get to it yet.
Could you share if you are using im2col in a real model? It will help us prioritize.

@Godricly
Copy link
Author

It is used in CARAFE: Content-Aware ReAssembly of FEatures to extract local patches.

@isagastiberri
Copy link

isagastiberri commented Dec 2, 2019

I've also run into this same problem:

RuntimeError: ONNX export failed: Couldn't export Python operator Im2Col

I would like to export SiamMask to ONNX. Is there any way to do it in the meantime?

@Godricly
Copy link
Author

Godricly commented Dec 6, 2019

@spandantiwari Can you make sure that demo code works? Thx

@neginraoof
Copy link
Contributor

PR #30972 addresses this issue.

@GOBish
Copy link

GOBish commented Jul 12, 2020

@isagastiberri were you able to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A request for a proper, new feature. module: onnx Related to torch.onnx triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

6 participants