Ejemplo n.º 1
0
 def test_run_in_eager_and_graph_modes_skip_eager_runs_graph(self):
   modes = []
   def _test(self):
     if context.executing_eagerly():
       self.skipTest("Skipping in eager mode")
     modes.append("eager" if context.executing_eagerly() else "graph")
   test_util.run_in_graph_and_eager_modes(_test)(self)
   self.assertEqual(modes, ["graph"])
Ejemplo n.º 2
0
 def test_run_in_eager_and_graph_modes_skip_eager_runs_graph(self):
   modes = []
   def _test(self):
     if context.executing_eagerly():
       self.skipTest("Skipping in eager mode")
     modes.append("eager" if context.executing_eagerly() else "graph")
   test_util.run_in_graph_and_eager_modes(_test)(self)
   self.assertEqual(modes, ["graph"])
Ejemplo n.º 3
0
  def test_run_in_graph_and_eager_modes(self):
    l = []
    def inc(self, with_brackets):
      del self  # self argument is required by run_in_graph_and_eager_modes.
      mode = "eager" if context.executing_eagerly() else "graph"
      with_brackets = "with_brackets" if with_brackets else "without_brackets"
      l.append((with_brackets, mode))

    f = test_util.run_in_graph_and_eager_modes(inc)
    f(self, with_brackets=False)
    f = test_util.run_in_graph_and_eager_modes()(inc)
    f(self, with_brackets=True)

    self.assertEqual(len(l), 4)
    self.assertEqual(set(l), {
        ("with_brackets", "graph"),
        ("with_brackets", "eager"),
        ("without_brackets", "graph"),
        ("without_brackets", "eager"),
    })
Ejemplo n.º 4
0
  def test_run_in_graph_and_eager_modes(self):
    l = []
    def inc(self, with_brackets):
      del self  # self argument is required by run_in_graph_and_eager_modes.
      mode = "eager" if context.executing_eagerly() else "graph"
      with_brackets = "with_brackets" if with_brackets else "without_brackets"
      l.append((with_brackets, mode))

    f = test_util.run_in_graph_and_eager_modes(inc)
    f(self, with_brackets=False)
    f = test_util.run_in_graph_and_eager_modes()(inc)
    f(self, with_brackets=True)

    self.assertEqual(len(l), 4)
    self.assertEqual(set(l), {
        ("with_brackets", "graph"),
        ("with_brackets", "eager"),
        ("without_brackets", "graph"),
        ("without_brackets", "eager"),
    })
Ejemplo n.º 5
0
      return
    print("Testing InceptionFwd %s", (input_size, filter_size, stride,
                                                padding))
    tf_logging.info("Testing InceptionFwd %s", (input_size, filter_size, stride,
                                                padding))
    self._AclCompareFwdValues(input_size, filter_size, [stride, stride], padding)

  return Test

if __name__ == "__main__":
  for index, (input_size_, filter_size_, output_size_, stride_,
              padding_) in enumerate(GetShrunkInceptionShapes()):
    print("testInceptionFwd_"+ str(index), input_size_, filter_size_, output_size_, stride_)
    setattr(Conv2DTest, "testInceptionFwd_" + str(index),
            test_util.run_in_graph_and_eager_modes()(
                GetInceptionFwdTest(input_size_, filter_size_, stride_,
                                    padding_)))

  # TODO(b/35359731)
  # Fwd, BckInput, and BackFilter to test that for certain input parameter
  # set, winograd nonfused algorithm will be excluded from conv autotune. If
  # in such case, winograd nonfused algorithm is added as one option of the
  # conv autotune, and cuDNN version is smaller than 7, the following tests
  # will fail.
  ishape = [1, 400, 400, 1]
  fshape = [1, 1, 1, 256]
  oshape = [1, 400, 400, 256]
  setattr(Conv2DTest, "testInceptionFwd_No_Winograd_Nonfused",
          test_util.run_in_graph_and_eager_modes()(
              GetInceptionFwdTest(ishape, fshape, 1, "SAME", gpu_only=True)))
  test.main()