Skip to content

Commit 6c0aec7

Browse files
committed
basic usage
1 parent 67de214 commit 6c0aec7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

docs/usage/basic_usage.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Basic Usage
22

3-
Below are some usage examples, for more check out the [usage](usage) guide.
3+
This page demonstrates basic torch2trt usage.
44

5-
## Convert
5+
## Conversion
6+
7+
You can easily convert a PyTorch module by calling ``torch2trt`` passing example data as input, for example to convert ``alexnet`` we call
68

79
```python
810
import torch
@@ -19,9 +21,16 @@ x = torch.ones((1, 3, 224, 224)).cuda()
1921
model_trt = torch2trt(model, [x])
2022
```
2123

22-
## Execute
24+
!!! note
25+
26+
Currently with torch2trt, once the model is converted, you must use the same input shapes during
27+
execution. The exception is
28+
the batch size, which can vary up to the value specified by the ``max_batch_size`` parameter.
29+
30+
## Executution
2331

24-
We can execute the returned ``TRTModule`` just like the original PyTorch model
32+
We can execute the returned ``TRTModule`` just like the original PyTorch model. Here we
33+
execute the model and print the maximum absolute error.
2534

2635
```python
2736
y = model(x)
@@ -31,7 +40,7 @@ y_trt = model_trt(x)
3140
print(torch.max(torch.abs(y - y_trt)))
3241
```
3342

34-
## Save and load
43+
## Saving and loading
3544

3645
We can save the model as a ``state_dict``.
3746

0 commit comments

Comments
 (0)