create_compressed_retrain_model

Applicability

Product

Supported

Atlas 350 Accelerator Card

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

Atlas A3 training product/Atlas A3 inference product

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

Atlas A2 training product/Atlas A2 inference product

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

Atlas 200I/500 A2 inference product

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

Atlas inference product

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

Atlas training product

  • 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. 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.

Prototype

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

Parameters

Parameter

Input/Output

Description

graph

Input

tf.Graph to be sparsified.

A tf.Graph.

config_defination

Input

Path of the simplified static compression combination configuration file.

Compression combination configuration file input by the user, which specifies the compression configuration of each layer in the tf.Graph.

The simplified configuration file compressed.cfg is generated based on the retrain_config_tf.proto file. The *.proto file is stored in /amct_tensorflow/proto/ under the AMCT installation directory.

For details about the parameters in the *.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 (including the file name) of the sparsity and quantization factor record file to be recorded.

A string.

Returns

Returns a list of operator variables inserted for compression combination. The data type is list. The element type in the list is tf.Variable.

Restrictions

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

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')

Flush files:

  • A graph inserted with sparsity and quantization operators.
  • A record file that records sparsity information and quantization factors.