Esempio n. 1
0
 def set_execution_mode(self, mode):
   """Sets execution mode for current thread."""
   if mode not in (None, SYNC, ASYNC):
     raise ValueError(
         "Execution mode should be None/SYNC/ASYNC. Got %s" % mode)
   if mode is None:
     mode = SYNC
   self._eager_context.execution_mode = mode
   pywrap_tensorflow.TFE_ContextSetAsyncForThread(self._handle, mode == ASYNC)
Esempio n. 2
0
    def execution_mode(self, mode):
        """Sets execution mode for current thread."""
        if mode not in (None, SYNC, ASYNC):
            raise ValueError(
                "Execution mode should be None/SYNC/ASYNC. Got %s" % mode)
        if mode is None:
            mode = SYNC

        if self._execution_mode != mode:
            self._execution_mode = mode
            # Only set the execution mode if the context has already been initialized
            if self._context_handle is not None:
                self._eager_context.execution_mode = mode
                pywrap_tensorflow.TFE_ContextSetAsyncForThread(
                    self._handle, mode == ASYNC)