Commit befd8234 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower Committed by TensorFlower Gardener
Browse files

Enable constant propagation across Switch(x,x) by rewriting the two outputs as...

Enable constant propagation across Switch(x,x) by rewriting the two outputs as Const(false), Const(true) with appropriate control dependencies. This is a fairly common pattern when the graph contains assertions.

By rewriting the graph a bit, we can propagate the constants down the two output branches, and just use control dependencies to trigger the selected one at runtime. For example,
         +------+
     x-->|Switch|-->a
     x-->|      |-->b
         +------+

Is rewritten as

         +------+
     x-->|Switch|-->Identity--^>Const(false)-->a
     x-->|      |-->Identity--^>Const(true)-->b
         +------+

(In practice there may be multiple consumers of each output branch.)

PiperOrigin-RevId: 186714991
parent 1dcd464f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment