如何在FP16模式下将pytorch模型转换为TensorRT时保持精度

如何在FP16模式下将pytorch模型转换为TensorRT时保持精度,pytorch,tensorrt,half-precision-float,Pytorch,Tensorrt,Half Precision Float,我想使用TensorRT FP16模式来加速我的pytorch模型,但精度有所下降。 我的问题是如何使用pytorch的混合精度训练,以避免转换为TensorRT FP16模型时的精度损失。 我尝试了torch.cuda.amp.autocast来训练模型,但它仍然失去了一些精度

我想使用TensorRT FP16模式来加速我的pytorch模型,但精度有所下降。 我的问题是如何使用pytorch的混合精度训练,以避免转换为TensorRT FP16模型时的精度损失。 我尝试了
torch.cuda.amp.autocast
来训练模型,但它仍然失去了一些精度