Return all the `tf.Operation` within the given boundary. Args: ops: an object convertible to a list of `tf.Operation`. those ops define the set in which to perform the operation (if a `tf.Graph` is given, it will be converted to the list of all its operations). seed_ops: the o
(ops,
seed_ops,
boundary_ops=(),
inclusive=True,
control_inputs=False,
control_outputs=None,
control_ios=None)
| 330 | |
| 331 | |
| 332 | def get_within_boundary_ops(ops, |
| 333 | seed_ops, |
| 334 | boundary_ops=(), |
| 335 | inclusive=True, |
| 336 | control_inputs=False, |
| 337 | control_outputs=None, |
| 338 | control_ios=None): |
| 339 | """Return all the `tf.Operation` within the given boundary. |
| 340 | |
| 341 | Args: |
| 342 | ops: an object convertible to a list of `tf.Operation`. those ops define the |
| 343 | set in which to perform the operation (if a `tf.Graph` is given, it |
| 344 | will be converted to the list of all its operations). |
| 345 | seed_ops: the operations from which to start expanding. |
| 346 | boundary_ops: the ops forming the boundary. |
| 347 | inclusive: if `True`, the result will also include the boundary ops. |
| 348 | control_inputs: A boolean indicating whether control inputs are enabled. |
| 349 | control_outputs: An instance of `util.ControlOutputs` or `None`. If not |
| 350 | `None`, control outputs are enabled. |
| 351 | control_ios: An instance of `util.ControlOutputs` or `None`. If not |
| 352 | `None`, both control inputs and control outputs are enabled. This is |
| 353 | equivalent to set control_inputs to True and control_outputs to |
| 354 | the `util.ControlOutputs` instance. |
| 355 | Returns: |
| 356 | All the `tf.Operation` surrounding the given ops. |
| 357 | Raises: |
| 358 | TypeError: if `ops` or `seed_ops` cannot be converted to a list of |
| 359 | `tf.Operation`. |
| 360 | ValueError: if the boundary is intersecting with the seeds. |
| 361 | """ |
| 362 | control_inputs, control_outputs = check_cios(control_inputs, control_outputs, |
| 363 | control_ios) |
| 364 | ops = util.make_list_of_op(ops) |
| 365 | seed_ops = util.make_list_of_op(seed_ops, allow_graph=False) |
| 366 | boundary_ops = set(util.make_list_of_op(boundary_ops)) |
| 367 | res = set(seed_ops) |
| 368 | if boundary_ops & res: |
| 369 | raise ValueError("Boundary is intersecting with the seeds.") |
| 370 | wave = set(seed_ops) |
| 371 | while wave: |
| 372 | new_wave = set() |
| 373 | ops_io = get_ops_ios(wave, control_inputs, control_outputs) |
| 374 | for op in ops_io: |
| 375 | if op in res: |
| 376 | continue |
| 377 | if op in boundary_ops: |
| 378 | if inclusive: |
| 379 | res.add(op) |
| 380 | else: |
| 381 | new_wave.add(op) |
| 382 | res.update(new_wave) |
| 383 | wave = new_wave |
| 384 | return [op for op in ops if op in res] |
| 385 | |
| 386 | |
| 387 | def get_forward_walk_ops(seed_ops, |
nothing calls this directly
no test coverage detected