tensorrt_demos icon indicating copy to clipboard operation
tensorrt_demos copied to clipboard

How to prevent tensorrt from fusing the final layers when trying to convert tiny yolov3 to int8?

Open NIKHILDUGAR opened this issue 2 years ago • 2 comments

I used the example given in https://github.com/jkjung-avt/tensorrt_demos#demo-5-yolov4 to convert my tiny yolov3 to int8 but the issue is that when I use --verbose on onnx_to_tensorrt.py step I see that the final layers are being fused. How do I stop this from happening?

Thanks

NIKHILDUGAR avatar Apr 25 '23 08:04 NIKHILDUGAR

In general, you could do mark_output() on a specific layer to prevent TensorRT from fusing it with other layers. Reference: https://github.com/NVIDIA/TensorRT/issues/252#issuecomment-577468499

Otherwise, please be more specific about which layers in your tiny yolov3 model you're having the trouble.

jkjung-avt avatar Apr 26 '23 07:04 jkjung-avt

Hey, thanks for the quick response. I did look at the reference you provided and the problem I am having with it is that it doesn't really take layer names only tensors and the method I have seen mostly used by people is:-

last_layer = network.get_layer(network.num_layers -1) network.mark_output(last_layer.get_output(0)) Now since the output layers of tiny yolo ( in my case) or yolo are on different levels I can't correctly identify which layers to mark and how to do so correctly.

NIKHILDUGAR avatar Apr 26 '23 07:04 NIKHILDUGAR