Commit 58e052bd authored by Sanjoy Das's avatar Sanjoy Das Committed by TensorFlower Gardener
Browse files

Add a workaround to the cycle detection algorithm for certain unusual graphs

Our cycle detection graph has special logic to deal with frames and
NextIteration nodes and this logic does not do the right thing in certain cases.
The motivation for the current scheme is mentioned in CL 137756517 but I think
it goes wrong for graphs like:

digraph {
  Enter_0 [label="Enter('frame')"]
  Enter_1 [label="Enter('frame')"]
  Exit_0 [label="Exit"]
  Exit_1 [label="Exit"]

  SRC -> Enter_0
  Enter_0 -> Exit_0
  Exit_0 -> A
  A -> Enter_1
  Enter_1 -> Exit_1
}

for which we try to create the cycle detection graph:

digraph {
  SRC -> "FakeNode(frame)"
  "FakeNode(frame)" -> A
  A -> "FakeNode(frame)"
  "FakeNode(frame)" -> Exit
}

which, of course, is cyclic.

I'm not sure how frequent this is in practice, so for now I'll add a workaround
that avoids auto-clustering in this situation.  But we may want to eventually
implement a more principled fix, possibly based on some from of SCC detection.

PiperOrigin-RevId: 237154773
parent 10b1a5c5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment