torch.jit.script_if_tracing
-
torch.jit.script_if_tracing(fn)[source] -
Compiles
fnwhen it is first called during tracing.torch.jit.scripthas 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_tracingto substitute fortorch.jit.script.- Parameters
-
fn – A function to compile.
- Returns
-
If called during tracing, a
ScriptFunctioncreated bytorch.jit.scriptis returned. Otherwise, the original functionfnis returned.
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.jit.script_if_tracing.html