Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors #3523

Open
nassimus26 opened this issue Mar 2, 2025 · 0 comments

Comments

@nassimus26
Copy link

nassimus26 commented Mar 2, 2025

for this code (on colab https://colab.research.google.com/drive/1WKSgxQUSZp4Q5dHeq2HgJvjjVzxJUoqA?usp=sharing) :

cnn = tf.keras.applications.EfficientNetV2B3(
      include_top=False,
      weights='imagenet',
      #input_tensor=None,
      include_preprocessing=True,
      input_shape = (300, 300, 3),
      pooling=None,
      classes = 2
  )
def representative_dataset_gen():
    for i in range(0):
        yield []
converter = tf.lite.TFLiteConverter.from_keras_model(cnn)
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.target_spec.supported_types = [tf.int8]  # extra line missing
#converter.experimental_new_quantizer = True
#converter.experimental_new_dynamic_range_quantizer = True

#converter.inference_output_type = tf.uint8
converter.experimental_new_converter = True
#converter.experimental_mlir_quantizer = True
#converter.experimental_enable_resource_variables = False
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset_gen
tflite_model = converter.convert()
open("cnn.tflite", "wb").write(tflite_model)

And then

!edgetpu_compiler -s cnn.tflite

I am getting :

Edge TPU Compiler version 16.0.384591198
Started a compilation timeout timer of 180 seconds.
ERROR: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors.
Compilation failed: Model failed in Tflite interpreter. Please ensure model can be loaded/run in Tflite interpreter.
Compilation child process completed within timeout period.
Compilation failed! 

I am fully aware that the Coral Dev Board team release the EdgeTPU Model version (efficientnet-edgetpu-L_quant_edgetpu.tflite)

But I am not interested in the default generated EdgeTPU file, indeed I want to do something like this :

cnn = tf.keras.applications.EfficientNetV2B3(..pooling=None,..) // no pooling 
x = cnn(cnn.input)
x = layers.AveragePooling2D(pool_size=(5, 5), strides=(5, 5), padding="same")(x)
x = layers.Flatten()(x)
mdl = models.Model(inputs = cnn.input, outputs =x)

And then build the TFLite and the EdgeTPU.

Unfortunately it doesn't seems possible to do this directly on a TFLite or TFliteEdgeTPU model :
For example : how to apply the code above with this : EfficientB3 EDGE_TPU version ?

And it seems the Coral Dev Board Team has rewrite the EfficientNet model from scratch, but they don't explain why or how to import their model implemented here TPU repo

By import I mean how to replace the pretrainded tf.keras.applications.EfficientNetV2B3 with their model ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant