Interactive visualization¶
Context¶
Interactive visualization displays the range (min and max values) of activations and weights for all quantized modules
in the quantization simulation QuantizationSimModel object.
Interactive visualization functionality includes:
Adjustable threshold values to flag layers for which min or max activations or weights exceed these values
Tables containing names and ranges for layers exceeding threshold values
Workflow¶
tbd
API¶
Warning
This feature is under heavy development and API changes may occur without notice in future versions.
- aimet_torch.v2.visualization_tools.visualize_stats(sim, dummy_input, save_path='./quant_stats_visualization.html')[source]¶
Produces an interactive html to view the stats collected by each quantizer during calibration
Note
The QuantizationSimModel input is expected to have been calibrated before using this function. Stats will only be plotted for activations/parameters with quantizers containing calibration statistics.
Creates an interactive visualization of min and max activations/weights of all quantized modules in the input QuantSim object. The features include:
Adjustable threshold values to flag layers whose min or max activations/weights exceed the set thresholds
Tables containing names and ranges for layers exceeding threshold values
Saves the visualization as a .html at the given path.
Example
>>> sim = aimet_torch.quantsim.QuantizationSimModel(model, dummy_input, quant_scheme=QuantScheme.post_training_tf) >>> with aimet_torch.nn.compute_encodings(sim.model): ... for data, _ in data_loader: ... sim.model(data) ... >>> visualize_stats(sim, dummy_input, save_path="./quant_stats_visualization.html")
- Parameters:
sim (
QuantizationSimModel) – Calibrated QuantizationSimModeldummy_input – Sample input used to trace the model
save_path (
str) – Path for saving the visualization. Default is “./quant_stats_visualization.html”
- Return type:
None
Warning
This feature is under heavy development and API changes may occur without notice in future versions.
- aimet_onnx.analysis.visualize_stats(sim, save_path='./quant_stats_visualization.html')[source]¶
Produces two interactive htmls to view the activation and weight encoding ranges from a calibrated QuantSim model.
Note
The QuantizationSimModel input is expected to have been calibrated before using this function. Stats will only be plotted for quantizers containing calibration statistics.
Creates interactive visualizations of min and max ranges of all quantized activations and weights in the input QuantSim object. The features include:
Adjustable threshold values to flag layers whose min or max values exceed the set thresholds
Tables containing names and ranges for layers exceeding threshold values
Two files are saved, derived from
save_pathby inserting_activationsand_weightsbefore the extension. For example, the default./quant_stats_visualization.htmlproduces./quant_stats_visualization_activations.htmland./quant_stats_visualization_weights.html.Example
>>> sim = QuantizationSimModel(model, quant_scheme=QuantScheme.post_training_tf) >>> with compute_encodings(sim): ... for input_data in data_loader: ... sim.session.run(None, input_data) ... >>> visualize_stats(sim, save_path="./quant_stats_visualization.html")
- Parameters:
sim (
QuantizationSimModel) – Calibrated QuantizationSimModelsave_path (
str) – Base path for saving the visualizations. Default is “./quant_stats_visualization.html”
- Return type:
None