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
0452cc3c
Commit
0452cc3c
authored
Nov 12, 2018
by
Gan Quan
Committed by
Minjie Wang
Nov 12, 2018
Browse files
[Bug] Transpose adj is not correctly cached (#148)
parent
cd3e25a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
python/dgl/graph_index.py
python/dgl/graph_index.py
+4
-3
No files found.
python/dgl/graph_index.py
View file @
0452cc3c
...
@@ -489,7 +489,8 @@ class GraphIndex(object):
...
@@ -489,7 +489,8 @@ class GraphIndex(object):
utils.CtxCachedObject
utils.CtxCachedObject
An object that returns tensor given context.
An object that returns tensor given context.
"""
"""
if
not
'adj'
in
self
.
_cache
:
key
=
'transposed adj'
if
transpose
else
'adj'
if
not
key
in
self
.
_cache
:
src
,
dst
,
_
=
self
.
edges
(
sorted
=
False
)
src
,
dst
,
_
=
self
.
edges
(
sorted
=
False
)
src
=
F
.
unsqueeze
(
src
.
tousertensor
(),
0
)
src
=
F
.
unsqueeze
(
src
.
tousertensor
(),
0
)
dst
=
F
.
unsqueeze
(
dst
.
tousertensor
(),
0
)
dst
=
F
.
unsqueeze
(
dst
.
tousertensor
(),
0
)
...
@@ -501,8 +502,8 @@ class GraphIndex(object):
...
@@ -501,8 +502,8 @@ class GraphIndex(object):
# FIXME(minjie): data type
# FIXME(minjie): data type
dat
=
F
.
ones
((
self
.
number_of_edges
(),),
dtype
=
F
.
float32
)
dat
=
F
.
ones
((
self
.
number_of_edges
(),),
dtype
=
F
.
float32
)
mat
=
F
.
sparse_matrix
(
dat
,
(
'coo'
,
idx
),
(
n
,
n
))
mat
=
F
.
sparse_matrix
(
dat
,
(
'coo'
,
idx
),
(
n
,
n
))
self
.
_cache
[
'adj'
]
=
utils
.
CtxCachedObject
(
lambda
ctx
:
F
.
copy_to
(
mat
,
ctx
))
self
.
_cache
[
key
]
=
utils
.
CtxCachedObject
(
lambda
ctx
:
F
.
copy_to
(
mat
,
ctx
))
return
self
.
_cache
[
'adj'
]
return
self
.
_cache
[
key
]
def
incidence_matrix
(
self
,
oriented
=
False
):
def
incidence_matrix
(
self
,
oriented
=
False
):
"""Return the incidence matrix representation of this graph.
"""Return the incidence matrix representation of this graph.
...
...
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