Prunes tensor corresponding to parameter called `name` in `module` by removing every other entry in the tensors. Modifies module in place (and also return the modified module) by: 1) adding a named buffer called `name+'_mask'` corresponding to the binary mask applied to the par
(module, name)
| 369 | # also provide a simple function that instantiates the method and |
| 370 | # applies it. |
| 371 | def foobar_unstructured(module, name): |
| 372 | """Prunes tensor corresponding to parameter called `name` in `module` |
| 373 | by removing every other entry in the tensors. |
| 374 | Modifies module in place (and also return the modified module) |
| 375 | by: |
| 376 | 1) adding a named buffer called `name+'_mask'` corresponding to the |
| 377 | binary mask applied to the parameter `name` by the pruning method. |
| 378 | The parameter `name` is replaced by its pruned version, while the |
| 379 | original (unpruned) parameter is stored in a new parameter named |
| 380 | `name+'_orig'`. |
| 381 | |
| 382 | Args: |
| 383 | module (nn.Module): module containing the tensor to prune |
| 384 | name (string): parameter name within `module` on which pruning |
| 385 | will act. |
| 386 | |
| 387 | Returns: |
| 388 | module (nn.Module): modified (i.e. pruned) version of the input |
| 389 | module |
| 390 | |
| 391 | Examples: |
| 392 | >>> m = nn.Linear(3, 4) |
| 393 | >>> foobar_unstructured(m, name='bias') |
| 394 | """ |
| 395 | FooBarPruningMethod.apply(module, name) |
| 396 | return module |
| 397 | |
| 398 | ###################################################################### |
| 399 | # Let's try it out! |