Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ZenoTan
Copy link
Member

@ZenoTan ZenoTan commented Apr 30, 2022

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Apr 30, 2022

Codecov Report

Merging #38 (838617f) into master (0b26fcb) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 838617f differs from pull request most recent head d65d610. Consider uploading reports for the commit d65d610 to get more accurate results

@@            Coverage Diff            @@
##            master       #38   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         9    +2     
  Lines          116       194   +78     
=========================================
+ Hits           116       194   +78     
Impacted Files Coverage Δ
pyg_lib/csrc/random/cpu/biased_sampling.cpp 100.00% <100.00%> (ø)
pyg_lib/csrc/random/cpu/biased_sampling.h 100.00% <100.00%> (ø)
pyg_lib/csrc/utils/cpu/convert.h 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b26fcb...d65d610. Read the comment docs.

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);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auto cdf = at::empty_like(bias);
const auto cdf = at::empty_like(bias);

Copy link
Member Author

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

Copy link
Member

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 :)

@ZenoTan ZenoTan requested review from rusty1s and yaoyaowd May 2, 2022 16:34
Copy link
Contributor

@yaoyaowd yaoyaowd left a 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;
Copy link
Contributor

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.

@ZenoTan ZenoTan merged commit 6b2cf2d into master May 2, 2022
@ZenoTan ZenoTan deleted the bias_convert branch May 2, 2022 21:17
@ZenoTan ZenoTan mentioned this pull request May 2, 2022
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants