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
1b3f14b0
Unverified
Commit
1b3f14b0
authored
Nov 22, 2023
by
Chang Liu
Committed by
GitHub
Nov 22, 2023
Browse files
[Misc.] Avoid calling `IsPinned` in the coo/csr constructor from every sampling process (#6568)
parent
2d8d6fbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
include/dgl/aten/coo.h
include/dgl/aten/coo.h
+10
-6
include/dgl/aten/csr.h
include/dgl/aten/csr.h
+10
-6
No files found.
include/dgl/aten/coo.h
View file @
1b3f14b0
...
...
@@ -64,11 +64,6 @@ struct COOMatrix {
data
(
darr
),
row_sorted
(
rsorted
),
col_sorted
(
csorted
)
{
if
(
!
IsEmpty
())
{
is_pinned
=
(
aten
::
IsNullArray
(
row
)
||
row
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
col
)
||
col
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
data
)
||
data
.
IsPinned
());
}
CheckValidity
();
}
...
...
@@ -134,6 +129,15 @@ struct COOMatrix {
aten
::
IsNullArray
(
data
);
}
// Check and update the internal flag is_pinned.
// This function will initialize a cuda context.
inline
bool
CheckIfPinnedInCUDA
()
{
is_pinned
=
(
aten
::
IsNullArray
(
row
)
||
row
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
col
)
||
col
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
data
)
||
data
.
IsPinned
());
return
is_pinned
;
}
/** @brief Return a copy of this matrix on the give device context. */
inline
COOMatrix
CopyTo
(
const
DGLContext
&
ctx
)
const
{
if
(
ctx
==
row
->
ctx
)
return
*
this
;
...
...
@@ -151,7 +155,7 @@ struct COOMatrix {
num_rows
,
num_cols
,
row
.
PinMemory
(),
col
.
PinMemory
(),
aten
::
IsNullArray
(
data
)
?
data
:
data
.
PinMemory
(),
row_sorted
,
col_sorted
);
CHECK
(
new_coo
.
is_pinned
)
CHECK
(
new_coo
.
CheckIfPinnedInCUDA
()
)
<<
"An internal DGL error has occured while trying to pin a COO "
"matrix. Please file a bug at "
"'https://github.com/dmlc/dgl/issues' "
...
...
include/dgl/aten/csr.h
View file @
1b3f14b0
...
...
@@ -60,11 +60,6 @@ struct CSRMatrix {
indices
(
iarr
),
data
(
darr
),
sorted
(
sorted_flag
)
{
if
(
!
IsEmpty
())
{
is_pinned
=
(
aten
::
IsNullArray
(
indptr
)
||
indptr
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
indices
)
||
indices
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
data
)
||
data
.
IsPinned
());
}
CheckValidity
();
}
...
...
@@ -128,6 +123,15 @@ struct CSRMatrix {
aten
::
IsNullArray
(
data
);
}
// Check and update the internal flag is_pinned.
// This function will initialize a cuda context.
inline
bool
CheckIfPinnedInCUDA
()
{
is_pinned
=
(
aten
::
IsNullArray
(
indptr
)
||
indptr
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
indices
)
||
indices
.
IsPinned
())
&&
(
aten
::
IsNullArray
(
data
)
||
data
.
IsPinned
());
return
is_pinned
;
}
/** @brief Return a copy of this matrix on the give device context. */
inline
CSRMatrix
CopyTo
(
const
DGLContext
&
ctx
)
const
{
if
(
ctx
==
indptr
->
ctx
)
return
*
this
;
...
...
@@ -143,7 +147,7 @@ struct CSRMatrix {
auto
new_csr
=
CSRMatrix
(
num_rows
,
num_cols
,
indptr
.
PinMemory
(),
indices
.
PinMemory
(),
aten
::
IsNullArray
(
data
)
?
data
:
data
.
PinMemory
(),
sorted
);
CHECK
(
new_csr
.
is_pinned
)
CHECK
(
new_csr
.
CheckIfPinnedInCUDA
()
)
<<
"An internal DGL error has occured while trying to pin a CSR "
"matrix. Please file a bug at "
"'https://github.com/dmlc/dgl/issues' "
...
...
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