Yep, this makes sense and is what I am suspecting. Thanks for the example. I was thinking if there were states inside operation that I can use to avoid doing this flagging (since with this approach, I have to reset the flag after each batch of inputs, and that might potentially make the code really messy if the training logic involves multiple different dataset.)
I think in TensorFlow, you can just make an operation group and feed input to get all the output of operations without duplicating any computation or graphs. Something like
operations_to_complete = [model.operation1, model.operation2]
val1, val2 = execute(model, operations)