NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.53k stars 671 forks source link

TypeError: add_pooling(): incompatible function arguments. #719

Open borninfreedom opened 2 years ago

borninfreedom commented 2 years ago

The shape of my input images variable is torch Size ([16, 3, 416, 416]) .

When executing code model_trt=torch2trt(model,[images]), the errors will be reported as:

Traceback (most recent call last):
  File "train.py", line 382, in <module>
    fit_one_epoch(model_train, model, yolo_loss, loss_history, optimizer, epoch, epoch_step, epoch_step_val, gen, gen_val, UnFreeze_Epoch, Cuda, save_period, save_d                                                     ir)
  File "/yolov4-tiny-pytorch/utils/utils_fit.py", line 105, in fit_one_epoch
    model_trt=torch2trt(model,[images])
  File "/usr/local/lib/python3.6/dist-packages/torch2trt-0.3.0-py3.6.egg/torch2trt/torch2trt.py", line 553, in torch2trt
    outputs = module(*inputs)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/yolov4-tiny-pytorch/nets/yolo.py", line 78, in forward
    feat1, feat2 = self.backbone(x)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/yolov4-tiny-pytorch/nets/CSPdarknet53_tiny.py", line 127, in forward
    x, _    = self.resblock_body1(x)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/yolov4-tiny-pytorch/nets/CSPdarknet53_tiny.py", line 90, in forward
    x = self.maxpool(x)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/pooling.py", line 159, in forward
    self.return_indices)
  File "/usr/local/lib/python3.6/dist-packages/torch2trt-0.3.0-py3.6.egg/torch2trt/torch2trt.py", line 300, in wrapper
    converter["converter"](ctx)
  File "/usr/local/lib/python3.6/dist-packages/torch2trt-0.3.0-py3.6.egg/torch2trt/converters/max_pool2d.py", line 33, in convert_max_pool2d
    input=input_trt, type=trt.PoolingType.MAX, window_size=kernel_size)
  File "/usr/local/lib/python3.6/dist-packages/torch2trt-0.3.0-py3.6.egg/torch2trt/torch2trt.py", line 364, in wrapper
    ret = attr(*args, **kwargs)
TypeError: add_pooling(): incompatible function arguments. The following argument types are supported:
    1. (self: tensorrt.tensorrt.INetworkDefinition, input: tensorrt.tensorrt.ITensor, type: tensorrt.tensorrt.PoolingType, window_size: tensorrt.tensorrt.DimsHW) ->                                                      tensorrt.tensorrt.IPoolingLayer

Invoked with: <tensorrt.tensorrt.INetworkDefinition object at 0x7f7c5c4200a0>; kwargs: input=<tensorrt.tensorrt.ITensor object at 0x7f7dc7b595e0>, type=PoolingType.                                                     MAX, window_size=([2, 2], [2, 2])

How to solve this problem?

Linkcy97 commented 1 year ago

I have the same problems,can you fixed it

Linkcy97 commented 1 year ago

My sugession is pth to onnx to trt