Commit 0ec46f5d authored by Tong Shen's avatar Tong Shen Committed by TensorFlower Gardener
Browse files

Propagate const input of "If"/"While" node into their function bodies.

Function call node and SymbolicGradient are already handled in a different way. When we compile function call node or SymbolicGradient, if some of their XLA inputs are XLA constant values, we will generate const HLO instead of parameter HLO (we effectively remove those const inputs from XLA computation's inputs). We could use the same mechanism for "If"/"While" nodes, but graph rewriting seems like a cleaner solution. Especially for "While" node: body function needs to have same input & output args; we need to perform graph rewriting if we remove Const input args.

Reason for not doing it in graph rewriting pass: these Const input nodes might only be available after constant folding. As a result, we can only do this after GraphOptimizer. Running GraphOptimizer in graph rewriting phase might break some graphs (e.g. GraphOptimizer removes Identity nodes in outside compilation which might be used as fetched tensor).

PiperOrigin-RevId: 219360183
parent 47dd94a2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment