sparsification — Model Optimizer 0.27.1 (original) (raw)

High-level API to automatically sparsify your model with various algorithms.

Functions

sparsify Sparsify a given model and search for they optimal sparsified weights.
export Export a sparse dynamic model to a regular model.

export(model)

Export a sparse dynamic model to a regular model.

This should be done after the model is fine-tuned and the weights are fixed.

Warning

After the call to export(), the sparsity mask will no longer be enforced. This means any future weight updates would destroy the sparsity pattern. If you want to continue training, call export() after training is finished.

Parameters:

model (Module) –

Return type:

Module

sparsify(model, mode, config=None)

Sparsify a given model and search for they optimal sparsified weights.

Parameters:

Return type:

_tuple_[Module, _dict_[str, _Any_]]

Returns: A sparsified model

Note

The given model is sparsified in-place. The returned model is thus a reference to the same model instance as the input model.