Walks the dataset graph to ensure all datasets come from the same graph.
(dataset)
| 2126 | |
| 2127 | |
| 2128 | def _ensure_same_dataset_graph(dataset): |
| 2129 | """Walks the dataset graph to ensure all datasets come from the same graph.""" |
| 2130 | current_graph = ops.get_default_graph() |
| 2131 | bfs_q = Queue.Queue() |
| 2132 | bfs_q.put(dataset) # pylint: disable=protected-access |
| 2133 | visited = [] |
| 2134 | while not bfs_q.empty(): |
| 2135 | ds = bfs_q.get() |
| 2136 | visited.append(ds) |
| 2137 | ds_graph = ds._graph # pylint: disable=protected-access |
| 2138 | if current_graph != ds_graph: |
| 2139 | logging.warning("The graph (" + str(current_graph) + ") of the iterator " |
| 2140 | "is different from the graph (" + str(ds_graph) + ") " |
| 2141 | "the dataset: " + str(ds._variant_tensor) + " was " # pylint: disable=protected-access |
| 2142 | "created in. If you are using the Estimator API, " |
| 2143 | "make sure that no part of the dataset returned by the " |
| 2144 | "`input_fn` function is defined outside the `input_fn` " |
| 2145 | "function. Please ensure that all datasets in the " |
| 2146 | "pipeline are created in the same graph as the iterator. " |
| 2147 | "NOTE: This warning will become an error in future " |
| 2148 | "versions of TensorFlow.") |
| 2149 | for input_ds in ds._inputs(): # pylint: disable=protected-access |
| 2150 | if input_ds not in visited: |
| 2151 | bfs_q.put(input_ds) |
| 2152 | |
| 2153 | |
| 2154 | @tf_export(v1=["data.make_one_shot_iterator"]) |