Returns True if a default caching device should be set, otherwise False.
()
| 131 | |
| 132 | |
| 133 | def _should_cache(): |
| 134 | """Returns True if a default caching device should be set, otherwise False.""" |
| 135 | if context.executing_eagerly(): |
| 136 | return False |
| 137 | # Don't set a caching device when running in a loop, since it is possible that |
| 138 | # train steps could be wrapped in a tf.while_loop. In that scenario caching |
| 139 | # prevents forward computations in loop iterations from re-reading the |
| 140 | # updated weights. |
| 141 | ctxt = ops.get_default_graph()._get_control_flow_context() # pylint: disable=protected-access |
| 142 | return control_flow_util.GetContainingWhileContext(ctxt) is None |
| 143 | |
| 144 | |
| 145 | def _is_keras_rnn_cell(rnn_cell): |
no test coverage detected