pytorch_nndct.IterativePruningRunner - 2.0 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2022-01-20
Version
2.0 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 the real data.
  • ana(eval_fn, args=(), gpus=None, excludes=None, forced=False)
    eval_fn
    Callable object that takes a torch.nn.Module object as its first argument and returns the evaluation score.
    args
    A tuple of arguments that will be passed to eval_fn.
    gpus
    A tuple or list of GPU indices to be used. If not set, the default GPU will be used.
    excludes
    A list of node names or torch modules to be excluded from pruning.
    forced
    If False, skip model analysis and use cached result.
  • prune(ratio=None, threshold=None, spec_path=None, excludes=None, mode='sparse')
    ratio
    The expected percentage of MACs reduction.
    threshold
    Relative proportion of model performance loss that can be tolerated.
    spec_path
    Pre-defined pruning specification.
    excludes
    A list of node names or torch modules to be excluded from pruning.
    mode
    One of ['sparse', 'slim']. Should always using 'sparse' in iterative loop. A slim model is used for quantization-aware training.