(self)
| 238 | return tensor_shape.TensorShape(proto_with_symbolic_values) |
| 239 | |
| 240 | def testBatch(self): |
| 241 | test_cases = [{ |
| 242 | 'tensor': 0, |
| 243 | 'shape': tensor_shape.TensorShape([None]) |
| 244 | }, { |
| 245 | 'tensor': np.array([1, 2, 3]), |
| 246 | 'shape': tensor_shape.TensorShape([None, 3]) |
| 247 | }, { |
| 248 | 'tensor': np.array([[1, 2, 3]]), |
| 249 | 'shape': tensor_shape.TensorShape([None, 1, 3]) |
| 250 | }] |
| 251 | |
| 252 | for test_case in test_cases: |
| 253 | with ops.Graph().as_default() as g: |
| 254 | dataset = dataset_ops.Dataset.from_tensors(test_case['tensor']) |
| 255 | dataset = dataset.batch(42) |
| 256 | iterator = dataset_ops.make_one_shot_iterator(dataset) |
| 257 | get_next = iterator.get_next() |
| 258 | train_op = ops.get_collection_ref(ops.GraphKeys.TRAIN_OP) |
| 259 | train_op.append(get_next) |
| 260 | mg = meta_graph.create_meta_graph_def(graph=g) |
| 261 | grappler_item = item.Item(mg) |
| 262 | op_properties = grappler_item.GetOpProperties() |
| 263 | inferred_shape = self.as_tensor_shape( |
| 264 | op_properties['IteratorGetNext'][0].shape) |
| 265 | self.assertTrue(test_case['shape'].dims[0].is_compatible_with( |
| 266 | inferred_shape[0])) |
| 267 | self.assertEqual(test_case['shape'][1:], inferred_shape[1:]) |
| 268 | |
| 269 | def testPaddedBatch(self): |
| 270 | test_cases = [{ |
nothing calls this directly
no test coverage detected