I have a model that i want to port to tflite micro. However, when i run the code it gives me the following error:
Didn't find op for builtin opcode 'TRANSPOSE' version '2'
Failed to get registration from op code d
I assume that the transpose function is not supported in tflite micro. i also tried replacing it with a PERMUTE layer but it seems that it uses tf.transpose under the hood. Here is the part of my model where i try to traspose:
output = tf.reshape(output, (img_width // B, B, img_height // B, B), name="reshape_in")
output = Permute((2, 1, 3), name="transpose_in")(output)
is there any other way i could perform this transpose without calling tf.transpose? Maybe using reshape?
I had a similar issue when trying to run a model with TFLite's GPU delegate, which does not support the transpose operation.
One possibility is to use a combination of strided slices, tf.reshape and concat operations:
shape = (3,4,5)
a = tf.random.uniform(shape)
a_t = tf.transpose(a,(1,0,2)) # permuting first and second axis
a_concat = tf.concat([tf.reshape(a[i:i+1,:,:],(shape[1],1,shape[2])) for i in range(shape[0])],axis=1)
tf.debugging.assert_equal(a_t,a_concat)
Notes:
tf.concat because PACK/tf.stack is not available on the GPU delegatea[i:i+1,:] instead of a[i] because strided slices that remove an axis are not supported on the GPU delegateIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With