Problem with quantization of GRU model

Hii TensorFlow community,

After a long search for my problem, any solution fund won’t work for me. I hope that you can help me to overcome this problem so I can continue my project.

The problem is while doing post-training integer quantization of a GRU model, it gives me the following error :

ValueError: Failed to parse the model: pybind11::init(): factory function returned nullptr.
I use the following code for quantization :

converter = tf.lite.TFLiteConverter.from_saved_model(GRUMODEL_TF)
converter.optimizations = [tf.lite.Optimize.DEFAULT]

def representative_dataset_gen():
for sample in XX_data:
sample = np.expand_dims(sample.astype(np.float32), axis=0)
yield [sample]

Set the optimization flag.

converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.int8
converter.inference_output_type = tf.int8
converter.representative_dataset = repr_data_gen
model_tflite = converter.convert()

open(GRUMODEL_TFLITE, “wb”).write(model_tflite)