Returns the number of incoming edges to the given op. The edge calculation skips the edges that come from 'NextIteration' ops. NextIteration creates a cycle in the graph. We break cycles by treating this op as 'sink' and ignoring all outgoing edges from it. Args: op: Tf.Operat
(op)
| 70 | return op.type in ['NextIteration'] |
| 71 | |
| 72 | def _in_op_degree(op): |
| 73 | """Returns the number of incoming edges to the given op. |
| 74 | |
| 75 | The edge calculation skips the edges that come from 'NextIteration' ops. |
| 76 | NextIteration creates a cycle in the graph. We break cycles by treating |
| 77 | this op as 'sink' and ignoring all outgoing edges from it. |
| 78 | Args: |
| 79 | op: Tf.Operation |
| 80 | Returns: |
| 81 | the number of incoming edges. |
| 82 | """ |
| 83 | count = 0 |
| 84 | for op in op.control_inputs + [in_tensor.op for in_tensor in op.inputs]: |
| 85 | if not _is_loop_edge(op): |
| 86 | count += 1 |
| 87 | return count |
| 88 | |
| 89 | sorted_ops = [] |
| 90 | op_in_degree = {op: _in_op_degree(op) for op in g.get_operations()} |
no test coverage detected