Hi,
Please refer to below link and examples:
https://github.com/NVIDIA/TensorRT/blob/master/samples/opensource/sampleMNIST/sampleMNIST.cpp#L305
Thanks