Make cond_v2 + while_v2 rewrite the forward pass to output needed intermediates.
This is to enable taking the gradient of TF functions nested inside new control flow. Prior to this change, cond_v2 and while_v2 initially outputted all intermediates in case they were needed by the gradient computation. Functions, however, rewrite the forward pass with any intermediates needed by the gradient when the gradient is computed. This meant that these intermediates were not initially available for cond_v2 and while_v2 to output. By making everything output intermediates on-the-fly, intermediates are available when needed. PiperOrigin-RevId: 224222524
Loading
Please sign in to comment