I was troubleshooting an issue with snpe-tflite-to-dlc crashing, where it just prints "Segmentation Fault" without anything useful. I trained a simple network and attempted to convert it.
The model below trains and is successfully converted to DLC:
model = tf.keras.Sequential([
tf.keras.layers.Input(shape=(13, 33, 1)), # Input layer with shape (1, 15, 15, 1)
#tf.keras.layers.Reshape((13,33,1)),
tf.keras.layers.Conv2D(3, (3, 3), activation='relu', padding='same', name='STG1_LCNN2'),
tf.keras.layers.Flatten(), # Flatten the input to a 1D tensor
tf.keras.layers.Dense(1, activation='sigmoid') # Single dense layer with sigmoid activation
])
Note that this input layer has shape (13, 33, 1). I then changed the input shape to (1, 13, 33, 1), and added a Reshape() layer, trained it, and tried to convert it. When I converted it, it generates the Segmentation Fault crash.
model = tf.keras.Sequential([
tf.keras.layers.Input(shape=(1, 13, 33, 1)), # Input layer with shape (1, 15, 15, 1)
tf.keras.layers.Reshape((13,33,1)),
tf.keras.layers.Conv2D(3, (3, 3), input_shape = input_shape[1:], activation='relu', padding='same', name='STG1_LCNN2'),
tf.keras.layers.Flatten(), # Flatten the input to a 1D tensor
tf.keras.layers.Dense(1, activation='sigmoid') # Single dense layer with sigmoid activation
])
In the first case, I am telling snpe-tflite-to-dlc that the input shape is (1, 13, 33, 1), even though it is really (13, 33, 1), and it doesn't seem to cause a problem. But it crashes when I try to use a reshape layer, and that is a problem. The SNPE documentation says that the Reshape() layer is supported. Am I doing something wrong, or is there a bug?
Thanks
Dear developer,
You can change the input dimension with api of tflite.
BR.
Yunxiang