open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework
https://mmdeploy.readthedocs.io/en/latest/
Apache License 2.0
2.78k stars 637 forks source link

[Bug] ABINet to ONNX/tensorrt failed #2318

Closed smrlehdgus closed 1 year ago

smrlehdgus commented 1 year ago

Checklist

Describe the bug

Attempted to convert abinet model to onnx and tensorrt using tools/deploy.py failed.

Reproduction

  1. mim download mmocr --config abinet_20e_st-an_mj --dest ./abinet
  2. convert model 2-1. convert to onnx
    
           python tools/deploy.py \
              /home/project/mmdeploy/configs/mmocr/text-recognition/text-recognition_onnxruntime_static.py \
              downloads/abinet/abinet_20e_st-an_mj.py \
              downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth \
              demo/resources/text_recog.jpg \
              --work-dir downloads/abinet/onnx \
              --device cpu \
              --dump-info
    2-2. convert to tensorrt
      python tools/deploy.py \
          /home/project/mmdeploy/configs/mmocr/text-recognition/text-recognition_tensorrt_static-32x128.py \
          downloads/abinet/abinet_20e_st-an_mj.py \
          downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth \
          demo/resources/text_recog.jpg \
          --work-dir downloads/abinet/trt \
          --device cuda \
          --dump-info

### Environment

