pytorch_nndct.SparsePruner - 3.5 English

Vitis AI User Guide (UG1414)

Document ID
UG1414
Release Date
2023-09-28
Version
3.5 English

This API has the following methods:

  • __init__(model, inputs)
    model
    A torch.nn.Module object to prune.
    inputs
    A single or a list of torch. Tensor used as inputs for model inference. It does not need to be real data. It can be a randomly generated tensor of the same shape and data type as real data.
  • sparse_model(w_sparsity=0.5, a_sparsity=0, block_size=16,excludes=None)
    w_sparsity
    One of ['0', '0.5', '0.75']. A float of weight sparsity of Convolution and Fully Connected layers. By default, the w_sparsity is set to 0.5.
    a_sparsity
    One of ['0', '0.5']. A float of sparsity of activations. Here, the activations represent the input feature map of the sparse layer. By default, a_sparsity is set to 0. If a_sparsity is 0.5, w_sparsity must be 0.75.
    block_size
    The int number of consecutive elements of the input channel/channel unfolded according to the weights/activations.
    excludes
    A list of modules to be excluded from sparsity pruning.
  • export_sparse_model(model)

    Returns a network converted from sparse networks with sparse weights for inference on hardware for specified sparse computations.

    model
    The sparse model.