Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
144a491b
"tests/python/common/data/test_serialize.py" did not exist on "18a26fcfb1983af7fba69db9bdce7ba5e6a9945f"
Unverified
Commit
144a491b
authored
Aug 09, 2023
by
Ramon Zhou
Committed by
GitHub
Aug 09, 2023
Browse files
[Graphbolt] Update the sampler algorithm documentation for fanout = -1. (#6114)
parent
129e75f3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
21 deletions
+31
-21
graphbolt/src/csc_sampling_graph.cc
graphbolt/src/csc_sampling_graph.cc
+16
-9
python/dgl/graphbolt/impl/csc_sampling_graph.py
python/dgl/graphbolt/impl/csc_sampling_graph.py
+15
-12
No files found.
graphbolt/src/csc_sampling_graph.cc
View file @
144a491b
...
@@ -329,9 +329,9 @@ c10::intrusive_ptr<CSCSamplingGraph> CSCSamplingGraph::LoadFromSharedMemory(
...
@@ -329,9 +329,9 @@ c10::intrusive_ptr<CSCSamplingGraph> CSCSamplingGraph::LoadFromSharedMemory(
* @param num_neighbors The number of neighbors to pick.
* @param num_neighbors The number of neighbors to pick.
* @param fanout The number of edges to be sampled for each node. It should be
* @param fanout The number of edges to be sampled for each node. It should be
* >= 0 or -1.
* >= 0 or -1.
* - When the value is -1, all neighbors will be
chosen for sampling. It is
* - When the value is -1, all neighbors will be
sampled once regardless of
* equivalent to selecting all neighbors w
ith non-zero probability when the
*
replacement. It is
equivalent to selecting all neighbors w
hen the fanout is
*
fanout is
>= the number of neighbors (and replacement is set to false).
* >= the number of neighbors (and replacement is set to false).
* - When the value is a non-negative integer, it serves as a minimum
* - When the value is a non-negative integer, it serves as a minimum
* threshold for selecting neighbors.
* threshold for selecting neighbors.
* @param replace Boolean indicating whether the sample is performed with or
* @param replace Boolean indicating whether the sample is performed with or
...
@@ -458,9 +458,10 @@ inline torch::Tensor UniformPick(
...
@@ -458,9 +458,10 @@ inline torch::Tensor UniformPick(
* @param num_neighbors The number of neighbors to pick.
* @param num_neighbors The number of neighbors to pick.
* @param fanout The number of edges to be sampled for each node. It should be
* @param fanout The number of edges to be sampled for each node. It should be
* >= 0 or -1.
* >= 0 or -1.
* - When the value is -1, all neighbors will be chosen for sampling. It is
* - When the value is -1, all neighbors with non-zero probability will be
* equivalent to selecting all neighbors with non-zero probability when the
* sampled once regardless of replacement. It is equivalent to selecting all
* fanout is >= the number of neighbors (and replacement is set to false).
* neighbors with non-zero probability when the fanout is >= the number of
* neighbors (and replacement is set to false).
* - When the value is a non-negative integer, it serves as a minimum
* - When the value is a non-negative integer, it serves as a minimum
* threshold for selecting neighbors.
* threshold for selecting neighbors.
* @param replace Boolean indicating whether the sample is performed with or
* @param replace Boolean indicating whether the sample is performed with or
...
@@ -592,9 +593,10 @@ inline void safe_divide(T& a, U b) {
...
@@ -592,9 +593,10 @@ inline void safe_divide(T& a, U b) {
* @param num_neighbors The number of neighbors to pick.
* @param num_neighbors The number of neighbors to pick.
* @param fanout The number of edges to be sampled for each node. It should be
* @param fanout The number of edges to be sampled for each node. It should be
* >= 0 or -1.
* >= 0 or -1.
* - When the value is -1, all neighbors will be chosen for sampling. It is
* - When the value is -1, all neighbors (with non-zero probability, if
* equivalent to selecting all neighbors with non-zero probability when the
* weighted) will be sampled once regardless of replacement. It is equivalent to
* fanout is >= the number of neighbors (and replacement is set to false).
* selecting all neighbors with non-zero probability when the fanout is >= the
* number of neighbors (and replacement is set to false).
* - When the value is a non-negative integer, it serves as a minimum
* - When the value is a non-negative integer, it serves as a minimum
* threshold for selecting neighbors.
* threshold for selecting neighbors.
* @param options Tensor options specifying the desired data type of the result.
* @param options Tensor options specifying the desired data type of the result.
...
@@ -612,6 +614,11 @@ inline torch::Tensor LaborPick(
...
@@ -612,6 +614,11 @@ inline torch::Tensor LaborPick(
const
torch
::
TensorOptions
&
options
,
const
torch
::
TensorOptions
&
options
,
const
torch
::
optional
<
torch
::
Tensor
>&
probs_or_mask
,
const
torch
::
optional
<
torch
::
Tensor
>&
probs_or_mask
,
SamplerArgs
<
SamplerType
::
LABOR
>
args
)
{
SamplerArgs
<
SamplerType
::
LABOR
>
args
)
{
// TODO: fix inconsistency with Neighbor sampler.
// 1. Replace = true, fanout = -1. Expected: sample all neighbors with
// non-zero probility once regardless of replacement.
// 2. Replace = true, fanout > num_neighbors. Expected: sample fanout many
// neighbors.
fanout
=
fanout
<
0
?
num_neighbors
:
std
::
min
(
fanout
,
num_neighbors
);
fanout
=
fanout
<
0
?
num_neighbors
:
std
::
min
(
fanout
,
num_neighbors
);
if
(
!
NonUniform
&&
!
Replace
&&
fanout
>=
num_neighbors
)
{
if
(
!
NonUniform
&&
!
Replace
&&
fanout
>=
num_neighbors
)
{
return
torch
::
arange
(
offset
,
offset
+
num_neighbors
,
options
);
return
torch
::
arange
(
offset
,
offset
+
num_neighbors
,
options
);
...
...
python/dgl/graphbolt/impl/csc_sampling_graph.py
View file @
144a491b
...
@@ -283,10 +283,11 @@ class CSCSamplingGraph:
...
@@ -283,10 +283,11 @@ class CSCSamplingGraph:
types, and each fanout value corresponds to a specific edge
types, and each fanout value corresponds to a specific edge
type of the nodes.
type of the nodes.
The value of each fanout should be >= 0 or = -1.
The value of each fanout should be >= 0 or = -1.
- When the value is -1, all neighbors will be chosen for
- When the value is -1, all neighbors (with non-zero probability,
sampling. It is equivalent to selecting all neighbors when
if weighted) will be sampled once regardless of replacement. It
the fanout is >= the number of neighbors (and replace is set to
is equivalent to selecting all neighbors with non-zero
false).
probability when the fanout is >= the number of neighbors (and
replace is set to false).
- When the value is a non-negative integer, it serves as a
- When the value is a non-negative integer, it serves as a
minimum threshold for selecting neighbors.
minimum threshold for selecting neighbors.
replace: bool
replace: bool
...
@@ -395,10 +396,11 @@ class CSCSamplingGraph:
...
@@ -395,10 +396,11 @@ class CSCSamplingGraph:
types, and each fanout value corresponds to a specific edge
types, and each fanout value corresponds to a specific edge
type of the nodes.
type of the nodes.
The value of each fanout should be >= 0 or = -1.
The value of each fanout should be >= 0 or = -1.
- When the value is -1, all neighbors will be chosen for
- When the value is -1, all neighbors (with non-zero probability,
sampling. It is equivalent to selecting all neighbors when
if weighted) will be sampled once regardless of replacement. It
the fanout is >= the number of neighbors (and replace is set to
is equivalent to selecting all neighbors with non-zero
false).
probability when the fanout is >= the number of neighbors (and
replace is set to false).
- When the value is a non-negative integer, it serves as a
- When the value is a non-negative integer, it serves as a
minimum threshold for selecting neighbors.
minimum threshold for selecting neighbors.
replace: bool
replace: bool
...
@@ -455,10 +457,11 @@ class CSCSamplingGraph:
...
@@ -455,10 +457,11 @@ class CSCSamplingGraph:
types, and each fanout value corresponds to a specific edge
types, and each fanout value corresponds to a specific edge
type of the nodes.
type of the nodes.
The value of each fanout should be >= 0 or = -1.
The value of each fanout should be >= 0 or = -1.
- When the value is -1, all neighbors will be chosen for
- When the value is -1, all neighbors (with non-zero probability,
sampling. It is equivalent to selecting all neighbors when
if weighted) will be sampled once regardless of replacement. It
the fanout is >= the number of neighbors (and replace is set to
is equivalent to selecting all neighbors with non-zero
false).
probability when the fanout is >= the number of neighbors (and
replace is set to false).
- When the value is a non-negative integer, it serves as a
- When the value is a non-negative integer, it serves as a
minimum threshold for selecting neighbors.
minimum threshold for selecting neighbors.
replace: bool
replace: bool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment