-
Couldn't load subscription status.
- Fork 53
Weighted graph preprocessing to enable biased sampling #38
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 9 +2
Lines 116 194 +78
=========================================
+ Hits 116 194 +78
Continue to review full report at Codecov.
|
| TORCH_CHECK(rowptr.is_cpu(), "'rowptr' must be a CPU tensor"); | ||
| TORCH_CHECK(bias.is_cpu(), "'bias' must be a CPU tensor"); | ||
|
|
||
| auto cdf = at::empty_like(bias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| auto cdf = at::empty_like(bias); | |
| const auto cdf = at::empty_like(bias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to write data to cdf so it's not a const here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tensor will always be a const since we only change its data, not its metadata. It‘s not so important though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit comment is to always use size_t for indexes such as
for (size_t i = _s; i < _e; ++i)
for (size_t j = 0; j < len; ++j)
Both from complier optimization and readability point of view.
| avg /= len; | ||
|
|
||
| // The sets for index with a bias lower or higher than average | ||
| std::vector<std::pair<int64_t, scalar_t>> high, low; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more optimization we can do is to use std::vector<size_t> high, low instead of pair.
Later you can do
scalar_t low_bias = out_beg[low_idx];
out_beg[low_idx] = low_bias / avg;
out_beg[high_idx] -= (avg - low_bias);
Create pairs are much more costly than just use int.
No description provided.