Skip to content

Commit 968dca6

Browse files
author
liord
committed
Fixed bug in TFLite TPC regarding the quantization of kernels in convolutions and linear layers.
1 parent aa2a182 commit 968dca6

File tree

1 file changed

+3
-2
lines changed
  • model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1

1 file changed

+3
-2
lines changed

model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def generate_tpc(default_config: OpQuantizationConfig,
137137
# If the QuantizationConfigOptions contains only one configuration,
138138
# this configuration will be used for the operation quantization:
139139
default_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([default_config]))
140+
base_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([base_config]), base_config=base_config)
140141

141142
# In TFLite, the quantized operator specifications constraint operators quantization
142143
# differently. For more details:
@@ -179,13 +180,13 @@ def generate_tpc(default_config: OpQuantizationConfig,
179180
qc_options=default_configuration_options.clone_and_edit(
180181
fixed_zero_point=-128, fixed_scale=1 / 256))
181182
fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED,
182-
qc_options=default_configuration_options.clone_and_edit_weight_attribute(
183+
qc_options=base_configuration_options.clone_and_edit_weight_attribute(
183184
weights_per_channel_threshold=False))
184185
squeeze = schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE,
185186
qc_options=default_configuration_options.clone_and_edit(
186187
quantization_preserving=True))
187188

188-
conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.CONV)
189+
conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=base_configuration_options)
189190
relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU)
190191
relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6)
191192
elu = schema.OperatorsSet(name=schema.OperatorSetNames.ELU)

0 commit comments

Comments
 (0)