TorchScript
Created On: Sep 07, 2018 | Last Updated On: Jul 16, 2025
Warning
TorchScript is deprecated, please use torch.export instead.
Creating TorchScript Code
script
| Script the function. |
trace
| Trace a function and return an executable or |
script_if_tracing
| Compiles |
trace_module
| Trace a module and return an executable |
fork
| Create an asynchronous task executing |
wait
| Force completion of a |
ScriptModule
| Wrapper for C++ torch::jit::Module with methods, attributes, and parameters. |
ScriptFunction
| Functionally equivalent to a |
freeze
| Freeze ScriptModule, inline submodules, and attributes as constants. |
optimize_for_inference
| Perform a set of optimization passes to optimize a model for the purposes of inference. |
enable_onednn_fusion
| Enable or disables onednn JIT fusion based on the parameter |
onednn_fusion_enabled
| Return whether onednn JIT fusion is enabled. |
set_fusion_strategy
| Set the type and number of specializations that can occur during fusion. |
strict_fusion
| Give errors if not all nodes have been fused in inference, or symbolically differentiated in training. |
save
| Save an offline version of this module for use in a separate process. |
load
| Load a |
ignore
| This decorator indicates to the compiler that a function or method should be ignored and left as a Python function. |
unused
| This decorator indicates to the compiler that a function or method should be ignored and replaced with the raising of an exception. |
interface
| Decorate to annotate classes or modules of different types. |
isinstance
| Provide container type refinement in TorchScript. |
Attribute
| This method is a pass-through function that returns |
annotate
| Use to give type of |