Library overview

Appending new nodes is the only graph editing operation allowed by the TensorFlow core library. The Graph Editor library is an attempt to allow for other kinds of editing operations, namely, rerouting and transforming.

  • rerouting is a local operation consisting in re-plugging existing tensors (the edges of the graph). Operations (the nodes) are not modified by this operation. For example, rerouting can be used to insert an operation adding noise in place of an existing tensor.
  • transforming is a global operation consisting in transforming a graph into another. By default, a transformation is a simple copy but it can be customized to achieved other goals. For instance, a graph can be transformed into another one in which noise is added after all the operations of a specific type.

Important: modifying a graph in-place with the Graph Editor must be done offline, that is, without any active sessions.

Of course new operations can be appended online but Graph Editor specific operations like rerouting and transforming can currently only be done offline.

Here is an example of what you cannot do:

  • Build a graph.
  • Create a session and run the graph.
  • Modify the graph with the Graph Editor.
  • Re-run the graph with the same previously created session.

To edit an already running graph, follow these steps:

  • Build a graph.
  • Create a session and run the graph.
  • Save the graph state and terminate the session
  • Modify the graph with the Graph Editor.
  • create a new session and restore the graph state
  • Re-run the graph with the newly created session.

Note that this procedure is very costly because a new session must be created after any modifications. Among other things, it takes time because the entire graph state must be saved and restored again.