General Restrictions and APIs

General Restrictions

  • AMCT does not perform security verification of passed file paths. Ensure that the file path arguments passed to any API call are correct.
  • If the API contains a parameter that requires the user to enter the file path, the value of the parameter will be overwritten when quantization is performed again. The quantization log printed to the screen also contains a warning message indicating that the related file is overwritten.

APIs

Category

API

Function

PTQ APIs

create_quant_config

Finds all quantizable layers in a graph, creates a quantization configuration file, and writes the quantization configuration of the quantizable layers to the configuration file.

quantize_model

Quantizes a graph based on the quantization configuration file, inserts the weight and activation quantization operators, generates a quantization factor record file record_file, and returns an ONNX model ready for calibration.

save_model

Inserts operators such as AscendQuant and AscendDequant into the modified model based on the quantization factor record file record_file and generates a fake-quantized model for accuracy simulation in the ONNX Runtime environment and a model deployable on the AI processor for inference.

accuracy_based_auto_calibration

Calibrates the input model based on the input configuration file to search for a quantization configuration that meets accuracy requirements, and outputs a fake-quantized model for accuracy simulation in the ONNX Runtime environment and a model deployable on the AI processor for inference.

quantize_preprocess

Preprocesses the quantization of a graph based on the quantization configuration file, inserts the balanced quantization operators, generates a balanced quantization factor record file record_file, and returns an ONNX model ready for calibration.

Model Adaptation API

convert_qat_model

Converts an ONNX QAT model to the CANN format.