TensorFlow 2.0 Beta is available Learn more

tff.framework.replace_called_lambda_with_block

Replaces all the called lambdas in comp with a block.

tff.framework.replace_called_lambda_with_block(comp)

Defined in python/core/impl/transformations.py.

This transform traverses comp postorder, matches the following pattern, and replaces the following computation containing a called lambda:

      Call
     /    \

Lambda(x) Comp(y)
Comp(z)

(x -> z)(y)

with the following computation containing a block:

       Block
      /     \

[x=Comp(y)] Comp(z)

let x=y in z

The functional computation b and the argument c are retained; the other computations are replaced. This transformation is used to facilitate the merging of TFF orchestration logic, in particular to remove unnecessary lambda expressions and as a stepping stone for merging Blocks together.

Args:

  • comp: The computation building block in which to perform the replacements.

Returns:

A new computation with the transformation applied or the original comp.

Raises:

  • TypeError: If types do not match.