Int8 default ranges break when a bconv is followed by a normal conv.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 258
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Observed behaviour
When converting this model...
model = tf.keras.models.Sequential([
tf.keras.Input((32, 32, 3)),
lq.layers.QuantConv2D(
32,
(3, 3),
input_quantizer="ste_sign",
kernel_quantizer="ste_sign",
padding="same",
pad_values=1.0,
use_bias=False
),
tf.keras.layers.Conv2D(32, (3, 3)),
])
converted_model = lce.convert_keras_model(model, experimental_default_int8_range=(-3, 3))
...we obtain the following converted model, with extra dequantise and quantise nodes around the Conv2D:
Expected behaviour
We expect there to be no dequantise or quantise nodes in a converted model when the experimental_default_int8_range argument is used.
If the QuantConv2D is replaced by a normal Conv2D we get:
model = tf.keras.models.Sequential([
tf.keras.Input((32, 32, 3)),
tf.keras.layers.Conv2D(
32, (3, 3), padding="same", use_bias=False
),
tf.keras.layers.Conv2D(32, (3, 3)),
])
converted_model = lce.convert_keras_model(model, experimental_default_int8_range=(-3, 3))
Similarly, if the Conv2D is replaced with a QuantConv2D we get:
model = tf.keras.models.Sequential([
tf.keras.Input((32, 32, 3)),
lq.layers.QuantConv2D(
32,
(3, 3),
input_quantizer="ste_sign",
kernel_quantizer="ste_sign",
padding="same",
pad_values=1.0,
use_bias=False
),
lq.layers.QuantConv2D(
32,
(3, 3),
input_quantizer="ste_sign",
kernel_quantizer="ste_sign",
padding="same",
pad_values=1.0,
use_bias=False
),
])
converted_model = lce.convert_keras_model(model, experimental_default_int8_range=(-3, 3))
So there is something specifically going wrong with the QuantConv2D > Conv2D combination.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Sequential models shown and lce.convert_keras_model using experimental_default_int8_range=(-3, 3), then compare the converted graphs for QuantConv2D followed by Conv2D. Trace the conversion path for this layer combination; done means the mixed model no longer contains the extra dequantise and quantise nodes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, keras, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100