示例#1
0
def main(argv=None):
  """Runs all unit tests."""
  _test_util.InstallStackTraceHandler()
  return _googletest.main(argv)
示例#2
0
        command_parser.parse_memory_interval("<=2k"))
    self.assertEquals(
        command_parser.Interval(11, True, float("inf"), False),
        command_parser.parse_memory_interval(">=11"))
    self.assertEquals(command_parser.Interval(0, False, 2048, False),
                      command_parser.parse_memory_interval("<2k"))
    self.assertEquals(
        command_parser.Interval(11, False, float("inf"), False),
        command_parser.parse_memory_interval(">11"))

  def testParseMemoryIntervalsWithInvalidValueStrings(self):
    with self.assertRaisesRegexp(ValueError, "Invalid value string after >= "):
      command_parser.parse_time_interval(">=wM")
    with self.assertRaisesRegexp(ValueError, "Invalid value string after > "):
      command_parser.parse_time_interval(">YM")
    with self.assertRaisesRegexp(ValueError, "Invalid value string after <= "):
      command_parser.parse_time_interval("<= _MB")
    with self.assertRaisesRegexp(ValueError, "Invalid value string after < "):
      command_parser.parse_time_interval("<-MB")

  def testInvalidMemoryIntervalRaisesException(self):
    with self.assertRaisesRegexp(
        ValueError,
        r"Invalid interval \[5k, 3k\]. Start of interval must be less than or "
        "equal to end of interval."):
      command_parser.parse_memory_interval("[5k, 3k]")


if __name__ == "__main__":
  googletest.main()
示例#3
0
文件: test.py 项目: Dr4KK/tensorflow
def main(argv=None):
  """Runs all unit tests."""
  return _googletest.main(argv)
示例#4
0
文件: test.py 项目: kadeng/tensorflow
def main():
  """Runs all unit tests."""
  return _googletest.main()
             expected=EXAMPLE4D_EXPAND_AXIS[2],
             expected_shape=[3, None, None, None, 2]),
        dict(rt_input=EXAMPLE4D,
             ragged_rank=2,
             axis=3,
             expected=EXAMPLE4D_EXPAND_AXIS[3],
             expected_shape=[3, None, None, 1, 2]),
        dict(rt_input=EXAMPLE4D,
             ragged_rank=2,
             axis=4,
             expected=EXAMPLE4D_EXPAND_AXIS[4],
             expected_shape=[3, None, None, 2, 1]),
    ])  # pyformat: disable
    def testRaggedExpandDims(self,
                             rt_input,
                             axis,
                             expected,
                             ragged_rank=None,
                             expected_shape=None):
        rt = ragged_factory_ops.constant(rt_input, ragged_rank=ragged_rank)
        expanded = ragged_array_ops.expand_dims(rt, axis=axis)
        self.assertEqual(expanded.shape.ndims, rt.shape.ndims + 1)
        if expected_shape is not None:
            self.assertEqual(expanded.shape.as_list(), expected_shape)

        self.assertRaggedEqual(expanded, expected)


if __name__ == '__main__':
    googletest.main()
示例#6
0
def main():
    """Runs all unit tests."""
    return _googletest.main()
示例#7
0
def main(argv=None):
  """Runs all unit tests."""
  return _googletest.main(argv)
def main(argv=None):
    """Runs all unit tests."""
    _test_util.InstallStackTraceHandler()
    return _googletest.main(argv)
示例#9
0
        self.assertAllClose(self._exec(self._quantized_simple), self._desire_z,
                            0.01, 0.01)

    def testFull(self):
        self.assertAllClose(self._exec(self._quantized_full), self._desire_z,
                            0.01, 0.01)

    def testFullIsBetter(self):
        self.assertLess(
            abs(self._exec(self._quantized_full) - self._desire_z),
            abs(self._exec(self._quantized_simple) - self._desire_z))

    def testQuantize(self):
        graph, mapping = obfuscate_quantized_graph(self._quantized_full,
                                                   keeps=['c3'])
        self.assertAllClose(self._exec(self._quantized_full),
                            self._exec(graph))
        self.assertEqual({'a', 'b', 'c3'}, set(mapping.values()))

    @staticmethod
    def _exec(g):
        with Session(graph=Graph()) as session:
            with session.graph.as_default():
                import_graph_def(g.graph, name='')
            feeds = feeds_of_graph(g)
            return session.run('c3:0', feed_dict=feeds)


if __name__ == '__main__':
    main()