create_compressed_retrain_model

Function Usage

Applies to static compression combination. Sparsifies the input graph (via either filter-level sparsity or 2:4 structured sparsity) based on the specified compression configuration file, inserts quantization operators, and returns the modified graph.

Constraints

The compression combination configuration file must contain at least one of the following configurations: sparsity configuration or quantization configuration.

Prototype

quant_add_ops = create_compressed_retrain_model(graph, config_defination, outputs, record_file)

Command-Line Options

Option

Input/Return

Description

Restriction

graph

Input

tf.Graph to be sparsified.

A tf.Graph.

config_defination

Input

Path of the simplified configuration file for static compression combination.

User-defined compression configuration file, which is used to specify the compression configuration of each layer in the tf.Graph model.

Whether to create a simplified configuration file quant.cfg from the retrain_config_tf.proto file in /amct_tensorflow/proto/retrain_config_tf.proto in the AMCT installation path.

For details about the parameters in the retrain_config_tf.proto file and the generated simplified configuration file compressed.cfg, see Simplified QAT Configuration File.

A string

outputs

Input

Name of the model output node.

A list of strings.

record_file

Input

Path and name of the sparsity and quantization factor file to be recorded.

A string

quant_add_ops

Returns

List of operator variables inserted for combination compression.

A list of strings.

Returns

List of layer name variables for combination compression.

Outputs

  • Graph into which the sparsity and quantization operators are inserted.
  • Record file that records sparsity information and quantization factors.

Example

1
2
import amct_tensorflow as amct
amct.create_compressed_retrain_model(graph, './tmp/sample.cfg', [operation_name_1, operation_name_2], './tmp/record.txt')