[TFLite] Cannot apply XNNPack delegate to simple model with Dense layer
if you change `img = tf.keras.layers.Input((40, 320, 1), name='img')` to `img = tf.keras.layers.Input((40, 320, 1), name='img', batch_size=1)`, mostly the issue will be gone. Without fixed batch (`batch_size=1`), there are some other nodes to handle dynamic batch size, some of them may not be delegatable.  To see the nodes I mentioned, check the tflite you have with [netron](https://github.com/lutzroeder/netron) or other visualization tools may help. Hi @christian-steinmeyer 

As @freedomtan suggests, you can specify `batch_size=1` to avoid dynamic tensors.

To add more, the `Reshape` operation after conversion is being flagged as dynamic tensor which can be observed in the [gist](https://colab.research.google.com/gist/pjpratik/fe7ed189b1d02e12fe274cb844f384a1/60762.ipynb) and it is known limitation of XNNPack for not supporting the dynamic tensors.

Thanks. Thanks for getting back to me. That did the trick!

In case anyone else comes across this. In order to change the input layer of an existing model, I've ended up using this code:
```py
old_input_layer = model.get_layer(index=0)
new_input_layer = tf.keras.layers.Input(
        batch_size=1,
        shape=old_input_layer.input.shape[1:],
        dtype=old_input_layer.dtype,
        name=old_input_layer.name,
    )
new_model = tf.keras.models.clone_model(old_model, new_input_layer)

# copy over the weights
new_model.set_weights(old_model.get_weights()) > Thanks for getting back to me. That did the trick!
> 
> In case anyone else comes across this. In order to change the input layer of an existing model, I've ended up using this code:
> 
> ```python
> old_input_layer = model.get_layer(index=0)
> new_input_layer = tf.keras.layers.Input(
>         batch_size=1,
>         shape=old_input_layer.input.shape[1:],
>         dtype=old_input_layer.dtype,
>         name=old_input_layer.name,
>     )
> new_model = tf.keras.models.clone_model(old_model, new_input_layer)
> ```

Thank you for this trick! However, using netron, I observed that the values of the kernel parameters are all changed after the convertion. And the output is totally different than the original model.

Have you encountered such problem? You might have to also copy over the weights (depends a bit on what exactly you are doing).

```python
new_model.set_weights(old_model.get_weights()) > You might have to also copy over the weights (depends a bit on what exactly you are doing).
> 
> ```python
> new_model.set_weights(old_model.get_weights())
> ```

Exactly! Thank you again! 
It is strange that the man page of tf.keras.models.clone_model does not mention that  You're welcome! It only says:
> "Model cloning is similar to calling a model on new inputs, except that it creates new layers (and thus new weights) instead of sharing the weights of the existing layers."

which leaves some room for misinterpretation, I think. Glad it's working for you now!
### 1. System information

- OS Platform and Distribution: macOS ventura 13.2.1
In python, I'm using 2.11, for the c++ side, I used the latest main and followed the instructions to [build tensorflow lite with cmake](https://www.tensorflow.org/lite/guide/build_cmake#create_a_cmake_project_which_uses_tensorflow_lite) from this commit (f8066222ad6).

### 2. Code

I have a tiny dummy model:
```py
    import tensorflow as tf

    img = tf.keras.layers.Input((40, 320, 1), name='img')
    x = tf.keras.layers.Conv2D(32, (3, 3), padding='same')(img)
    x = tf.keras.layers.Dense(24, activation='softmax', name="output")(x)
    model = tf.keras.Model(inputs=[img], outputs=x)
```
which I'm converting to tflite like so:
```py
    converter = tf.lite.TFLiteConverter.from_keras_model(model)
    converter.optimizations = [
        tf.lite.Optimize.EXPERIMENTAL_SPARSITY,  # sparsity optimization for xnnpack acceleration
    ]
    tflite_model = converter.convert()
```
before saving.
And then on the c++ side I'm trying to apply the xnnpack delegate:
```cpp
    auto m_model = TfLiteModelCreateFromFile("<PATH_TO_FILE>.tflite");
    auto m_options = TfLiteInterpreterOptionsCreate();
    TfLiteXNNPackDelegateOptions opt = TfLiteXNNPackDelegateOptionsDefault();
    auto m_xnnpack_delegate = TfLiteXNNPackDelegateCreate(&opt);
    TfLiteInterpreterOptionsAddDelegate(m_options, m_xnnpack_delegate);
    auto m_interpreter = TfLiteInterpreterCreate(m_model, m_options); // This returns nullptr and prints error messages in the console
```

However this fails with `WARNING: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#15 is a dynamic-sized tensor).`, where `tensor#15` is `model/output/Tensordot/Reshape`. For some reason, that I don't quite understand, this part of the dense layer seems to be flagged as a dynamic tensor.

Any idea, what might be the cause here?

A bit of context: I'm actually looking into pruning using the [PruneForLatencyOnXNNPack](https://www.tensorflow.org/model_optimization/api_docs/python/tfmot/sparsity/keras/PruneForLatencyOnXNNPack) approach. I've skipped the training with pruning on this dummy model for now, but I have a more complex model, that I also pruned before conversion and it, too, fails on the dense layer.  As far as I can tell, the Dense layer [should be supported](https://github.com/google/XNNPACK), so I'm really confused.
