Decorator for enabling CondV2 and WhileV2 on a test. Note this enables using CondV2 and WhileV2 after running the test class's setup/teardown methods. In addition to this, callers must import the while_v2 module in order to set the _while_v2 module in control_flow_ops. Args: fn: the
(fn)
| 438 | |
| 439 | |
| 440 | def enable_control_flow_v2(fn): |
| 441 | """Decorator for enabling CondV2 and WhileV2 on a test. |
| 442 | |
| 443 | Note this enables using CondV2 and WhileV2 after running the test class's |
| 444 | setup/teardown methods. |
| 445 | |
| 446 | In addition to this, callers must import the while_v2 module in order to set |
| 447 | the _while_v2 module in control_flow_ops. |
| 448 | |
| 449 | Args: |
| 450 | fn: the function to be wrapped |
| 451 | |
| 452 | Returns: |
| 453 | The wrapped function |
| 454 | """ |
| 455 | |
| 456 | def wrapper(*args, **kwargs): |
| 457 | enable_control_flow_v2_old = control_flow_util.ENABLE_CONTROL_FLOW_V2 |
| 458 | control_flow_util.ENABLE_CONTROL_FLOW_V2 = True |
| 459 | try: |
| 460 | return fn(*args, **kwargs) |
| 461 | finally: |
| 462 | control_flow_util.ENABLE_CONTROL_FLOW_V2 = enable_control_flow_v2_old |
| 463 | |
| 464 | return wrapper |
| 465 | |
| 466 | |
| 467 | def with_control_flow_v2(cls): |
no outgoing calls
no test coverage detected