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 |
|---|---|---|
Common APIs |
Sets the log levels of the messages printed to the screen and those saved in the amct_log/amct_tensorflow.log file. |
|
Provides a Python instance based on the input data of the bin type for a model to calibrate and infer the model. |
||
PTQ APIs |
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. |
|
Quantizes a graph based on the quantization configuration file, inserts the quantization operators, generates a quantization factor record file record_file, and returns the list of newly added operators. |
||
Inserts operators such as AscendQuant and AscendDequant into the original .pb model based on the quantization factor record file record_file and generates a .pb model file that serves for both accuracy simulation in the TensorFlow environment and inference deployment on the AI processor. |
||
Calibrates the input model based on the input configuration file to search for a quantization configuration that meets accuracy requirements, and outputs a model suitable for both accuracy simulation in the TensorFlow environment and inference deployment on the AI processor. |
||
Preprocesses the quantization of a graph based on the quantization configuration file (currently, only balanced quantization is supported), inserts the balanced quantization operators, and generates a balance factor record file record_file that is to be read in the subsequent quantize_model phase. |
||
QAT APIs |
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. |
|
Performs quantization on a graph based on the configuration file (config_file), inserts activation and weight fake-quantization layers, and saves the modified network to a new model file. |
||
Inserts operators such as AscendQuant and AscendDequant into the retrained model and generates a model that can be used for both accuracy simulation and inference deployment. |
||
Sparsity APIs |
Filter-level sparsity or 2:4 structured sparsity API. Only either of the two sparsity features can be enabled at a time. |
|
Filter-level sparsity or 2:4 structured sparsity API. Only either of the two sparsity features can be enabled at a time. |
||
Auto Channel Pruning Search API |
Calculates the sparsity sensitivity (affecting accuracy) and sparsity gain (affecting performance) of each channel based on the user model. Then, the search policy searches for the optimal layer-wise channel sparsity ratio based on the input to balance accuracy and performance. Finally, a configuration file is generated. |
|
Compression Combination APIs |
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. |
|
Applies to static compression combination. Generates the resultant model of static compression combination from the retrained model. |
||
Tensor Decomposition APIs |
Performs tensor decomposition on the original TensorFlow model, generating a new model file. |
|
Fine-tunes a decomposed model by decomposing the graph in the training code. |
||
Model Adaptation APIs |
Converts a TensorFlow model based on the user-defined quantization factors into a model serving for both accuracy simulation in the TensorFlow environment and inference on the AI processor. |
|
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. |