convert_qat_model

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Converts a TensorFlow QAT model to a quantized model that serves for both accuracy simulation on the CPU and GPU and deployment on the AI processor.

Prototype

1
convert_qat_model(pb_model, outputs, save_path, record_file=None)

Parameters

Parameter

Input/Output

Description

pb_model

Input

Path of the QAT model to be adapted.

A string.

outputs

Input

List of output operators in a graph.

A list.

record_file

Input

Path of the quantization factor record file (.txt) computed by the user.

A string.

Default: None

save_path

Input

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

A string.

Returns

Returns a list of output operators in a graph.

Restrictions

Only TensorFlow models that contain the FakeQuantWithMinMaxVars and FakeQuantWithMinMaxVarsPerchannel operators are supported. The model format is .pb.

Example

1
2
import amct_tensorflow as amct
convert_qat_model(pb_model, outputs, save_path)

Flush file: a .pb model file that can be used for accuracy simulation in the TensorFlow environment or offline inference on the AI processor.

When adaptation is performed again, the preceding files output by the API will be overwritten.