Re: How to use Control Flow V2 ops

Skip to first unread message

Terry Heo (Woncheol)

Oct 10, 2021, 1:20:36 AM10/10/21
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.


On Sun, Oct 10, 2021 at 6:47 AM Cris <> 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 

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
To view this discussion on the web visit

Cristina Augello

Oct 10, 2021, 3:07:26 PM10/10/21
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
0 new messages