Skip to content

Commit 22123aa

Browse files
authored
Add pt compression doc (#4299)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for the PyTorch backend alongside TensorFlow in the documentation. - Introduced a new command for compressing models using PyTorch: `dp compress -i model.pth -o model-compress.pth`. - **Documentation** - Updated the header to reflect both TensorFlow and PyTorch support. - Enhanced instructions section with clear guidance for users of both frameworks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 0c5ab07 commit 22123aa

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

doc/freeze/compress.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Compress a model {{ tensorflow_icon }}
1+
# Compress a model {{ tensorflow_icon }} {{ pytorch_icon }}
22

33
:::{note}
4-
**Supported backends**: TensorFlow {{ tensorflow_icon }}
4+
**Supported backends**: TensorFlow {{ tensorflow_icon }}, PyTorch {{ pytorch_icon }}
55
:::
66

77
## Theory
@@ -64,10 +64,25 @@ In the compressed DP model, the number of neighbors is precisely indexed at the
6464

6565
Once the frozen model is obtained from DeePMD-kit, we can get the neural network structure and its parameters (weights, biases, etc.) from the trained model, and compress it in the following way:
6666

67+
::::{tab-set}
68+
69+
:::{tab-item} TensorFlow {{ tensorflow_icon }}
70+
6771
```bash
6872
dp compress -i graph.pb -o graph-compress.pb
6973
```
7074

75+
:::
76+
77+
:::{tab-item} PyTorch {{ pytorch_icon }}
78+
79+
```bash
80+
dp compress -i model.pth -o model-compress.pth
81+
```
82+
83+
:::
84+
::::
85+
7186
where `-i` gives the original frozen model, `-o` gives the compressed model. Several other command line options can be passed to `dp compress`, which can be checked with
7287

7388
```bash

0 commit comments

Comments
 (0)