```Shell
08/01 08:40:09 - mmengine - INFO - 

08/01 08:40:09 - mmengine - INFO - **********Environmental information**********
08/01 08:40:10 - mmengine - INFO - sys.platform: linux
08/01 08:40:10 - mmengine - INFO - Python: 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
08/01 08:40:10 - mmengine - INFO - CUDA available: True
08/01 08:40:10 - mmengine - INFO - numpy_random_seed: 2147483648
08/01 08:40:10 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4080
08/01 08:40:10 - mmengine - INFO - CUDA_HOME: /usr/local/cuda
08/01 08:40:10 - mmengine - INFO - NVCC: Cuda compilation tools, release 12.0, V12.0.140
08/01 08:40:10 - mmengine - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
08/01 08:40:10 - mmengine - INFO - PyTorch: 1.14.0a0+44dac51
08/01 08:40:10 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.4
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.1-Product Build 20201104 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.7.0 (Git Hash N/A)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: NO AVX
  - CUDA Runtime 12.0
  - NVCC architecture flags: -gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-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;-gencode;arch=compute_90,code=sm_90;-gencode;arch=compute_90,code=compute_90
  - CuDNN 8.7  (built against CUDA 11.8)
  - Magma 2.6.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.0, CUDNN_VERSION=8.7.0, CXX_COMPILER=/usr/bin/c++, CXX_FLAGS=-fno-gnu-unique -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 -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -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_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=1.14.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=ON, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

08/01 08:40:10 - mmengine - INFO - TorchVision: 0.15.0a0
08/01 08:40:10 - mmengine - INFO - OpenCV: 4.7.0
08/01 08:40:10 - mmengine - INFO - MMEngine: 0.7.4
08/01 08:40:10 - mmengine - INFO - MMCV: 2.0.1
08/01 08:40:10 - mmengine - INFO - MMCV Compiler: GCC 9.4
08/01 08:40:10 - mmengine - INFO - MMCV CUDA Compiler: 12.0
08/01 08:40:10 - mmengine - INFO - MMDeploy: 1.1.0+
08/01 08:40:10 - mmengine - INFO - 

08/01 08:40:10 - mmengine - INFO - **********Backend information**********
08/01 08:40:10 - mmengine - INFO - tensorrt:    8.5.3.1
08/01 08:40:10 - mmengine - INFO - tensorrt custom ops: NotAvailable
08/01 08:40:10 - mmengine - INFO - ONNXRuntime: 1.15.1
08/01 08:40:10 - mmengine - INFO - ONNXRuntime-gpu:     1.15.1
08/01 08:40:10 - mmengine - INFO - ONNXRuntime custom ops:      NotAvailable
08/01 08:40:10 - mmengine - INFO - pplnn:       None
08/01 08:40:10 - mmengine - INFO - ncnn:        None
08/01 08:40:10 - mmengine - INFO - snpe:        None
08/01 08:40:10 - mmengine - INFO - openvino:    None
08/01 08:40:10 - mmengine - INFO - torchscript: 1.14.0a0+44dac51
08/01 08:40:10 - mmengine - INFO - torchscript custom ops:      NotAvailable
08/01 08:40:10 - mmengine - INFO - rknn-toolkit:        None
08/01 08:40:10 - mmengine - INFO - rknn-toolkit2:       None
08/01 08:40:10 - mmengine - INFO - ascend:      None
08/01 08:40:10 - mmengine - INFO - coreml:      None
08/01 08:40:10 - mmengine - INFO - tvm: None
08/01 08:40:10 - mmengine - INFO - vacc:        None
08/01 08:40:10 - mmengine - INFO - 

08/01 08:40:10 - mmengine - INFO - **********Codebase information**********
08/01 08:40:10 - mmengine - INFO - mmdet:       3.0.0
08/01 08:40:10 - mmengine - INFO - mmseg:       None
08/01 08:40:10 - mmengine - INFO - mmpretrain:  None
08/01 08:40:10 - mmengine - INFO - mmocr:       1.0.1
08/01 08:40:10 - mmengine - INFO - mmagic:      None
08/01 08:40:10 - mmengine - INFO - mmdet3d:     None
08/01 08:40:10 - mmengine - INFO - mmpose:      None
08/01 08:40:10 - mmengine - INFO - mmrotate:    None
08/01 08:40:10 - mmengine - INFO - mmaction:    None
08/01 08:40:10 - mmengine - INFO - mmrazor:     None

Error traceback

2-1. convert to onnx 

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 131, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1533, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/optimizer.py", line 27, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1113, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 989, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 893, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1260, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/encoder_decoder_recognizer.py", line 36, in encoder_decoder_recognizer__forward
    return self.decoder.predict(feat, out_enc, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/base_decoder.py", line 29, in base_decoder__forward
    out_dec = self(feat, out_enc, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_fuser.py", line 145, in forward_test
    raw_result = self.forward_train(feat, logits, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_fuser.py", line 114, in forward_train
    out_dec = self.language_decoder(feat, text_logits,
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/base.py", line 166, in forward
    return self.forward_test(feat, out_enc, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_language_decoder.py", line 180, in forward_test
    return self.forward_train(feat, logits, data_samples)
  File "/home/project/mmocr/mmocr/models/textrecog/decoders/abi_language_decoder.py", line 146, in forward_train
    output = m(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 816, in forward
    attn_masks = [
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 817, in <listcomp>
    copy.deepcopy(attn_masks) for _ in range(self.num_attn)
  File "/usr/lib/python3.8/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/_tensor.py", line 119, in __deepcopy__
    new_storage = self._typed_storage()._deepcopy(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 660, in _deepcopy
    return self._new_wrapped_storage(copy.deepcopy(self._untyped_storage, memo))
  File "/usr/lib/python3.8/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 98, in __deepcopy__
    new_storage = self.clone()
  File "/usr/local/lib/python3.8/dist-packages/torch/storage.py", line 112, in clone
    return type(self)(self.nbytes(), device=self.device).copy_(self)
RuntimeError: NYI: Named tensors are not supported with the tracer
08/01 08:40:53 - mmengine - ERROR - /usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.

2-2. convert to tensorrt

Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 131, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1533, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/optimizer.py", line 27, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1113, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 989, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 893, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1260, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/onnx/export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/codebase/mmocr/models/text_recognition/encoder_decoder_recognizer.py", line 35, in encoder_decoder_recognizer__forward
    out_enc = self.encoder(feat, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/encoders/abi_encoder.py", line 81, in forward
    feature = m(feature)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 830, in forward
    query = self.attentions[attn_index](
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmengine/utils/misc.py", line 395, in new_func
    output = old_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 542, in forward
    out = self.attn(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/activation.py", line 1164, in forward
    attn_output, attn_output_weights = F.multi_head_attention_forward(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py", line 5186, in multi_head_attention_forward
    attn_output, attn_output_weights = _scaled_dot_product_attention(
TypeError: _scaled_dot_product_attention__tensorrt() takes from 3 to 5 positional arguments but 7 were given
08/01 08:43:42 - mmengine - ERROR - /usr/local/lib/python3.8/dist-packages/mmdeploy-1.1.0-py3.8-linux-x86_64.egg/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
AllentDan commented 1 year ago

Fixed in #2319

smrlehdgus commented 1 year ago

Fixed in #2319

2-2. convert to tensorrt TypeError: _scaled_dot_product_attention__tensorrt() takes from 3 to 5 positional arguments but 7 were given

this error is not fixed

python tools/deploy.py \
    configs/mmocr/text-recognition/text-recognition_tensorrt_static-32x128.py \
    downloads/abinet/abinet_20e_st-an_mj.py \
    downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth \
    demo/resources/text_recog.jpg \
    --work-dir downloads/abinet/trt \
    --device cuda
08/07 11:03:41 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
08/07 11:03:42 - mmengine - WARNING - Failed to search registry with scope "mmocr" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmocr" is a correct scope, or whether the registry is initialized.
08/07 11:03:42 - mmengine - WARNING - Failed to search registry with scope "mmocr" in the "mmocr_tasks" registry tree. As a workaround, the current "mmocr_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmocr" is a correct scope, or whether the registry is initialized.
/home/project/mmocr/mmocr/models/textrecog/module_losses/ce_module_loss.py:101: UserWarning: padding does not exist in the dictionary
  warnings.warn(
/home/project/mmocr/mmocr/models/textrecog/postprocessors/base.py:60: UserWarning: padding does not exist in the dictionary
  warnings.warn(
Loads checkpoint by local backend from path: downloads/abinet/abinet_20e_st-an_mj_20221005_012617-ead8c139.pth
The model and loaded state dict do not match exactly

unexpected key in source state_dict: data_preprocessor.mean, data_preprocessor.std

08/07 11:03:42 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 
08/07 11:03:42 - mmengine - INFO - Export PyTorch model to ONNX: downloads/abinet/trt/end2end.onnx.
08/07 11:03:42 - mmengine - WARNING - Can not find mmdet.models.utils.transformer.PatchMerging.forward, function rewrite will not be applied
/home/project/mmdeploy/mmdeploy/codebase/mmocr/models/text_recognition/transformer_module.py:23: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  1.0 / torch.tensor(10000).to(device).pow(
/home/project/mmdeploy/mmdeploy/codebase/mmocr/models/text_recognition/transformer_module.py:24: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  torch.tensor(2 * (hid_j // 2) / d_hid)).to(device)
/home/project/mmdeploy/mmdeploy/codebase/mmocr/models/text_recognition/transformer_module.py:22: TracerWarning: torch.Tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  denominator = torch.Tensor([
/home/project/mmdeploy/mmdeploy/codebase/mmocr/models/text_recognition/transformer_module.py:22: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  denominator = torch.Tensor([
========== Diagnostic Run torch.onnx.export version 1.14.0a0+44dac51 ===========
verbose: False, log level: Level.ERROR
======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ========================

Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/pytorch2onnx.py", line 98, in torch2onnx
    export(
  File "/home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/onnx/export.py", line 131, in export
    torch.onnx.export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 506, in export
    _export(
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1533, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/home/project/mmdeploy/mmdeploy/apis/onnx/optimizer.py", line 27, in model_to_graph__custom_optimizer
    graph, params_dict, torch_out = ctx.origin_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 1113, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 989, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 893, in _trace_and_get_graph_from_model
    trace_graph, torch_out, inputs_states = torch.jit._get_trace_graph(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1260, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
    graph, out = torch._C._create_graph_by_tracing(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/apis/onnx/export.py", line 123, in wrapper
    return forward(*arg, **kwargs)
  File "/home/project/mmdeploy/mmdeploy/codebase/mmocr/models/text_recognition/encoder_decoder_recognizer.py", line 35, in encoder_decoder_recognizer__forward
    out_enc = self.encoder(feat, data_samples)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/project/mmocr/mmocr/models/textrecog/encoders/abi_encoder.py", line 81, in forward
    feature = m(feature)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 830, in forward
    query = self.attentions[attn_index](
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmengine/utils/misc.py", line 395, in new_func
    output = old_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mmcv/cnn/bricks/transformer.py", line 542, in forward
    out = self.attn(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1480, in _call_impl
    return forward_call(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1467, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/activation.py", line 1164, in forward
    attn_output, attn_output_weights = F.multi_head_attention_forward(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py", line 5186, in multi_head_attention_forward
    attn_output, attn_output_weights = _scaled_dot_product_attention(
TypeError: _scaled_dot_product_attention__tensorrt() takes from 3 to 5 positional arguments but 7 were given
08/07 11:03:44 - mmengine - ERROR - /home/project/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.