tflite-micro icon indicating copy to clipboard operation
tflite-micro copied to clipboard

Failed to get restistration from op code REVERSE_V2

Open wrich5773 opened this issue 4 years ago • 9 comments

I've searched through schema_generated.h and it seems like REVERSE_V2 is given Op Code 105 and included in the BuiltInOperator enumerations, however there's no reference implementation provided in /micro/kernels. Without REVERSE_V2, I am unable to implement a simple keras bidirectional LSTM.

Are there any plans to complete the implementation of REVERSE_V2? All the other op codes are implemented (even if they're not included in AllOpsResolver) except REVERSE_V2.

Thanks!

wrich5773 avatar Oct 25 '21 20:10 wrich5773

I'm having the same issue. Any progress or is there a workaround?

spietz avatar May 27 '22 09:05 spietz

I also have this problem, how did you solve it in the end?

yyd19948 avatar Feb 28 '23 02:02 yyd19948

I also have this problem, have you guys solve the problem?

victorVoice avatar May 17 '23 10:05 victorVoice

I think you should start by following the following document porting_reference_ops.md to port reverseV2 to micro tflite and change the name of the issue to "micro: port op REVERSE_V2 from lite" .
I started on my side in local but impossible to execute the command "bazel test tensorflow/lite/kernels:all"

ox6d avatar May 25 '23 09:05 ox6d

"This issue is being marked as stale due to inactivity. Remove label or comment to prevent closure in 5 days."

github-actions[bot] avatar Jun 22 '23 10:06 github-actions[bot]

"This issue is being closed because it has been marked as stale for 5 days with no further activity."

github-actions[bot] avatar Jun 27 '23 10:06 github-actions[bot]

Hello there! Any updates on this?

narrietal avatar Feb 07 '25 16:02 narrietal

I found a solution that works for me.

It consists of splitting the bidirectional RNN layer into two unidirectional layers. Then, perform the reverse operations manually with slicing operators, which are supported in TFLM, and concatenate the outputs together.

from tensorflow.keras.layers import GRU, Concatenate

def manual_reverse(x, axis):
     return x[..., ::-1, :] if axis == 1 else x[::-1]

# Define numer of GRU cell units
units = 10
# Forward GRU
forward_gru = GRU(units, return_sequences=True)(x)
# Backward GRU (reverse input sequence manually)
reversed_input = manual_reverse(x, axis=1)
backward_gru = GRU(units, return_sequences=True)(reversed_input)
# Reverse backward output back to original order
backward_gru_reversed = manual_reverse(backward_gru, axis=1)
# Concatenate forward and backward outputs
output_frgu = Concatenate()([forward_gru, backward_gru_reversed])

narrietal avatar Mar 04 '25 14:03 narrietal

[internal: see #3052 for @rkuester implementation prior to REVERSE_V2 being added to TfLite]

ddavis-2015 avatar Mar 05 '25 00:03 ddavis-2015

Implemented with PR #3123

ddavis-2015 avatar Jul 10 '25 20:07 ddavis-2015