Tests modification of the queue post-construction.
(self)
| 66 | i = tpu_feed.InfeedQueue(tuple_shapes=[[1], [2, 3]], shard_dimensions=[1]) |
| 67 | |
| 68 | def testModification(self): |
| 69 | """Tests modification of the queue post-construction.""" |
| 70 | i = tpu_feed.InfeedQueue(number_of_tuple_elements=2) |
| 71 | i.set_tuple_types([dtypes.float32, dtypes.int32]) |
| 72 | self.assertEqual(i.tuple_types, [dtypes.float32, dtypes.int32]) |
| 73 | i.set_tuple_types([dtypes.float32, dtypes.float32]) |
| 74 | self.assertEqual(i.tuple_types, [dtypes.float32, dtypes.float32]) |
| 75 | with self.assertRaises(ValueError): |
| 76 | i.set_tuple_types([dtypes.float32]) |
| 77 | i.set_tuple_shapes([[1], [2, 3]]) |
| 78 | self.assertEqual(i.tuple_shapes, [[1], [2, 3]]) |
| 79 | i.set_tuple_shapes([[1, 2], [3, 4]]) |
| 80 | self.assertEqual(i.tuple_shapes, [[1, 2], [3, 4]]) |
| 81 | with self.assertRaises(ValueError): |
| 82 | i.set_tuple_shapes([[1, 2]]) |
| 83 | i.set_number_of_shards(2) |
| 84 | self.assertEqual(i.number_of_shards, 2) |
| 85 | i.set_number_of_shards(3) |
| 86 | self.assertEqual(i.number_of_shards, 3) |
| 87 | t1 = constant_op.constant(1, dtypes.int32, shape=[6]) |
| 88 | t2 = constant_op.constant(2.0, dtypes.float32, shape=[3, 18]) |
| 89 | i.set_configuration_from_input_tensors([t1, t2]) |
| 90 | self.assertEqual(i.tuple_shapes, [[6], [3, 18]]) |
| 91 | self.assertEqual(i.tuple_types, [dtypes.int32, dtypes.float32]) |
| 92 | i.set_configuration_from_sharded_input_tensors([[t2, t1], [t2, t1]]) |
| 93 | self.assertEqual(i.number_of_shards, 2) |
| 94 | self.assertEqual(i.tuple_shapes, [[6, 18], [12]]) |
| 95 | self.assertEqual(i.tuple_types, [dtypes.float32, dtypes.int32]) |
| 96 | i.set_shard_dimensions([1, 0]) |
| 97 | i.set_number_of_shards(3) |
| 98 | with self.assertRaises(ValueError): |
| 99 | i.set_number_of_shards(4) |
| 100 | |
| 101 | def testFreezing(self): |
| 102 | """Tests freezing the queue.""" |
nothing calls this directly
no test coverage detected