From 32478fe0ea2981b123e3e11528001cf7e838c882 Mon Sep 17 00:00:00 2001 From: fengjiayi Date: Thu, 21 Jun 2018 17:35:47 +0800 Subject: [PATCH] Make buffers of DoubleBufferReader and open_files bigger --- .../reader/create_double_buffer_reader_op.cc | 4 ++-- python/paddle/fluid/layers/io.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/reader/create_double_buffer_reader_op.cc b/paddle/fluid/operators/reader/create_double_buffer_reader_op.cc index 5f35b9b3ea..5f734489a8 100644 --- a/paddle/fluid/operators/reader/create_double_buffer_reader_op.cc +++ b/paddle/fluid/operators/reader/create_double_buffer_reader_op.cc @@ -23,13 +23,13 @@ namespace reader { // 'Double buffer' means we shall maintain two batches of input data at the same // time. So the kCacheSize shoul be at least 2. -static constexpr size_t kCacheSize = 3; +static constexpr size_t kCacheSize = 5; // There will be two bacthes out of the channel during training: // 1. the one waiting to be sent to the channel // 2. the one just be received from the channel, which is also being used by // subsequent operators. // So the channel size should be kChacheSize - 2 -static constexpr size_t kChannelSize = 1; // kCacheSize - 2 +static constexpr size_t kChannelSize = 3; // kCacheSize - 2 class DoubleBufferReader : public framework::DecoratedReader { public: diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index 8d153b75cd..9b4be05800 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -110,7 +110,7 @@ class BlockGuardServ(BlockGuard): class ListenAndServ(object): """ **ListenAndServ Layer** - + ListenAndServ is used to create a rpc server bind and listen on specific TCP port, this server will run the sub-block when received variables from clients. @@ -212,7 +212,7 @@ def Send(endpoints, send_vars, sync=True): of send_vars to send send_vars (list): variables to send to server sync (bool): whether to wait the request finish - + """ assert (type(send_vars) == list) @@ -469,10 +469,13 @@ def open_files(filenames, lod_levels(list): List of ints which declaring data lod_level. dtypes(list): List of strs which declaring data type. thread_num(int): The maximal concurrent prefetch thread number. - buffer_size(int): The size of prefetch buffer. + buffer_size(int|None): The size of prefetch buffer. If it is setted None, + buffer size will be thread_num * 3. + Default: None pass_num(int): Number of passes to run. for_parallel(Bool): Set it as True if you are going to run subsequent operators in parallel. + Default: True Returns: Variable: A Reader Variable via which we can get file data. @@ -492,7 +495,7 @@ def open_files(filenames, image, label = fluid.layers.io.read_file(reader) """ if buffer_size is None: - buffer_size = thread_num + buffer_size = thread_num * 3 if isinstance(filenames, basestring): filenames = [filenames] dtypes = [convert_np_dtype_to_dtype_(dt) for dt in dtypes] -- GitLab