Skip to content

Commit 87ac675

Browse files
committed
Add python wrapper for open_files_op
1 parent 3d677b1 commit 87ac675

File tree

1 file changed

+30
-0
lines changed
  • python/paddle/fluid/layers

1 file changed

+30
-0
lines changed

python/paddle/fluid/layers/io.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,36 @@ def open_recordio_file(filename, shapes, lod_levels, dtypes):
287287
startup_var)
288288

289289

290+
def open_files(filenames, thread_num, shapes, lod_levels, dtypes):
291+
dtypes = [convert_np_dtype_to_dtype_(dt) for dt in dtypes]
292+
shape_concat = []
293+
ranks = []
294+
295+
for shape in shapes:
296+
shape_concat.extend(shape)
297+
ranks.append(len(shape))
298+
299+
var_name = unique_name('multiple_reader')
300+
301+
startup_blk = default_startup_program().current_block()
302+
startup_var = startup_blk.create_var(name=var_name)
303+
startup_blk.append_op(
304+
type='open_files',
305+
outputs={'Out': [startup_var]},
306+
attrs={
307+
'shape_concat': shape_concat,
308+
'lod_levels': lod_levels,
309+
'ranks': ranks,
310+
'filename': filenames,
311+
'thread_num': thread_num
312+
})
313+
314+
startup_var.desc.set_dtypes(dtypes)
315+
startup_var.persistable = True
316+
return _copy_reader_var_(default_main_program().current_block(),
317+
startup_var)
318+
319+
290320
def __create_decorated_reader__(op_type, reader, attrs):
291321
var_name = unique_name(op_type)
292322
startup_blk = default_startup_program().current_block()

0 commit comments

Comments
 (0)