How to get the intermediate output from torchscript ?
It is possible to do any python things you want like store intermediate values, and even attach a debugger by using torch.jit.ignore
to create a Python entrypoint in the middle of a Torchscript function. To get an intermediate variable into Python, just make a function with the decorator @torch.jit.ignore
and pass the intermediate value into said function.
Docs:
https://pytorch.org/docs/stable/generated/torch.jit.ignore.html#torch.jit.ignore