Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomReader #10872

Merged
merged 11 commits into from
May 25, 2018
Merged

CustomReader #10872

merged 11 commits into from
May 25, 2018

Conversation

JiayiFeng
Copy link
Collaborator

@JiayiFeng JiayiFeng commented May 23, 2018

fixes #10873

@JiayiFeng JiayiFeng requested a review from reyoung May 23, 2018 10:48
}
PADDLE_ENFORCE(
source_var_names_.size() == underlying_outs.size() &&
sink_var_names_.size() == underlying_outs.size(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sink_var_names maybe not equal with source_var_names.size()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks!

// The scope for CustomReader's sub-block should be independent and shouldn't
// be any other computation scope's child. Otherwise, data preprocessing and
// compution cannot be concurrent.
auto* scope = new framework::Scope();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is no need to new Scope(). Just

Scope scope;

is cool

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

out->resize(sink_var_names_.size());
for (size_t i = 0; i < sink_var_names_.size(); ++i) {
framework::Variable* var = scope->FindVar(sink_var_names_[i]);
PADDLE_ENFORCE_NOT_NULL(var);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe fluid/operator/detail/safe_ref.h is good?

auto& tensor = detail::Ref(scope->FindVar(sink_var_names_[i])).Get<framework::LoDTensor>()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

source_lod_levels = self.underlying_reader.desc.lod_levels()
self.source_var_names = []
source_vars = []
for idx in xrange(len(source_shapes)):
Copy link
Collaborator

@reyoung reyoung May 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more pythonic way

source_var_names = (unique_name("preprocessor_source") for _ in xrange(len(source_shapes)))
for var_name, shape, dtype, lod_level in zip(source_var_names, source_shapes, source_dtypes, source_lod_levels):
	pass

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent

@JiayiFeng JiayiFeng merged commit cd8700f into PaddlePaddle:develop May 25, 2018
@JiayiFeng JiayiFeng deleted the dev_CustomReader branch May 25, 2018 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Reader
2 participants