Torchscript module/function -> Python

After using @torch.jit.script or torch.jit.trace on a Module/function is there a way to convert the traced module/function to Python again?

1 Like

You can call it from Python but if you want to debug into it, you would have to use a switch in your code to make it use the original Python function.
You can also use the environment variable PYTORCH_JIT to disable it for the entire run of your program.

We don’t have a way to convert it back to the original python. The .code attribute for a method will give you valid python syntax that corresponds to that method implementation though.