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

Function _test_reader_files_arg

dali/test/python/reader/test_file.py:65–90  ·  view source on GitHub ↗
(use_root, use_labels, shuffle)

Source from the content-addressed store, hash-verified

63
64
65def _test_reader_files_arg(use_root, use_labels, shuffle):
66 root = g_root
67 fnames = g_files
68 if not use_root:
69 fnames = [os.path.join(root, f) for f in fnames]
70 root = None
71
72 lbl = None
73 if use_labels:
74 lbl = [10000 + i for i in range(len(fnames))]
75
76 batch_size = 3
77 pipe = Pipeline(batch_size, 1, 0)
78 files, labels = fn.readers.file(
79 file_root=root, files=fnames, labels=lbl, random_shuffle=shuffle
80 )
81 pipe.set_outputs(files, labels)
82
83 num_iters = (len(fnames) + 2 * batch_size) // batch_size
84 for i in range(num_iters):
85 out_f, out_l = pipe.run()
86 for j in range(batch_size):
87 contents = bytes(out_f.at(j)).decode("utf-8")
88 label = out_l.at(j)[0]
89 index = label - 10000 if use_labels else label
90 assert contents == ref_contents(fnames[index])
91
92
93def test_file_reader():

Callers

nothing calls this directly

Calls 7

set_outputsMethod · 0.95
runMethod · 0.95
PipelineClass · 0.90
ref_contentsFunction · 0.85
fileMethod · 0.80
decodeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected