MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testBatch

Method testBatch

tensorflow/python/grappler/datasets_test.py:240–267  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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 = [{

Callers

nothing calls this directly

Calls 12

GetOpPropertiesMethod · 0.95
as_tensor_shapeMethod · 0.95
get_collection_refMethod · 0.80
ItemMethod · 0.80
as_defaultMethod · 0.45
GraphMethod · 0.45
from_tensorsMethod · 0.45
batchMethod · 0.45
get_nextMethod · 0.45
appendMethod · 0.45
is_compatible_withMethod · 0.45

Tested by

no test coverage detected