Skip to content

Commit

Permalink
Add "# pragma: no cover" to Logger critical errors
Browse files Browse the repository at this point in the history
  • Loading branch information
liord committed Dec 10, 2024
1 parent 951568c commit f183073
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions model_compression_toolkit/target_platform_capabilities/schema/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ def __post_init__(self):
Logger critical if attributes are of incorrect type or have invalid values.
"""
if not isinstance(self.weights_n_bits, int) or self.weights_n_bits < 1:
Logger.critical("weights_n_bits must be a positive integer.")
Logger.critical("weights_n_bits must be a positive integer.") # pragma: no cover
if not isinstance(self.enable_weights_quantization, bool):
Logger.critical("enable_weights_quantization must be a boolean.")
Logger.critical("enable_weights_quantization must be a boolean.") # pragma: no cover
if self.lut_values_bitwidth is not None and not isinstance(self.lut_values_bitwidth, int):
Logger.critical("lut_values_bitwidth must be an integer or None.")
Logger.critical("lut_values_bitwidth must be an integer or None.") # pragma: no cover

def clone_and_edit(self, **kwargs) -> 'AttributeQuantizationConfig':
"""
Expand Down Expand Up @@ -251,27 +251,27 @@ def __post_init__(self) -> None:
# Validate `quantization_config_list`
if not isinstance(self.quantization_config_list, list):
Logger.critical(
f"'quantization_config_list' must be a list, but received: {type(self.quantization_config_list)}.")
f"'quantization_config_list' must be a list, but received: {type(self.quantization_config_list)}.") # pragma: no cover
for cfg in self.quantization_config_list:
if not isinstance(cfg, OpQuantizationConfig):
Logger.critical(
f"Each option must be an instance of 'OpQuantizationConfig', but found an object of type: {type(cfg)}.")
f"Each option must be an instance of 'OpQuantizationConfig', but found an object of type: {type(cfg)}.") # pragma: no cover

# Handle base_config
if len(self.quantization_config_list) > 1:
if self.base_config is None:
Logger.critical(f"For multiple configurations, a 'base_config' is required for non-mixed-precision optimization.")
Logger.critical(f"For multiple configurations, a 'base_config' is required for non-mixed-precision optimization.") # pragma: no cover
if not any(self.base_config == cfg for cfg in self.quantization_config_list):
Logger.critical(f"'base_config' must be included in the quantization config options list.")
Logger.critical(f"'base_config' must be included in the quantization config options list.") # pragma: no cover
elif len(self.quantization_config_list) == 1:
if self.base_config is None:
object.__setattr__(self, 'base_config', self.quantization_config_list[0])
elif self.base_config != self.quantization_config_list[0]:
Logger.critical(
"'base_config' should be the same as the sole item in 'quantization_config_list'.")
"'base_config' should be the same as the sole item in 'quantization_config_list'.") # pragma: no cover

elif len(self.quantization_config_list) == 0:
Logger.critical("'QuantizationConfigOptions' requires at least one 'OpQuantizationConfig'. The provided list is empty.")
Logger.critical("'QuantizationConfigOptions' requires at least one 'OpQuantizationConfig'. The provided list is empty.") # pragma: no cover

def clone_and_edit(self, **kwargs) -> 'QuantizationConfigOptions':
"""
Expand Down Expand Up @@ -500,9 +500,9 @@ def __post_init__(self) -> None:
# Validate the operator_groups_list
if not isinstance(self.operator_groups_list, list):
Logger.critical(
f"List of operator groups should be of type list but is {type(self.operator_groups_list)}.")
f"List of operator groups should be of type list but is {type(self.operator_groups_list)}.") # pragma: no cover
if len(self.operator_groups_list) < 2:
Logger.critical("Fusing cannot be created for a single operator.")
Logger.critical("Fusing cannot be created for a single operator.") # pragma: no cover

# if self.name is None:
# Generate the name from the operator groups if not provided
Expand Down Expand Up @@ -588,9 +588,9 @@ def __post_init__(self) -> None:
"""
# Validate `default_qco`
if not isinstance(self.default_qco, QuantizationConfigOptions):
Logger.critical("'default_qco' must be an instance of QuantizationConfigOptions.")
Logger.critical("'default_qco' must be an instance of QuantizationConfigOptions.") # pragma: no cover
if len(self.default_qco.quantization_config_list) != 1:
Logger.critical("Default QuantizationConfigOptions must contain exactly one option.")
Logger.critical("Default QuantizationConfigOptions must contain exactly one option.") # pragma: no cover

def get_config_options_by_operators_set(self, operators_set_name: str) -> QuantizationConfigOptions:
"""
Expand Down Expand Up @@ -661,9 +661,9 @@ def append_component(self, tp_model_component: TargetPlatformModelComponent) ->
self.fusing_patterns.append(tp_model_component)
elif isinstance(tp_model_component, OperatorsSetBase):
self.operator_set.append(tp_model_component)
else: # pragma: no cover
else:
Logger.critical(
f"Attempted to append an unrecognized TargetPlatformModelComponent of type: {type(tp_model_component)}.")
f"Attempted to append an unrecognized TargetPlatformModelComponent of type: {type(tp_model_component)}.") # pragma: no cover

def get_info(self) -> Dict[str, Any]:
"""
Expand All @@ -688,7 +688,7 @@ def __validate_model(self) -> None:
"""
opsets_names = [op.name for op in self.operator_set]
if len(set(opsets_names)) != len(opsets_names):
Logger.critical("Operator Sets must have unique names.")
Logger.critical("Operator Sets must have unique names.") # pragma: no cover

def __enter__(self) -> 'TargetPlatformModel':
"""
Expand Down

0 comments on commit f183073

Please sign in to comment.