Esempio n. 1
0
 def decorated(self, run_mode, *args, **kwargs):
   """A run of a single test case w/ specified run mode."""
   if run_mode == 'v1_graph':
     with context.graph_mode(), testing_utils.run_eagerly_scope(False):
       with self.test_session(use_gpu=True, config=config):
         f(self, *args, **kwargs)
   elif run_mode == 'v2_function':
     with context.eager_mode():
       with testing_utils.run_eagerly_scope(False):
         f(self, *args, **kwargs)
   elif run_mode == 'v2_eager':
     with context.eager_mode():
       with testing_utils.run_eagerly_scope(True):
         f(self, *args, **kwargs)
   else:
     return ValueError('Unknown run mode %s' % run_mode)
Esempio n. 2
0
  def context_managers(self, kwargs):
    run_eagerly = kwargs.pop('run_eagerly', None)

    if run_eagerly is not None:
      return [testing_utils.run_eagerly_scope(run_eagerly)]
    else:
      return []
Esempio n. 3
0
 def decorated(self, *args, **kwargs):
   """A run of a single test case w/ specified run mode / model type."""
   run_mode = kwargs.pop('_run_mode', None)
   model_type = kwargs.pop('_model_type', None)
   if run_mode is None:
     run_with_model_type(self, model_type, *args, **kwargs)
   elif run_mode == 'v1_graph':
     with context.graph_mode(), testing_utils.run_eagerly_scope(False):
       with self.test_session(use_gpu=True, config=config):
         run_with_model_type(self, model_type, *args, **kwargs)
   elif run_mode == 'v2_function':
     with context.eager_mode():
       with testing_utils.run_eagerly_scope(False):
         run_with_model_type(self, model_type, *args, **kwargs)
   elif run_mode == 'v2_eager':
     with context.eager_mode():
       with testing_utils.run_eagerly_scope(True):
         run_with_model_type(self, model_type, *args, **kwargs)
   else:
     return ValueError('Unknown run mode %s' % run_mode)
Esempio n. 4
0
def _v2_distributed_test(f, test_or_class, *args, **kwargs):
    with context.eager_mode():
        with testing_utils.run_eagerly_scope(False):
            with testing_utils.run_distributed_scope(True):
                f(test_or_class, *args, **kwargs)
Esempio n. 5
0
def _v1_graph_test(f, test_or_class, config, *args, **kwargs):
    with context.graph_mode(), testing_utils.run_eagerly_scope(False):
        with testing_utils.run_distributed_scope(False):
            with test_or_class.test_session(use_gpu=True, config=config):
                f(test_or_class, *args, **kwargs)
def _v2_graph_functions_test(f, test_or_class, *args, **kwargs):
    with context.eager_mode():
        with testing_utils.run_eagerly_scope(False):
            f(test_or_class, *args, **kwargs)
Esempio n. 7
0
def _v2_function_and_kerastensors_test(f, test_or_class, *args, **kwargs):
    with context.eager_mode():
        with testing_utils.run_eagerly_scope(False):
            with testing_utils.use_keras_tensors_scope(True):
                f(test_or_class, *args, **kwargs)
Esempio n. 8
0
def _v1_session_test(f, test_or_class, config, *args, **kwargs):
    with ops.get_default_graph().as_default():
        with testing_utils.run_eagerly_scope(False):
            with test_or_class.test_session(use_gpu=True, config=config):
                f(test_or_class, *args, **kwargs)
def _v2_function_test(f, test_or_class, *args, **kwargs):
    with context.eager_mode():
        with testing_utils.run_eagerly_scope(False):
            with testing_utils.experimental_run_tf_function_scope(True):
                f(test_or_class, *args, **kwargs)
Esempio n. 10
0
def _v2_eager_test(f, test_or_class, *args, **kwargs):
  with context.eager_mode():
    with testing_utils.run_eagerly_scope(True):
      f(test_or_class, *args, **kwargs)
Esempio n. 11
0
def _v2_graph_functions_test(f, test_or_class, *args, **kwargs):
  with context.eager_mode():
    with testing_utils.run_eagerly_scope(False):
      f(test_or_class, *args, **kwargs)
Esempio n. 12
0
def _v1_graph_test(f, test_or_class, config, *args, **kwargs):
  with context.graph_mode(), testing_utils.run_eagerly_scope(False):
    with test_or_class.test_session(use_gpu=True, config=config):
      f(test_or_class, *args, **kwargs)
Esempio n. 13
0
def _v1_session_test(f, test_or_class, config, *args, **kwargs):
    with context.graph_mode(), testing_utils.run_eagerly_scope(False):
        with testing_utils.experimental_run_tf_function_scope(False):
            with test_or_class.test_session(use_gpu=True, config=config):
                f(test_or_class, *args, **kwargs)