Ejemplo n.º 1
0
  def testCheckValid(self):
    device.check_valid("/job:foo/replica:0")

    with self.assertRaisesRegex(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/replica:foo")

    with self.assertRaisesRegex(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/task:bar")

    with self.assertRaisesRegex(ValueError, "Unknown attribute: 'bar'"):
      device.check_valid("/bar:muu/baz:2")

    with self.assertRaisesRegex(ValueError, "Cannot specify multiple device"):
      device.check_valid("/cpu:0/device:GPU:2")
Ejemplo n.º 2
0
  def testCheckValid(self):
    device.check_valid("/job:foo/replica:0")

    with self.assertRaisesRegexp(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/replica:foo")

    with self.assertRaisesRegexp(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/task:bar")

    with self.assertRaisesRegexp(ValueError, "Unknown attribute: 'bar'"):
      device.check_valid("/bar:muu/baz:2")

    with self.assertRaisesRegexp(ValueError, "Cannot specify multiple device"):
      device.check_valid("/cpu:0/device:GPU:2")
Ejemplo n.º 3
0
  def testCheckValid(self):
    device.check_valid("/job:foo/replica:0")

    with self.assertRaisesRegex(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/replica:foo")

    with self.assertRaisesRegex(ValueError, "invalid literal for int"):
      device.check_valid("/job:j/task:bar")

    # Assume no one will register a device type named "barcpugpu"
    with self.assertRaisesRegex(ValueError, "Unknown attribute: 'barcpugpu'"):
      device.check_valid("/barcpugpu:muu/baz:2")

    with self.assertRaisesRegex(ValueError, "Cannot specify multiple device"):
      device.check_valid("/cpu:0/device:GPU:2")
Ejemplo n.º 4
0
    def testCheckValid(self):
        device.check_valid("/job:foo/replica:0")

        with self.assertRaises(Exception) as e:
            device.check_valid("/job:j/replica:foo")
        self.assertTrue("invalid literal for int" in str(e.exception))

        with self.assertRaises(Exception) as e:
            device.check_valid("/job:j/task:bar")
        self.assertTrue("invalid literal for int" in str(e.exception))

        with self.assertRaises(Exception) as e:
            device.check_valid("/bar:muu/baz:2")
        self.assertTrue("Unknown attribute: 'bar'" in str(e.exception))

        with self.assertRaises(Exception) as e:
            device.check_valid("/cpu:0/gpu:2")
        self.assertTrue("Cannot specify multiple device" in str(e.exception))
Ejemplo n.º 5
0
  def testCheckValid(self):
    device.check_valid("/job:foo/replica:0")

    with self.assertRaises(Exception) as e:
      device.check_valid("/job:j/replica:foo")
    self.assertTrue("invalid literal for int" in str(e.exception))

    with self.assertRaises(Exception) as e:
      device.check_valid("/job:j/task:bar")
    self.assertTrue("invalid literal for int" in str(e.exception))

    with self.assertRaises(Exception) as e:
      device.check_valid("/bar:muu/baz:2")
    self.assertTrue("Unknown attribute: 'bar'" in str(e.exception))

    with self.assertRaises(Exception) as e:
      device.check_valid("/cpu:0/gpu:2")
    self.assertTrue("Cannot specify multiple device" in str(e.exception))