Refactor Graph._create_op_from_tf_operation to not depend on the op's inputs
Previously, importer._ProcessNewOps may have call _create_op_from_tf_operation on a newly-imported op before _create_op_from_tf_operation has been called on all its inputs. This would fail since _create_op_from_tf_operation contained calls to Operation.inputs (some indirectly, e.g. through Operation.__init__). This change factors out the _create_op_from_tf_operation and Operation.__init__ logic requiring the inputs, and creates a new Graph._add_new_tf_operations method that creates all the Operation and then applies the factored-out logic. This also removes ImportGraphDefTest.TestCyclic and replaces it with a new test, testWhileLoop. The current Python implementation of import_graph_def allows any cycle to be imported. However, with the C API enabled, while loops are the only legal cycles. This test exposes this case since not all inputs can be available when creating the Operations forming the while loop cycle (it wasn't exposed before since the C++ ImportGraphDef function create nodes in topological order, although this isn't part of the API contract). PiperOrigin-RevId: 179052930
Loading
Please sign in to comment