Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted backend aware quantization API #2501

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -142,8 +142,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 @@ -162,10 +161,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 @@ -216,18 +211,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
Loading