Returns: a context where all variables will be created as local.
(enable=True)
| 49 | |
| 50 | @contextmanager |
| 51 | def override_to_local_variable(enable=True): |
| 52 | """ |
| 53 | Returns: |
| 54 | a context where all variables will be created as local. |
| 55 | """ |
| 56 | if enable: |
| 57 | |
| 58 | def custom_getter(getter, name, *args, **kwargs): |
| 59 | _replace_global_by_local(kwargs) |
| 60 | return getter(name, *args, **kwargs) |
| 61 | |
| 62 | with custom_getter_scope(custom_getter): |
| 63 | yield |
| 64 | else: |
| 65 | yield |
| 66 | |
| 67 | |
| 68 | # https://github.com/tensorflow/benchmarks/blob/48cbef14a592e02a14beee8e9aef3ad22cadaed1/scripts/tf_cnn_benchmarks/variable_mgr_util.py#L192-L218 |
no test coverage detected