CUDAbevfusion export-scn.py error

Description

I used a export-scn.py from CUDABEVFuion repo(GitHub - NVIDIA-AI-IOT/Lidar_AI_Solution: A project demonstrating Lidar related AI solutions, including three GPU accelerated Lidar/camera DL networks (PointPillars, CenterPoint, BEVFusion) and the related libs (cuPCL, 3D SparseConvolution, YUV2RGB, cuOSD,).) to export lidar.backbone.xyz.onnx. Then I uesd netron to visualize the onnx. But the network is error. Please see the picture.

I modified the export-scn.py, and uesd command “python qat/export-scn.py --config bevfusion/configs/nuscenes/det/transfusion/secfpn/camera+lidar/swint_v0p075/convfuser.yaml --ckpt model/swint/epoch_30.pth --fp16 fp16 --save=qat/onnx_fp16/lidar.backbone.onnx”.
My code as follow:

import sys
from torchpack.utils.config import configs
from mmcv.cnn import fuse_conv_bn
from mmcv import Config
from mmdet3d.models import build_model
from mmdet3d.utils import recursive_eval
from mmcv.runner import wrap_fp16_model
import torch
import argparse
import os

custom functional package

import lean.funcs as funcs
import lean.exptool as exptool
import lean.quantize as quantize
from mmcv.runner import load_checkpoint,save_checkpoint
from mmdet3d.models import build_model
def load_model(cfg, checkpoint_path = None):
model = build_model(cfg.model)
if checkpoint_path != None:
checkpoint = load_checkpoint(model, checkpoint_path, map_location=“cpu”)
return model
if name == “main”:

parser = argparse.ArgumentParser()
parser.add_argument("--config", metavar="FILE", default="bevfusion/configs/nuscenes/det/transfusion/secfpn/camera+lidar/resnet50/convfuser.yaml", help="config file")
parser.add_argument("--ckpt", default="model/resnet50/bevfusion-det.pth", help="the checkpoint file to resume from")
parser.add_argument("--calibrate_batch", type=int, default=300, help="calibrate batch")
parser.add_argument("--fp16", type=str, default='fp16', help="fp")
parser.add_argument("--save", type=str, default="qat/onnx/lidar.backbone.onnx", help="output onnx")
parser.add_argument("--in-channel", type=int, default=5, help="SCN num of input channels")
parser.add_argument("--inverse", action="store_true", help="Transfer the coordinate order of the index from xyz to zyx")

args = parser.parse_args()
configs.load(args.config, recursive=True)
cfg = Config(recursive_eval(configs), filename=args.config)
# model  = torch.load(args.ckpt).module
model = load_model(cfg, checkpoint_path = args.ckpt)

inverse_indices = args.inverse
if inverse_indices:
    args.save = os.path.splitext(args.save)[0] + ".zyx.onnx"
else:
    args.save = os.path.splitext(args.save)[0] + ".xyz.onnx"

os.makedirs(os.path.dirname(args.save), exist_ok=True)
# model = torch.load(args.ckpt).module
model.eval().cuda().half()
model = model.encoders.lidar.backbone

quantize.disable_quantization(model).apply()

# Set layer attributes
for name, module in model.named_modules():
    # module.precision = "int8"
    # module.output_precision = "int8"
    module.precision = "fp16"
    module.output_precision = "fp16"    
model.conv_input.precision = "fp16"
model.conv_out.output_precision = "fp16"

voxels = torch.zeros(1, args.in_channel).cuda().half()
coors  = torch.zeros(1, 4).int().cuda()
batch_size = 1

exptool.export_onnx(model, voxels, coors, batch_size, inverse_indices, args.save)

How can I fix the problem?

Environment

**TensorRT Version8.5.1.7:
**GPU TypeRTX4090:
Nvidia Driver Version:
**CUDA Version525:
**CUDNN Version8:
**Operating System + Versionubuntu18.04:
**Python Version (if applicable)3.8.0:
TensorFlow Version (if applicable):
**PyTorch Version (if applicable)1.10:
Baremetal or Container (if container which image + tag):

Hi @332135337 ,
This forum talks about issues specific to Tensorrt, and I might not have the correct answer to your concern.
Would recommend you raising it to Issues · NVIDIA-AI-IOT/Lidar_AI_Solution · GitHub

Thanks