yamle.quantization.quantizer module#

class yamle.quantization.quantizer.BaseQuantizer(activation_bits, weight_bits)[source]#

Bases: ABC

This is the base class for all quantization methods.

The quantizer’s call method will be used to quantize the model.

Parameters:
  • activation_bits (int) – The number of bits to use for the activation.

  • weight_bits (int) – The number of bits to use for the weight.

abstract prepare(*args, **kwargs)[source]#

This method is used to prepare the model for quantization.

Return type:

None

abstract get_qconfig()[source]#

This method is used to get the quantization configuration.

Return type:

Any

cleanup(*args, **kwargs)[source]#

This method is used to clean up the model after quantization.

Return type:

None

save_original_model(method)[source]#

This method is used to create a copy of the original model.

Return type:

None

save_quantized_model(method)[source]#

This method is used to save the quantized model.

Return type:

None

recover(method)[source]#

This method is used to recover the original model.

Return type:

None

static add_specific_args(parent_parser)[source]#

This method is used to add the pruner specific arguments to the parent parser.

Return type:

ArgumentParser

replace_layers_for_quantization(model)[source]#

This function takes a model and replaces any special layers with their quantizable counterparts. e.g. Add -> FloatFunctional.add

Return type:

None

class yamle.quantization.quantizer.DummyQuantizer(activation_bits, weight_bits)[source]#

Bases: BaseQuantizer

This is a dummy quantizer that does not perform any quantization.

prepare()[source]#

This method is used to prepare the model for quantization.

Return type:

None

get_qconfig()[source]#

This method is used to get the quantization configuration.

Return type:

None