Esempio n. 1
0
 def _merge_call(self, merge_fn, *args, **kwargs):
   """Default implementation for single tower."""
   _push_per_thread_mode(  # thread-local, so not needed with multiple threads
       distribution_strategy_context._CrossTowerThreadMode(  # pylint: disable=protected-access
           self._distribution_strategy))
   try:
     return merge_fn(self._distribution_strategy, *args, **kwargs)
   finally:
     _pop_per_thread_mode()
Esempio n. 2
0
 def _merge_call(self, merge_fn, *args, **kwargs):
   """Default implementation for single tower."""
   _push_per_thread_mode(  # thread-local, so not needed with multiple threads
       distribution_strategy_context._CrossTowerThreadMode(  # pylint: disable=protected-access
           self._distribution_strategy))
   try:
     return merge_fn(self._distribution_strategy, *args, **kwargs)
   finally:
     _pop_per_thread_mode()
Esempio n. 3
0
 def __init__(self,
              distribution_strategy,
              var_creator_scope,
              var_scope=None,
              default_device=None):
   self._context = distribution_strategy_context._CrossTowerThreadMode(  # pylint: disable=protected-access
       distribution_strategy)
   self._var_creator_scope = var_creator_scope
   self._var_scope = var_scope
   if default_device:
     self._device_scope = ops.device(default_device)
   else:
     self._device_scope = None
Esempio n. 4
0
 def __init__(self,
              distribution_strategy,
              var_creator_scope,
              var_scope=None,
              default_device=None):
   self._context = distribution_strategy_context._CrossTowerThreadMode(  # pylint: disable=protected-access
       distribution_strategy)
   self._var_creator_scope = var_creator_scope
   self._var_scope = var_scope
   if default_device:
     self._device_scope = ops.device(default_device)
   else:
     self._device_scope = None