Skip to content

TypeError: expected Tensor as element 1 in argument 0, but got int when converting from swin to onnx #935

@ducky777

Description

@ducky777

Thanks for your bug report. We appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.
  3. The bug has not been fixed in the latest version.

Describe the bug

Error when converting swin to onnx

Reproduction

can be reproduced in the following colab notebook
https://colab.research.google.com/drive/1_uf5cFgQNohxP48dztI1qmcSVa4KQ6rz?usp=sharing

wget https://download.openmmlab.com/mmdetection/v2.0/swin/mask_rcnn_swin-t-p4-w7_fpn_fp16_ms-crop-3x_coco/mask_rcnn_swin-t-p4-w7_fpn_fp16_ms-crop-3x_coco_20210908_165006-90a4008c.pth

python tools/deploy.py \
    ./mmdeploy/configs/mmdet/instance-seg/instance-seg_onnxruntime_static.py \
    ./mmdetection/configs/swin/mask_rcnn_swin-t-p4-w7_fpn_fp16_ms-crop-3x_coco.py \
    ./mask_rcnn_swin-t-p4-w7_fpn_fp16_ms-crop-3x_coco_20210908_165006-90a4008c.pth \
    ./mmdetection/demo/demo.jpg \
    --work-dir ./outputs \
    --device cuda:0 \
    --show
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    No changes made

Environment

  1. Please run python tools/check_env.py to collect necessary environment information and paste it here.
    2022-08-21 14:55:13,190 - mmdeploy - INFO -

2022-08-21 14:55:13,190 - mmdeploy - INFO - Environmental information
2022-08-21 14:55:13,518 - mmdeploy - INFO - sys.platform: linux
2022-08-21 14:55:13,519 - mmdeploy - INFO - Python: 3.7.13 (default, Apr 24 2022, 01:04:09) [GCC 7.5.0]
2022-08-21 14:55:13,519 - mmdeploy - INFO - CUDA available: True
2022-08-21 14:55:13,519 - mmdeploy - INFO - GPU 0: Tesla P100-PCIE-16GB
2022-08-21 14:55:13,519 - mmdeploy - INFO - CUDA_HOME: /usr/local/cuda
2022-08-21 14:55:13,519 - mmdeploy - INFO - NVCC: Cuda compilation tools, release 11.1, V11.1.105
2022-08-21 14:55:13,519 - mmdeploy - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
2022-08-21 14:55:13,519 - mmdeploy - INFO - PyTorch: 1.12.1+cu113
2022-08-21 14:55:13,519 - mmdeploy - INFO - PyTorch compiling details: PyTorch built with:

  • GCC 9.3
  • C++ Version: 201402
  • Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for Intel(R) 64 architecture applications
  • Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  • OpenMP 201511 (a.k.a. OpenMP 4.5)
  • LAPACK is enabled (usually provided by MKL)
  • NNPACK is enabled
  • CPU capability usage: AVX2
  • CUDA Runtime 11.3
  • NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  • CuDNN 8.3.2 (built against CUDA 11.5)
  • Magma 2.5.2
  • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.3.2, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.12.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,

2022-08-21 14:55:13,519 - mmdeploy - INFO - TorchVision: 0.13.1+cu113
2022-08-21 14:55:13,519 - mmdeploy - INFO - OpenCV: 4.6.0
2022-08-21 14:55:13,519 - mmdeploy - INFO - MMCV: 1.6.1
2022-08-21 14:55:13,519 - mmdeploy - INFO - MMCV Compiler: GCC 9.3
2022-08-21 14:55:13,519 - mmdeploy - INFO - MMCV CUDA Compiler: 11.3
2022-08-21 14:55:13,519 - mmdeploy - INFO - MMDeploy: 0.7.0+1f8d889
2022-08-21 14:55:13,519 - mmdeploy - INFO -

2022-08-21 14:55:13,519 - mmdeploy - INFO - Backend information
2022-08-21 14:55:14,184 - mmdeploy - INFO - onnxruntime: 1.8.1 ops_is_avaliable : False
2022-08-21 14:55:14,187 - mmdeploy - INFO - tensorrt: None ops_is_avaliable : False
2022-08-21 14:55:14,213 - mmdeploy - INFO - ncnn: None ops_is_avaliable : False
2022-08-21 14:55:14,214 - mmdeploy - INFO - pplnn_is_avaliable: False
2022-08-21 14:55:14,216 - mmdeploy - INFO - openvino_is_avaliable: False
2022-08-21 14:55:14,240 - mmdeploy - INFO - snpe_is_available: False
2022-08-21 14:55:14,241 - mmdeploy - INFO -

2022-08-21 14:55:14,241 - mmdeploy - INFO - Codebase information
2022-08-21 14:55:14,242 - mmdeploy - INFO - mmdet: 2.25.1
2022-08-21 14:55:14,242 - mmdeploy - INFO - mmseg: None
2022-08-21 14:55:14,242 - mmdeploy - INFO - mmcls: None
2022-08-21 14:55:14,242 - mmdeploy - INFO - mmocr: None
2022-08-21 14:55:14,243 - mmdeploy - INFO - mmedit: None
2022-08-21 14:55:14,243 - mmdeploy - INFO - mmdet3d: None
2022-08-21 14:55:14,243 - mmdeploy - INFO - mmpose: None
2022-08-21 14:55:14,243 - mmdeploy - INFO - mmrotate: None

  1. You may add addition that may be helpful for locating the problem, such as
    Run on colab

Error traceback

  File "/content/mmdetection/mmdet/models/backbones/swin.py", line 210, in forward
    img_mask[:, h, w, :] = cnt
  File "/content/mmdeploy/mmdeploy/core/rewriters/rewriter_utils.py", line 379, in wrapper
    return self.func(self, *args, **kwargs)
  File "/content/mmdeploy/mmdeploy/pytorch/functions/tensor_setitem.py", line 62, in tensor__setitem__default
    out = torch.cat(cat_list, dim=i)
TypeError: expected Tensor as element 1 in argument 0, but got **int**

Bug fix

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions