27 #ifndef LBANN_DATA_READERS_PYTHON_HPP_INCLUDED 28 #define LBANN_DATA_READERS_PYTHON_HPP_INCLUDED 31 #ifdef LBANN_HAS_EMBEDDED_PYTHON 36 class python_reader :
public generic_data_reader
39 python_reader(std::string module,
40 std::string module_dir,
41 std::string sample_function,
42 std::string num_samples_function,
43 std::string sample_dims_function,
45 python_reader(
const python_reader&) =
default;
46 python_reader& operator=(
const python_reader&) =
default;
47 ~python_reader()
override;
48 python_reader* copy()
const override {
return new python_reader(*
this); }
50 std::string get_type()
const override {
return "python_reader"; }
52 const std::vector<El::Int> get_data_dims()
const override;
53 int get_num_labels()
const override;
54 int get_linearized_data_size()
const override;
55 int get_linearized_label_size()
const override;
57 void setup(
int num_io_threads,
58 observer_ptr<thread_pool> io_thread_pool)
override;
62 bool fetch_data_block(std::map<data_field_type, CPUMat*>& input_buffers,
66 El::Matrix<El::Int>& indices_fetched)
override;
67 bool fetch_label(
CPUMat& Y,
int data_id,
int mb_idx)
override;
71 std::vector<El::Int> m_sample_dims;
73 El::Int m_num_samples;
81 python::object m_sample_function;
89 python::object m_sample_function_wrapper;
95 python::object m_process_pool;
101 python::object m_shared_memory_array;
107 DataType* m_shared_memory_array_ptr =
nullptr;
112 #endif // LBANN_HAS_EMBEDDED_PYTHON 113 #endif // LBANN_DATA_READERS_PYTHON_HPP_INCLUDED
void load(std::string const &pbuf_filename, google::protobuf::Message &msg)
Fill the protobuf message from a binary file.
El::Matrix< DataType, El::Device::CPU > CPUMat