Shortcuts

torch.jit.script_if_tracing

torch.jit.script_if_tracing(fn)[source]

Compiles fn when it is first called during tracing. torch.jit.script has a non-negligible start up time when it is first called due to lazy-initializations of many compiler builtins. Therefore you should not use it in library code. However, you may want to have parts of your library work in tracing even if they use control flow. In these cases, you should use @torch.jit.script_if_tracing to substitute for torch.jit.script.

Parameters:

fn – A function to compile.

Returns:

If called during tracing, a ScriptFunction created by torch.jit.script is returned. Otherwise, the original function fn is returned.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources