From f1e52ba6bf5f6bc7f2ebd8dfae3403260bf1af81 Mon Sep 17 00:00:00 2001 From: Giuseppe Franco Date: Thu, 28 Sep 2023 11:52:42 +0200 Subject: [PATCH] Feat (ptq): support for float bias (#713) --- .../ptq/benchmark/ptq_benchmark_torchvision.py | 2 +- src/brevitas_examples/imagenet_classification/ptq/ptq_common.py | 2 +- .../imagenet_classification/ptq/ptq_evaluate.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/brevitas_examples/imagenet_classification/ptq/benchmark/ptq_benchmark_torchvision.py b/src/brevitas_examples/imagenet_classification/ptq/benchmark/ptq_benchmark_torchvision.py index 9a97b4794..58af032ef 100644 --- a/src/brevitas_examples/imagenet_classification/ptq/benchmark/ptq_benchmark_torchvision.py +++ b/src/brevitas_examples/imagenet_classification/ptq/benchmark/ptq_benchmark_torchvision.py @@ -50,7 +50,7 @@ 'scale_factor_type': ['float', 'po2'], # Scale factor type 'weight_bit_width': [8, 4], # Weight Bit Width 'act_bit_width': [8, 4], # Act bit width - 'bias_bit_width': [32, 16], # Bias Bit-Width for Po2 scale + 'bias_bit_width': [None, 32, 16], # Bias Bit-Width for Po2 scale 'weight_quant_granularity': ['per_tensor', 'per_channel'], # Scaling Per Output Channel 'act_quant_type': ['asym', 'sym'], # Act Quant Type 'weight_param_method': ['stats', 'mse'], # Weight Quant Type diff --git a/src/brevitas_examples/imagenet_classification/ptq/ptq_common.py b/src/brevitas_examples/imagenet_classification/ptq/ptq_common.py index f2ae5092c..42e976134 100644 --- a/src/brevitas_examples/imagenet_classification/ptq/ptq_common.py +++ b/src/brevitas_examples/imagenet_classification/ptq/ptq_common.py @@ -46,7 +46,7 @@ QUANTIZE_MAP = {'layerwise': layerwise_quantize, 'fx': quantize, 'flexml': quantize_flexml} -BIAS_BIT_WIDTH_MAP = {32: Int32Bias, 16: Int16Bias} +BIAS_BIT_WIDTH_MAP = {32: Int32Bias, 16: Int16Bias, None: None} WEIGHT_QUANT_MAP = { 'float': { diff --git a/src/brevitas_examples/imagenet_classification/ptq/ptq_evaluate.py b/src/brevitas_examples/imagenet_classification/ptq/ptq_evaluate.py index a560cd4c3..319b429b7 100644 --- a/src/brevitas_examples/imagenet_classification/ptq/ptq_evaluate.py +++ b/src/brevitas_examples/imagenet_classification/ptq/ptq_evaluate.py @@ -92,7 +92,7 @@ type=int, help='Input and weights bit width for first and last layer w/ layerwise backend (default: 8)') parser.add_argument( - '--bias-bit-width', default=32, choices=[32, 16], help='Bias bit width (default: 32)') + '--bias-bit-width', default=32, choices=[32, 16, None], help='Bias bit width (default: 32)') parser.add_argument( '--act-quant-type', default='sym',