Re: How to use Control Flow V2 ops

13 views
Skip to first unread message

Terry Heo (Woncheol)

unread,
Oct 10, 2021, 1:20:36 AMOct 10
to Cris, TensorFlow Lite
Hi, Cris.

You shouldn't use V1 control flow ops such as Switch, Merge.
Here is an example of using v2 control flow.

You need to update your code with v2 control flow ops.

Terry

On Sun, Oct 10, 2021 at 6:47 AM Cris <cristinaa...@gmail.com> wrote:
Hi all,

I'm trying to convert my TF model (which uses a custom layer where I use for loops, if statements and tf.Variable) to a TF Lite file, but I obtain this error:

"Failed to functionalize Control Flow V1 ops. Consider using Control Flow V2 ops instead 
tf.compat.v1.enable_control_flow_v2()."

I'm using Tensorflow 2.6.0. Where should I use tf.compat.v1.enable_control_flow_v2()? Before I try to convert with TF Lite converter or in another part of the code? I have made several attempts, but for now the error don't disappear.

--
You received this message because you are subscribed to the Google Groups "TensorFlow Lite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tflite+un...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tflite/a6f37420-21bf-429a-8042-783385f4267cn%40tensorflow.org.

Cristina Augello

unread,
Oct 10, 2021, 3:07:26 PMOct 10
to Terry Heo (Woncheol), TensorFlow Lite
Hi Terry,

Thanks for your reply. I'm just using if statements and nested for loops: do you mean I should only use tf.cond and tf.while_loop instead, respectively (sorry, I'm new to TF)?
Reply all
Reply to author
Forward
0 new messages