Skip to content

Commit 1b2397f

Browse files
committed
Suggestion to improve Basic Usage readability.
1 parent d586417 commit 1b2397f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ Google and Stanford June 2020 paper [Sparse GPU Kernels for Deep Learning](https
3030
This would be even more general, as the sparsity pattern is not constrained, and the performance looks very good, with some smart ad hoc optimizations.
3131

3232
## Basic usage
33-
You can use the BlockSparseLinear drop in replacement for torch.nn.Linear in your own model.
33+
You can use the BlockSparseLinear drop in replacement for torch.nn.Linear in your own model:
34+
35+
```python
36+
from pytorch_block_sparse import BlockSparseLinear
37+
38+
...
39+
40+
# self.fc = nn.Linear(1024, 256)
41+
self.fc = BlockSparseLinear(1024, 256, density=0.1)
42+
```
43+
44+
### Secondary usage.
3445

3546
Or you can use a utility called BlockSparseModelPatcher to modify easily an existing model before training it.(you cannot magically sparsify a trained existing model, you will need to train it from scratch)
3647

0 commit comments

Comments
 (0)