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
Hi,
does this also hold work torch.jit.trace?
Is there some pattern that is used to do logging while tracing? The only thing that comes to my mind is passing around the logs so that the logs are also an output of every module. However, I would rather directly write to a SummaryWriter in a module and keep the interface to/from the module clean.