TensorFlow is an open source platform for machine learning. When converting transposed convolutions using per-channel weight quantization the converter segfaults and crashes the Python process. We have patched the issue in GitHub commit aa0b852a4588cea4d36b74feb05d93055540b450. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
C6622D95-1C86-45C5-AB55-E6EEEA0996DF
2.7.2
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
0F9D273D-02DC-441E-AA91-EAC8DEAA4B44
2.8.1
2.8.0
cpe:2.3:a:google:tensorflow:*:*:*:*:*:*:*:*
FE4F8A81-6CC2-4F7F-9602-C170FDD926E7
2.9.1
2.9.0
cpe:2.3:a:google:tensorflow:2.10:rc0:*:*:*:*:*:*
1DBFBCE2-0A01-4575-BE45-6775ABFB8B28
cpe:2.3:a:google:tensorflow:2.10:rc1:*:*:*:*:*:*
89806CF9-E423-4CA6-A01A-8175C260CB24
cpe:2.3:a:google:tensorflow:2.10:rc2:*:*:*:*:*:*
F2B80690-A257-4E16-BD27-9AE045BC56ED
cpe:2.3:a:google:tensorflow:2.10:rc3:*:*:*:*:*:*
F335F9A4-5AB8-4E53-BC18-E01F7C653E5E
OR
When converting transposed convolutions using per-channel weight quantization the converter segfaults and crashes the Python process. Per-channel quantization is supported by TFLite Transposed convolutions:
https://github.com/tensorflow/tensorflow/blob/f87be6c7de847017c48520649e3d771e5d6b81b6/tensorflow/lite/kernels/transpose_conv.cc#L371-L380
so the converter shouldn't segfault when trying to convert such a model.

It looks like this issue has been introduced in TensorFlow 2.6 since the same model code produced a valid TFLite file in TensorFlow 2.5. This issue might also be related to #53766, but in any case the converter should never segfault.

### 1. System information

- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS / Ubuntu
- TensorFlow installation (pip package or built from source): pip package
- TensorFlow library (version, if pip package or github SHA, if built from source): 2.6, 2.7, 2.8rc0 and 2.9.0-dev20220114

### 2. Code

A minimal reproduction of the issue and a workaround is available in [this notebook](https://colab.research.google.com/drive/1IXri5HeDc9qTAtDOp-LqZyQTL8CcemGq?usp=sharing).

```python
import tensorflow as tf


class QuantConv2DTransposed(tf.keras.layers.Layer):
    def build(self, input_shape):
        self.kernel = self.add_weight("kernel", [3, 3, input_shape[-1], 24])

    def call(self, inputs):
        filters = tf.quantization.fake_quant_with_min_max_vars_per_channel(
            self.kernel, -3.0 * tf.ones([24]), 3.0 * tf.ones([24]), narrow_range=True
        )
        filters = tf.transpose(filters, (0, 1, 3, 2))
        return tf.nn.conv2d_transpose(inputs, filters, [*inputs.shape[:-1], 24], 1)


inp = tf.keras.Input(shape=(6, 8, 48), batch_size=1)
x = tf.quantization.fake_quant_with_min_max_vars(inp, -3.0, 3.0, narrow_range=True)
x = QuantConv2DTransposed()(x)
x = tf.quantization.fake_quant_with_min_max_vars(x, -3.0, 3.0, narrow_range=True)

model = tf.keras.Model(inp, x)

model.save("/tmp/testing")
converter = tf.lite.TFLiteConverter.from_saved_model("/tmp/testing")
converter.optimizations = [tf.lite.Optimize.DEFAULT]

# terminated by signal SIGSEGV (Address boundary error)
tflite_model = converter.convert()
```
TFLite Converter segfaults when trying to convert per-channel quantized transposed convolutions
This is a GitHub Issue
repo:tensorflow
owner:tensorflow
Title : TFLite Converter segfaults when trying to convert per-channel quantized transposed convolutions
Issue date:

--- start body ---
When converting transposed convolutions using per-channel weight quantization the converter segfaults and crashes the Python process. Per-channel quantization is supported by TFLite Transposed convolutions:
https://github.com/tensorflow/tensorflow/blob/f87be6c7de847017c48520649e3d771e5d6b81b6/tensorflow/lite/kernels/transpose_conv.cc#L371-L380
so the converter shouldn't segfault when trying to convert such a model.

It looks like this issue has been introduced in TensorFlow 2.6 since the same model code produced a valid TFLite file in TensorFlow 2.5. This issue might also be related to #53766, but in any case the converter should never segfault.

### 1. System information

- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS / Ubuntu
- TensorFlow installation (pip package or built from source): pip package
- TensorFlow library (version, if pip package or github SHA, if built from source): 2.6, 2.7, 2.8rc0 and 2.9.0-dev20220114

### 2. Code

A minimal reproduction of the issue and a workaround is available in [this notebook](https://colab.research.google.com/drive/1IXri5HeDc9qTAtDOp-LqZyQTL8CcemGq?usp=sharing).

```python
import tensorflow as tf


class QuantConv2DTransposed(tf.keras.layers.Layer):
    def build(self, input_shape):
        self.kernel = self.add_weight("kernel", [3, 3, input_shape[-1], 24])

    def call(self, inputs):
        filters = tf.quantization.fake_quant_with_min_max_vars_per_channel(
            self.kernel, -3.0 * tf.ones([24]), 3.0 * tf.ones([24]), narrow_range=True
        )
        filters = tf.transpose(filters, (0, 1, 3, 2))
        return tf.nn.conv2d_transpose(inputs, filters, [*inputs.shape[:-1], 24], 1)


inp = tf.keras.Input(shape=(6, 8, 48), batch_size=1)
x = tf.quantization.fake_quant_with_min_max_vars(inp, -3.0, 3.0, narrow_range=True)
x = QuantConv2DTransposed()(x)
x = tf.quantization.fake_quant_with_min_max_vars(x, -3.0, 3.0, narrow_range=True)

model = tf.keras.Model(inp, x)

model.save("/tmp/testing")
converter = tf.lite.TFLiteConverter.from_saved_model("/tmp/testing")
converter.optimizations = [tf.lite.Optimize.DEFAULT]

# terminated by signal SIGSEGV (Address boundary error)
tflite_model = converter.convert()
```
--- end body ---

comments :
--- start comments ---

--- end comments ---