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

IndexError: _Map_base::at #1

Open
minhhoangbui opened this issue Aug 15, 2021 · 2 comments
Open

IndexError: _Map_base::at #1

minhhoangbui opened this issue Aug 15, 2021 · 2 comments

Comments

@minhhoangbui
Copy link

minhhoangbui commented Aug 15, 2021

Thank you very much for your materials. I managed to use your pytorch dcn to train my model. However, when I convert this model to ONNX format, this error apprears. Do you know why?

  File "/data1/hoangbm/codes/CenterNet/src/lib/models/networks/dcnv2_torch15/dcn_v2_wrapper.py", line 105, in forward
    return DeformableConv2DFunction.apply(inputs, self.weight, self.bias, offset, mask, self.stride, self.pad, self.dilation, self.deformable_groups)
  File "/data1/hoangbm/codes/CenterNet/src/lib/models/networks/dcnv2_torch15/dcn_v2_wrapper.py", line 28, in forward
    ctx.deformable_groups
IndexError: _Map_base::at

This code produce this error

onnx.export(model, input_, '/data1/hoangbm/temp/pp_cnet15_dla.onnx', 
            keep_initializers_as_inputs=True,
            verbose=False, operator_export_type=OperatorExportTypes.ONNX)
@SsisyphusTao
Copy link
Owner

Thank you very much for your materials. I managed to use your pytorch dcn to train my model. However, when I convert this model to ONNX format, this error apprears. Do you know why?

  File "/data1/hoangbm/codes/CenterNet/src/lib/models/networks/dcnv2_torch15/dcn_v2_wrapper.py", line 105, in forward
    return DeformableConv2DFunction.apply(inputs, self.weight, self.bias, offset, mask, self.stride, self.pad, self.dilation, self.deformable_groups)
  File "/data1/hoangbm/codes/CenterNet/src/lib/models/networks/dcnv2_torch15/dcn_v2_wrapper.py", line 28, in forward
    ctx.deformable_groups
IndexError: _Map_base::at

This code produce this error

onnx.export(model, input_, '/data1/hoangbm/temp/pp_cnet15_dla.onnx', 
            keep_initializers_as_inputs=True,
            verbose=False, operator_export_type=OperatorExportTypes.ONNX)

I never used onnx to run models before, but as I as I know, if you want to use informal layers in onnx, you also need to write plugins like what i did to pytorch and tensorrt...

@zengjie617789
Copy link

zengjie617789 commented Jan 24, 2022

@SsisyphusTao , Could you explain how to implement the code of custom op in ONNX .
As far as i am concerned, it just need to register the simbolic function through g.op() after we can use the register op in pytorch. I think there are there steps for custom ops:

  1. implement custom op operations in c++/cuda ;
  2. register the custom op in python code for the need of exporting onnx model;
  3. reigister the plugin in tensorrt-onnx so that it can find the register op when exporting engine file.
    if not, can you share the idea of the process?
    thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants