Define a model that serves as an example

Export a PyTorch model to an ONNX model

TensorRT does not support to PyTorch model directly, but fortunately we could take advantage of ONNX

Prepare some useful functions

Load an ONNX model and build an TensorRT engine