save_prune_retrain_model

Function Usage

Filter-level sparsity or 2:4 structured sparsity API. Only either of the two sparsity features can be enabled at a time.

  • Channel sparsity scenario: Generate a sparsity model that implements channel cropping based on the retrained model with the mask operator, and delete the mask operator.
  • 2:4 structured sparsity scenario: Generate the final sparsity model based on the retrained model with the 2:4 structured sparsity operator, and delete the structured sparsity operator.

Restrictions

None

Prototype

save_prune_retrain_model(pb_model, outputs, record_file, save_path)

Parameters

Option

Input/Return

Description

Restriction

pb_model

Input

PB model with the mask operator for inference. The model parameters will be restored by the retrained checkpoint file.

A string

outputs

Input

Model outputs.

A list of strings, for example, [output1,output2,...].

record_file

Input

Path and name of the file that records sparsity information.

A string

save_path

Input

Model save path.

Must include the prefix of the model name, for example, ./quantized_model/*model.

A string

Return Value

None

Outputs

Implement the sparse PB model.

Examples

1
amct.save_prune_retrain_model(masked_pb_path, [operation_name_1, operation_name_2], './tmp/record.txt', './pb_model/final_model')