当前位置:   article > 正文

【torch加速】python onnx to tensorRT报错NotImplementedError: Converting dtype(‘float16‘) to a ctypes type_onnx notimplementederror

onnx notimplementederror

在进行torch加速时,使用了torch-onnx-torch的思路,当前阶段已成功生成tensorrt engine,但是在使用tensor RT engine进行推理的过程中遇到了该报错:NotImplementedError: Converting dtype(‘float16’) to a ctypes type


推理实现过程参考的tensorRT github项目的example中的yolov3-https://github.com/NVIDIA/TensorRT/tree/release/8.6/samples/python/yolov3_onnx

报错是出现在common文件的HostDeviceMem函数中,意思是float16类型在ctype中没有定义,解决方式见TensorRT issue #3222

I made a workaround :

 1. Initialize np.ndarray from int16 ctypes point 
 2. use arr.dtype = np.float16 to change dtype inplace.

  • 1
  • 2
  • 3
  • 4
  • 5

其意思就是既然ctype没有该类型,就在开辟内存时用int16类型来代替float16,因为他们占用的内存大小是一样的。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/57680?site
推荐阅读
相关标签
  

闽ICP备14008679号