Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Change ReadNext API #24

Closed
tonyyang-svail opened this issue Jun 22, 2018 · 1 comment
Closed

Change ReadNext API #24

tonyyang-svail opened this issue Jun 22, 2018 · 1 comment

Comments

@tonyyang-svail
Copy link
Collaborator

tonyyang-svail commented Jun 22, 2018

Change to

std::vector<VariableHandle> ReadNext(VariableHandle reader) {
  PADDLE_ENFORCE_EQ(reader->Desc().GetType(),
                    paddle::framework::proto::VarType::READER);

  std::vector<VariableHandle> rval;

  paddle::framework::LoDTensorArray data_holder;
  reader->GetMutable<paddle::framework::ReaderHolder>()->ReadNext(&data_holder);
  PADDLE_ENFORCE(!data_holder.empty(), "There is no next data.");
  for (size_t i = 0; i < data_holder.size(); ++i) {
    rval.emplace_back(new Variable("data" + std::to_string(i)));
    auto* lod_tensor = rval.back()->GetMutable<framework::LoDTensor>();
    lod_tensor->ShareDataWith(data_holder[i]);
    lod_tensor->set_lod(data_holder[i].lod());
  }

  return rval;
}
@tonyyang-svail
Copy link
Collaborator Author

fixed by #28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant