convert_qat_model

Applicable Products

Product

Supported

Ascend 950PR&950DT products

√

Atlas A3 products

√

Atlas A2 products

√

Atlas 200I/500 A2 inference products

√

Atlas inference products

√

Atlas training products

√

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.

Type: 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.

Type: string

Default: None

save_path

Input

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

Type: string

Returns

Returns a list of output operators in a graph.

Constraints

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)

The flush file is 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.