AIMET ONNX AdaRound API¶
Top-level API¶
Adaround Parameters¶
Code Example - Adaptive Rounding (AdaRound)¶
This example shows how to use AIMET to perform Adaptive Rounding (AdaRound).
Required imports
from aimet_onnx.quantsim import QuantizationSimModel
User should write this function to pass calibration data
def pass_calibration_data(model):
"""
The User of the QuantizationSimModel API is expected to write this function based on their data set.
This is not a working function and is provided only as a guideline.
:param model:
"""
Apply Adaround
def apply_adaround_example(model, dataloader):
"""
Example code to run adaround
"""
params = AdaroundParameters(data_loader=dataloader, num_batches=1, default_num_iterations=5,
forward_fn=pass_calibration_data,
forward_pass_callback_args=None)
ada_rounded_model = Adaround.apply_adaround(model, params, './', 'dummy')
sim = QuantizationSimModel(ada_rounded_model,
default_param_bw=8,
default_activation_bw=8, use_cuda=True)
sim.set_and_freeze_param_encodings('./dummy.encodings')