save_compressed_retrain_model

Applicable Products

Product

Supported

Ascend 950PR&950DT products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Atlas A3 products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Atlas A2 products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Atlas 200I/500 A2 inference products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Atlas inference products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Atlas training products

  • QAT
    • INT8 quantization: √
  • Filter-level sparsity: √
  • 2:4 structured sparsity: x

Note: For the products marked with x, no error is reported when the API is called, but no performance gains are obtained.

Description

Applies to static compression combination. Generates the resultant model of static compression combination from the retrained model.

Prototype

1
save_compressed_retrain_model(pb_model, outputs, record_file, save_path)

Parameters

Parameter

Input/Output

Description

pb_model

Input

.pb model of the inference mode with sparsity and quantization operators.

Type: string

outputs

Input

List of output operators in a graph.

A list of strings.

record_file

Input

Path (including the file name) of the sparsity and quantization factor record file.

Type: string

save_path

Input

Path for storing the compressed model.

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

Type: string

Returns

None

Example

1
2
import amct_tensorflow as amct
amct.save_compressed_retrain_model(masked_pb_path, [operation_name_1, operation_name_2], './tmp/record.txt', './pb_model/final_model')

The flush file is a compressed model, which can be fake-quantized in the TensorFlow environment and be used for inference on the AI processor.