MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_tfrecord_odirect

Function test_tfrecord_odirect

dali/test/python/reader/test_index.py:76–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74
75
76def test_tfrecord_odirect():
77 batch_size = 16
78
79 @pipeline_def(batch_size=batch_size, device_id=0, num_threads=4)
80 def tfrecord_pipe(path, index_path, dont_use_mmap, use_o_direct):
81 input = fn.readers.tfrecord(
82 path=path,
83 index_path=index_path,
84 dont_use_mmap=dont_use_mmap,
85 use_o_direct=use_o_direct,
86 features={"image/class/label": tfrec.FixedLenFeature([1], tfrec.int64, -1)},
87 name="Reader",
88 )
89 return input["image/class/label"]
90
91 tfrecord = os.path.join(get_dali_extra_path(), "db", "tfrecord", "train")
92 tfrecord_idx = os.path.join(get_dali_extra_path(), "db", "tfrecord", "train.idx")
93
94 pipe = tfrecord_pipe(tfrecord, tfrecord_idx, True, True)
95 pipe_ref = tfrecord_pipe(tfrecord, tfrecord_idx, False, False)
96 iters = (pipe.epoch_size("Reader") + batch_size) // batch_size
97 for _ in range(iters):
98 out = pipe.run()
99 out_ref = pipe_ref.run()
100 for a, b in zip(out, out_ref):
101 assert np.array_equal(a.as_array(), b.as_array())
102
103
104@cartesian_params(((1, 2, 1), (3, 1, 2)), (True, False), (True, False))

Callers

nothing calls this directly

Calls 4

get_dali_extra_pathFunction · 0.90
tfrecord_pipeFunction · 0.85
epoch_sizeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected