@@ -103,6 +103,7 @@ class QuantizationModifier(ScheduledModifier):
103
103
| freeze_bn_stats_epoch: 3.0
104
104
| model_fuse_fn_name: 'fuse_module'
105
105
| strict: True
106
+ | verbose: False
106
107
107
108
:param start_epoch: The epoch to start the modifier at
108
109
:param scheme: Default QuantizationScheme to use when enabling quantization
@@ -133,6 +134,8 @@ class QuantizationModifier(ScheduledModifier):
133
134
scheme_overrides or ignore are not found in a given module. Default True
134
135
:param end_epoch: Disabled, setting to anything other than -1 will raise an
135
136
exception. For compatibility with YAML serialization only.
137
+ :param verbose: if True, will log detailed information such as number of bits, batch
138
+ norm freezing etc. Default to False
136
139
"""
137
140
138
141
def __init__ (
@@ -148,6 +151,7 @@ def __init__(
148
151
num_calibration_steps : Optional [int ] = None ,
149
152
strict : bool = True ,
150
153
end_epoch : float = - 1.0 ,
154
+ verbose : bool = False ,
151
155
):
152
156
raise_if_torch_quantization_not_available ()
153
157
if end_epoch != - 1 :
@@ -178,7 +182,7 @@ def __init__(
178
182
self ._model_fuse_fn_name = None
179
183
180
184
self ._strict = strict
181
-
185
+ self . _verbose = verbose
182
186
self ._qat_enabled = False
183
187
self ._quantization_observer_disabled = False
184
188
self ._bn_stats_frozen = False
@@ -348,6 +352,22 @@ def strict(self, value: bool):
348
352
"""
349
353
self ._strict = value
350
354
355
+ @ModifierProp ()
356
+ def verbose (self ) -> bool :
357
+ """
358
+ :return: if True, will log detailed information such as number of bits, batch
359
+ norm freezing etc
360
+ """
361
+ return self ._verbose
362
+
363
+ @strict .setter
364
+ def verbose (self , value : bool ):
365
+ """
366
+ :params value: if True, will log detailed information such as number of bits,
367
+ batch norm freezing etc.
368
+ """
369
+ self ._verbose = value
370
+
351
371
def initialize (
352
372
self ,
353
373
module : Module ,
@@ -455,7 +475,8 @@ def _check_quantization_update(
455
475
module .apply (freeze_bn_stats )
456
476
self ._bn_stats_frozen = True
457
477
458
- self ._log_quantization (module , epoch , steps_per_epoch )
478
+ if self ._verbose :
479
+ self ._log_quantization (module , epoch , steps_per_epoch )
459
480
460
481
def _disable_quantization_observer_update_ready (self , epoch : float ) -> bool :
461
482
return (
0 commit comments