How to initialise hooks for a model loaded using an engine file

I have an engine file created for a resnet model, i am not interested in the final outputs but the intermediate layers, how to initilase hooks for a model initialised using engine file.

Could you explain in more detail what an engine file is and how you’ve generated it, please?

Hey, so the engine file is the tensorrt version of the model. So a model path is a .pth file then that is fed to ONNX which returns a .onnx file. that is parsed to generate a tensorrt engine.
I have attached the link to the method. Link.

I’m unsure how this is related to PyTorch as it seems you are using TensorRT?

Yes, i was wondering if there was any way of doing hooks in pytorch which would be suitable to tensorrt

I’m not aware of any way to export hooks. However, if you want to always return the intermediate activations, you might want to return them in the forward in a custom module, which should then be exportable. Would this work?

Yes this would work. Thanks a lot for your help.