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

Fix (fx): fix fx quantize for conv->bn #680

Merged
merged 2 commits into from
Jul 18, 2023
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
14 changes: 14 additions & 0 deletions src/brevitas/graph/quantize_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

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 +189,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
Loading