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
f8c60a18
Unverified
Commit
f8c60a18
authored
Aug 24, 2023
by
LastWhisper
Committed by
GitHub
Aug 24, 2023
Browse files
[Graphbolt] Introduce an `is_homogeneous` option for converting from COO to CSC format. (#6202)
parent
a38bb5d1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
python/dgl/graphbolt/impl/csc_sampling_graph.py
python/dgl/graphbolt/impl/csc_sampling_graph.py
+3
-2
python/dgl/graphbolt/impl/ondisk_dataset.py
python/dgl/graphbolt/impl/ondisk_dataset.py
+1
-1
tests/python/pytorch/graphbolt/impl/test_ondisk_dataset.py
tests/python/pytorch/graphbolt/impl/test_ondisk_dataset.py
+1
-1
No files found.
python/dgl/graphbolt/impl/csc_sampling_graph.py
View file @
f8c60a18
...
@@ -712,7 +712,7 @@ def save_csc_sampling_graph(graph, filename):
...
@@ -712,7 +712,7 @@ def save_csc_sampling_graph(graph, filename):
print
(
f
"CSCSamplingGraph has been saved to
{
filename
}
."
)
print
(
f
"CSCSamplingGraph has been saved to
{
filename
}
."
)
def
from_dglgraph
(
g
:
DGLGraph
)
->
CSCSamplingGraph
:
def
from_dglgraph
(
g
:
DGLGraph
,
is_homogeneous
=
False
)
->
CSCSamplingGraph
:
"""Convert a DGLGraph to CSCSamplingGraph."""
"""Convert a DGLGraph to CSCSamplingGraph."""
homo_g
,
ntype_count
,
_
=
to_homogeneous
(
g
,
return_count
=
True
)
homo_g
,
ntype_count
,
_
=
to_homogeneous
(
g
,
return_count
=
True
)
# Initialize metadata.
# Initialize metadata.
...
@@ -726,7 +726,8 @@ def from_dglgraph(g: DGLGraph) -> CSCSamplingGraph:
...
@@ -726,7 +726,8 @@ def from_dglgraph(g: DGLGraph) -> CSCSamplingGraph:
indptr
,
indices
,
_
=
homo_g
.
adj_tensors
(
"csc"
)
indptr
,
indices
,
_
=
homo_g
.
adj_tensors
(
"csc"
)
ntype_count
.
insert
(
0
,
0
)
ntype_count
.
insert
(
0
,
0
)
node_type_offset
=
torch
.
cumsum
(
torch
.
LongTensor
(
ntype_count
),
0
)
node_type_offset
=
torch
.
cumsum
(
torch
.
LongTensor
(
ntype_count
),
0
)
type_per_edge
=
homo_g
.
edata
[
ETYPE
]
type_per_edge
=
None
if
is_homogeneous
else
homo_g
.
edata
[
ETYPE
]
return
CSCSamplingGraph
(
return
CSCSamplingGraph
(
torch
.
ops
.
graphbolt
.
from_csc
(
torch
.
ops
.
graphbolt
.
from_csc
(
...
...
python/dgl/graphbolt/impl/ondisk_dataset.py
View file @
f8c60a18
...
@@ -152,7 +152,7 @@ def preprocess_ondisk_dataset(dataset_dir: str) -> str:
...
@@ -152,7 +152,7 @@ def preprocess_ondisk_dataset(dataset_dir: str) -> str:
g
.
edata
[
graph_feature
[
"name"
]]
=
edge_data
g
.
edata
[
graph_feature
[
"name"
]]
=
edge_data
# 4. Convert the DGLGraph to a CSCSamplingGraph.
# 4. Convert the DGLGraph to a CSCSamplingGraph.
csc_sampling_graph
=
from_dglgraph
(
g
)
csc_sampling_graph
=
from_dglgraph
(
g
,
is_homogeneous
)
# 5. Save the CSCSamplingGraph and modify the output_config.
# 5. Save the CSCSamplingGraph and modify the output_config.
output_config
[
"graph_topology"
]
=
{}
output_config
[
"graph_topology"
]
=
{}
...
...
tests/python/pytorch/graphbolt/impl/test_ondisk_dataset.py
View file @
f8c60a18
...
@@ -949,7 +949,7 @@ def test_OnDiskDataset_preprocess_homogeneous():
...
@@ -949,7 +949,7 @@ def test_OnDiskDataset_preprocess_homogeneous():
torch
.
arange
(
num_samples
),
torch
.
arange
(
num_samples
),
torch
.
tensor
([
fanout
]),
torch
.
tensor
([
fanout
]),
)
)
assert
len
(
list
(
subgraph
.
node_pairs
.
values
())[
0
]
[
0
])
<=
num_samples
assert
len
(
subgraph
.
node_pairs
[
0
])
<=
num_samples
def
test_OnDiskDataset_preprocess_path
():
def
test_OnDiskDataset_preprocess_path
():
...
...
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