Convert ops to a list of `tf.Operation`. Args: tops: can be an iterable of `tf.Operation`, a `tf.Graph` or a single operation. check_graph: if `True` check if all the operations belong to the same graph. allow_graph: if `False` a `tf.Graph` cannot be converted. ignore_ts: if
(tops, check_graph=True, allow_graph=True, ignore_ts=False)
| 195 | |
| 196 | |
| 197 | def make_list_of_op(tops, check_graph=True, allow_graph=True, ignore_ts=False): |
| 198 | """Convert ops to a list of `tf.Operation`. |
| 199 | |
| 200 | Args: |
| 201 | tops: can be an iterable of `tf.Operation`, a `tf.Graph` or a single |
| 202 | operation. |
| 203 | check_graph: if `True` check if all the operations belong to the same graph. |
| 204 | allow_graph: if `False` a `tf.Graph` cannot be converted. |
| 205 | ignore_ts: if True, silently ignore `tf.Tensor`. |
| 206 | Returns: |
| 207 | A newly created list of `tf.Operation`. |
| 208 | Raises: |
| 209 | TypeError: if tops cannot be converted to a list of `tf.Operation` or, |
| 210 | if `check_graph` is `True`, if all the ops do not belong to the |
| 211 | same graph. |
| 212 | """ |
| 213 | if isinstance(tops, ops.Graph): |
| 214 | if allow_graph: |
| 215 | return tops.get_operations() |
| 216 | else: |
| 217 | raise TypeError("allow_graph is False: cannot convert a tf.Graph.") |
| 218 | else: |
| 219 | if not is_iterable(tops): |
| 220 | tops = [tops] |
| 221 | if not tops: |
| 222 | return [] |
| 223 | if check_graph: |
| 224 | check_types = None if ignore_ts else ops.Operation |
| 225 | get_unique_graph(tops, check_types=check_types) |
| 226 | return [op for op in tops if isinstance(op, ops.Operation)] |
| 227 | |
| 228 | |
| 229 | def _get_inputs(op, only_differentiable): |
no test coverage detected