Commit 2141b78
authored
Add support for pruned models (#103)
* Add support for pruned models
According to the [pytorch documentation on
pruning](https://pytorch.org/tutorials/intermediate/pruning_tutorial.html),
the original parameter is replaced with one ending with `_orig` and
a new buffer ending with `_mask`. The mask contains 0s and 1s based on
which the correct parameters are chosen.
All instances of `param.nelements()` have been replaced by a variable
`cur_params` whose value is set based on whether it is a masked model or
not. To keep consistency with the rest of the code base, the `_orig` is
removed from the `name` variable right after the calculation of
`cur_params`.
* Add tests for pruning1 parent d9f4857 commit 2141b78
3 files changed
Lines changed: 67 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
165 | 179 | | |
166 | 180 | | |
167 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
15 | 26 | | |
16 | 27 | | |
17 | 28 | | |
| |||
116 | 127 | | |
117 | 128 | | |
118 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
119 | 143 | | |
120 | 144 | | |
121 | 145 | | |
122 | 146 | | |
123 | 147 | | |
124 | 148 | | |
125 | 149 | | |
126 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
127 | 153 | | |
128 | | - | |
| 154 | + | |
129 | 155 | | |
130 | 156 | | |
131 | 157 | | |
| |||
137 | 163 | | |
138 | 164 | | |
139 | 165 | | |
140 | | - | |
| 166 | + | |
141 | 167 | | |
142 | 168 | | |
143 | 169 | | |
| |||
153 | 179 | | |
154 | 180 | | |
155 | 181 | | |
| 182 | + | |
156 | 183 | | |
157 | 184 | | |
158 | 185 | | |
159 | 186 | | |
160 | | - | |
161 | | - | |
| 187 | + | |
162 | 188 | | |
163 | 189 | | |
164 | | - | |
| 190 | + | |
165 | 191 | | |
166 | 192 | | |
167 | | - | |
| 193 | + | |
168 | 194 | | |
169 | 195 | | |
170 | 196 | | |
| |||
0 commit comments