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
5b51e968
"git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "fca97a63fd6b752f601404b592021f217265f8d9"
Unverified
Commit
5b51e968
authored
Dec 28, 2023
by
Muhammed Fatih BALIN
Committed by
GitHub
Dec 28, 2023
Browse files
[GraphBolt][CUDA] Fix graph pinning and add tests (#6864)
parent
22a2513d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
+1
-1
tests/python/pytorch/graphbolt/impl/test_fused_csc_sampling_graph.py
...n/pytorch/graphbolt/impl/test_fused_csc_sampling_graph.py
+32
-6
No files found.
python/dgl/graphbolt/impl/fused_csc_sampling_graph.py
View file @
5b51e968
...
@@ -971,7 +971,7 @@ class FusedCSCSamplingGraph(SamplingGraph):
...
@@ -971,7 +971,7 @@ class FusedCSCSamplingGraph(SamplingGraph):
"""Copy `FusedCSCSamplingGraph` to the pinned memory in-place."""
"""Copy `FusedCSCSamplingGraph` to the pinned memory in-place."""
def
_pin
(
x
):
def
_pin
(
x
):
return
x
.
pin
ned
_memory
()
if
hasattr
(
x
,
"pin
ned
_memory"
)
else
x
return
x
.
pin_memory
()
if
hasattr
(
x
,
"pin_memory"
)
else
x
self
.
_apply_to_members
(
_pin
)
self
.
_apply_to_members
(
_pin
)
...
...
tests/python/pytorch/graphbolt/impl/test_fused_csc_sampling_graph.py
View file @
5b51e968
...
@@ -1511,11 +1511,7 @@ def test_from_dglgraph_heterogeneous():
...
@@ -1511,11 +1511,7 @@ def test_from_dglgraph_heterogeneous():
}
}
@
unittest
.
skipIf
(
def
create_fused_csc_sampling_graph
():
F
.
_default_context_str
==
"cpu"
,
reason
=
"`to` function needs GPU to test."
,
)
def
test_csc_sampling_graph_to_device
():
# Initialize data.
# Initialize data.
total_num_nodes
=
10
total_num_nodes
=
10
total_num_edges
=
9
total_num_edges
=
9
...
@@ -1541,7 +1537,7 @@ def test_csc_sampling_graph_to_device():
...
@@ -1541,7 +1537,7 @@ def test_csc_sampling_graph_to_device():
}
}
# Construct FusedCSCSamplingGraph.
# Construct FusedCSCSamplingGraph.
graph
=
gb
.
fused_csc_sampling_graph
(
return
gb
.
fused_csc_sampling_graph
(
indptr
,
indptr
,
indices
,
indices
,
edge_attributes
=
edge_attributes
,
edge_attributes
=
edge_attributes
,
...
@@ -1551,6 +1547,15 @@ def test_csc_sampling_graph_to_device():
...
@@ -1551,6 +1547,15 @@ def test_csc_sampling_graph_to_device():
edge_type_to_id
=
etypes
,
edge_type_to_id
=
etypes
,
)
)
@
unittest
.
skipIf
(
F
.
_default_context_str
==
"cpu"
,
reason
=
"`to` function needs GPU to test."
,
)
def
test_csc_sampling_graph_to_device
():
# Construct FusedCSCSamplingGraph.
graph
=
create_fused_csc_sampling_graph
()
# Copy to device.
# Copy to device.
graph
=
graph
.
to
(
"cuda"
)
graph
=
graph
.
to
(
"cuda"
)
...
@@ -1564,6 +1569,27 @@ def test_csc_sampling_graph_to_device():
...
@@ -1564,6 +1569,27 @@ def test_csc_sampling_graph_to_device():
assert
graph
.
edge_attributes
[
key
].
device
.
type
==
"cuda"
assert
graph
.
edge_attributes
[
key
].
device
.
type
==
"cuda"
@
unittest
.
skipIf
(
F
.
_default_context_str
==
"cpu"
,
reason
=
"Tests for pinned memory are only meaningful on GPU."
,
)
def
test_csc_sampling_graph_to_pinned_memory
():
# Construct FusedCSCSamplingGraph.
graph
=
create_fused_csc_sampling_graph
()
# Copy to pinned_memory in-place.
graph
.
pin_memory_
()
# Check.
assert
graph
.
csc_indptr
.
is_pinned
()
assert
graph
.
indices
.
is_pinned
()
assert
graph
.
node_type_offset
.
is_pinned
()
assert
graph
.
type_per_edge
.
is_pinned
()
assert
graph
.
csc_indptr
.
is_pinned
()
for
key
in
graph
.
edge_attributes
:
assert
graph
.
edge_attributes
[
key
].
is_pinned
()
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
F
.
_default_context_str
==
"gpu"
,
F
.
_default_context_str
==
"gpu"
,
reason
=
"Graph is CPU only at present."
,
reason
=
"Graph is CPU only at present."
,
...
...
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