示例#1
0
  def testLabelMap(self):
    with self.test_session() as sess:
      default_1 = test_ops.kernel_label()
      # pylint: disable=protected-access
      with sess.graph._kernel_label_map({"KernelLabel": "overload_1"}):
        overload_1_1 = test_ops.kernel_label()
        with sess.graph._kernel_label_map({"KernelLabel": "overload_2"}):
          overload_2 = test_ops.kernel_label()
          with sess.graph._kernel_label_map({"KernelLabel": ""}):
            default_2 = test_ops.kernel_label()
        overload_1_2 = test_ops.kernel_label()
      # pylint: enable=protected-access
      default_3 = test_ops.kernel_label()

      self.assertAllEqual(b"My label is: default", default_1.eval())
      self.assertAllEqual(b"My label is: default", default_2.eval())
      self.assertAllEqual(b"My label is: default", default_3.eval())
      self.assertAllEqual(b"My label is: overload_1", overload_1_1.eval())
      self.assertAllEqual(b"My label is: overload_1", overload_1_2.eval())
      self.assertAllEqual(b"My label is: overload_2", overload_2.eval())
示例#2
0
    def testLabelMap(self):
        with self.test_session() as sess:
            default_1 = test_ops.kernel_label()
            # pylint: disable=protected-access
            with sess.graph._kernel_label_map({"KernelLabel": "overload_1"}):
                overload_1_1 = test_ops.kernel_label()
                with sess.graph._kernel_label_map(
                    {"KernelLabel": "overload_2"}):
                    overload_2 = test_ops.kernel_label()
                    with sess.graph._kernel_label_map({"KernelLabel": ""}):
                        default_2 = test_ops.kernel_label()
                overload_1_2 = test_ops.kernel_label()
            # pylint: enable=protected-access
            default_3 = test_ops.kernel_label()

            self.assertAllEqual(b"My label is: default", default_1.eval())
            self.assertAllEqual(b"My label is: default", default_2.eval())
            self.assertAllEqual(b"My label is: default", default_3.eval())
            self.assertAllEqual(b"My label is: overload_1",
                                overload_1_1.eval())
            self.assertAllEqual(b"My label is: overload_1",
                                overload_1_2.eval())
            self.assertAllEqual(b"My label is: overload_2", overload_2.eval())
示例#3
0
 def testNoLabel(self):
   with self.test_session():
     self.assertAllEqual(b"My label is: default",
                         test_ops.kernel_label().eval())
示例#4
0
 def testNoLabel(self):
     with self.test_session():
         self.assertAllEqual(b"My label is: default",
                             test_ops.kernel_label().eval())