Skip to content

Commit

Permalink
Fix (fx): fix fx quantize for conv->bn
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Jul 18, 2023
1 parent c1617b5 commit d906304
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/brevitas/graph/quantize_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

MAX_RESIDUAL_ITERS = 9999

BATCH_NORM = (nn.BatchNorm1d, nn.BatchNorm2d, nn.BatchNorm3d)

def inp_placeholder_handler(model, input_quantizer):
"""
Expand Down Expand Up @@ -187,6 +188,18 @@ def output_quant_handler(
user_module = get_module(model, user.target)
if hasattr(user_module, 'act_quant'):
output_quant = False
elif isinstance(user_module, BATCH_NORM):
# If the user is BatchNorm, check BN's users and potentially requentize at
# the output of BN
output_quant = False
output_quant_handler(
model,
user,
rewriters,
is_sign_preserving,
quant_identity_map,
quant_act_map,
unsigned_act_tuple)
if output_quant:
if quant_module_name is None and quant_module is None:
if is_sign_preserving and are_inputs_unsigned(
Expand Down

0 comments on commit d906304

Please sign in to comment.