Convert ops to a list of `tf.Operation`. Args: ops: 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
(ops, check_graph=True, allow_graph=True, ignore_ts=False)
| 222 | |
| 223 | |
| 224 | def make_list_of_op(ops, check_graph=True, allow_graph=True, ignore_ts=False): |
| 225 | """Convert ops to a list of `tf.Operation`. |
| 226 | |
| 227 | Args: |
| 228 | ops: can be an iterable of `tf.Operation`, a `tf.Graph` or a single |
| 229 | operation. |
| 230 | check_graph: if `True` check if all the operations belong to the same graph. |
| 231 | allow_graph: if `False` a `tf.Graph` cannot be converted. |
| 232 | ignore_ts: if True, silently ignore `tf.Tensor`. |
| 233 | Returns: |
| 234 | A newly created list of `tf.Operation`. |
| 235 | Raises: |
| 236 | TypeError: if ops cannot be converted to a list of `tf.Operation` or, |
| 237 | if `check_graph` is `True`, if all the ops do not belong to the |
| 238 | same graph. |
| 239 | """ |
| 240 | if isinstance(ops, tf_ops.Graph): |
| 241 | if allow_graph: |
| 242 | return ops.get_operations() |
| 243 | else: |
| 244 | raise TypeError("allow_graph is False: cannot convert a tf.Graph.") |
| 245 | else: |
| 246 | if not is_iterable(ops): |
| 247 | ops = [ops] |
| 248 | if not ops: |
| 249 | return [] |
| 250 | if check_graph: |
| 251 | check_types = None if ignore_ts else tf_ops.Operation |
| 252 | get_unique_graph(ops, check_types=check_types) |
| 253 | return [op for op in ops if isinstance(op, tf_ops.Operation)] |
| 254 | |
| 255 | |
| 256 | # TODO(fkp): move this function in tf.Graph? |
nothing calls this directly
no test coverage detected