Skip to content

Commit

Permalink
Reverted backend aware quantization API (#2501)
Browse files Browse the repository at this point in the history
Signed-off-by: Chetan Gulecha <[email protected]>
  • Loading branch information
quic-cgulecha authored Oct 18, 2023
1 parent f664d16 commit 3e2494c
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions TrainingExtensions/torch/src/python/aimet_torch/quantsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ def __init__(self, model: torch.nn.Module, dummy_input: Union[torch.Tensor, Tupl
quant_scheme: Union[str, QuantScheme] = QuantScheme.post_training_tf_enhanced,
rounding_mode: str = 'nearest', default_output_bw: int = 8, default_param_bw: int = 8,
in_place: bool = False, config_file: str = None,
default_data_type: QuantizationDataType = QuantizationDataType.int,
master_opdef_file: str = None, backend_opdef_files: List[str] = None):
default_data_type: QuantizationDataType = QuantizationDataType.int):
"""
Constructor for QuantizationSimModel.
Expand All @@ -163,10 +162,6 @@ def __init__(self, model: torch.nn.Module, dummy_input: Union[torch.Tensor, Tupl
Possible options are QuantizationDataType.int and QuantizationDataType.float.
Note that the mode default_data_type=QuantizationDataType.float is only supported with
default_output_bw=16 and default_param_bw=16
:param master_opdef_file: Path to xml file for master ops definition
:param backend_opdef_files: List of paths to xml file for backend ops definition
The bitwidth, datatype applied in case of no matching found
will be taken according to the order of xml provided
"""
# Perform sanity checks on inputs
validate_quantsim_inputs(quant_scheme, rounding_mode, default_output_bw, default_param_bw,
Expand Down Expand Up @@ -217,18 +212,8 @@ def __init__(self, model: torch.nn.Module, dummy_input: Union[torch.Tensor, Tupl

# pylint: disable=protected-access
self._hw_version = quantsim_configurator._get_hw_version()

if master_opdef_file is not None and backend_opdef_files is not None:
try:
from aimet_common.backend_aware_quantsim_utility import populate_backend_info, QuantsimInfo
quantsim_info = QuantsimInfo(self._default_output_bw, self._default_param_bw, default_data_type)
self._supported_kernels = populate_backend_info(self.model, quantsim_configurator.get_module_names(),
master_opdef_file, backend_opdef_files, quantsim_info)
except ImportError:
raise ImportError('Modules for backend aware quantization not found.')
else:
self._supported_kernels = quantsim_configurator.get_supported_kernels()
self._validate_supported_kernels_for_quantizers(SUPPORTED_KERNELS_ACTION)
self._supported_kernels = quantsim_configurator.get_supported_kernels()
self._validate_supported_kernels_for_quantizers(SUPPORTED_KERNELS_ACTION)

def get_supported_kernels(self) -> Dict:
"""
Expand Down

0 comments on commit 3e2494c

Please sign in to comment.