Skip to content

Commit

Permalink
Fixed bug in TFLite TPC regarding the quantization of kernels in conv…
Browse files Browse the repository at this point in the history
…olutions and linear layers. (#1376)

Co-authored-by: liord <[email protected]>
  • Loading branch information
lior-dikstein and liord authored Mar 4, 2025
1 parent a6a4dd8 commit 2ef2589
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def generate_tpc(default_config: OpQuantizationConfig,
# If the QuantizationConfigOptions contains only one configuration,
# this configuration will be used for the operation quantization:
default_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([default_config]))
base_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([base_config]), base_config=base_config)

# In TFLite, the quantized operator specifications constraint operators quantization
# differently. For more details:
Expand Down Expand Up @@ -179,13 +180,13 @@ def generate_tpc(default_config: OpQuantizationConfig,
qc_options=default_configuration_options.clone_and_edit(
fixed_zero_point=-128, fixed_scale=1 / 256))
fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED,
qc_options=default_configuration_options.clone_and_edit_weight_attribute(
qc_options=base_configuration_options.clone_and_edit_weight_attribute(
weights_per_channel_threshold=False))
squeeze = schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE,
qc_options=default_configuration_options.clone_and_edit(
quantization_preserving=True))

conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.CONV)
conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=base_configuration_options)
relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU)
relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6)
elu = schema.OperatorsSet(name=schema.OperatorSetNames.ELU)
Expand Down

0 comments on commit 2ef2589

Please sign in to comment.