latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.ao.pruning.custom_from_mask
- tensorplay.ao.pruning.custom_from_mask(module: Module, name: str, mask: Tensor) Module[source]
Prune
module[name]with a pre-computed binarymask.Modifies the module in place (and also returns it) by:
adding a named buffer called
name + '_mask'holdingmask;replacing the parameter
nameby its masked version, while the original (unmasked) values are stored in a new parameter namedname + '_orig'.
- Parameters:
module – module containing the tensor to prune.
name – parameter name within
moduleon which pruning acts.mask – binary mask to be applied to the parameter.
- Returns:
The modified (i.e. pruned) module.
Examples
>>> # xdoctest: +SKIP >>> m = custom_from_mask( ... nn.Linear(5, 3), name="bias", mask=tensorplay.tensor([0, 1, 0]) ... ) >>> print(m.bias_mask) tensor([0., 1., 0.])
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

