You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Saving models compiled with Torch-TensorRT varies slightly with the `ir` that has been used for compilation.
7
+
8
+
1) Dynamo IR
9
+
10
+
Starting with 2.1 release of Torch-TensorRT, we are switching the default compilation to be dynamo based.
11
+
The output of `ir=dynamo` compilation is a `torch.fx.GraphModule` object. There are two ways to save these objects
12
+
13
+
a) Converting to Torchscript
14
+
`torch.fx.GraphModule` objects cannot be serialized directly. Hence we use `torch.jit.trace` to convert this into a `ScriptModule` object which can be saved to disk.
15
+
The following code illustrates this approach.
16
+
17
+
.. code-block:: python
18
+
19
+
import torch
20
+
import torch_tensorrt
21
+
22
+
model = MyModel().eval().cuda()
23
+
inputs = torch.randn((1, 3, 224, 224)).cuda()
24
+
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs) # Output is a torch.fx.GraphModule
0 commit comments