Get control_flow_ops.py ready to support de/serializing nested control flow.
authorSkye Wanderman-Milne <skyewm@google.com>
Mon, 5 Feb 2018 16:41:54 +0000 (08:41 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 5 Feb 2018 16:45:21 +0000 (08:45 -0800)
commit23851760b7b099214bdd4f1b88156d7ac2bdd2a2
treef9af338f1240339d2847ec6af26dcb9e7c13a1ec
parent95ed84d5eaa4acccb2f28bda5e5e459921568c3b
Get control_flow_ops.py ready to support de/serializing nested control flow.

With this change, ControlFlowContexts keep track of their nested
contexts (the reverse lookup as ControlFlowContext.outer_context).
This is to enable de/serializing the nested contexts of each "root"
context, and only adding the root contexts to collections. This allows
for simple deserialization of each root context by recursively
deserializing its nested contexts.

The de/serialization logic is disabled and the corresponding
control_flow.proto changes are omitted for now for forwards
compatability (i.e. three-week-old binaries must be ready to accept
the new proto format once its commited). After this is committed for
three weeks, I'll commit a follow-up change enabling the new behavior.

Design note: I chose to serialize the nested contexts, rather than the
outer contexts, because it makes it easy to deserialize the contexts
in topological order and to assign the right outer context. If we
serialized the outer contexts, there'd need to be some mechanism for
either sorting all the serialized contexts first, or deserializing all
of them and then doing another pass to assign the outer contexts.

PiperOrigin-RevId: 184533406
tensorflow/python/ops/control_flow_ops.py
tensorflow/python/ops/control_flow_ops_test.py