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
54e1ef2e
You need to sign in or sign up before continuing.
Unverified
Commit
54e1ef2e
authored
Sep 28, 2019
by
VoVAllen
Committed by
GitHub
Sep 28, 2019
Browse files
[Fix] Fix serialize NDArray when shape is 0 (#884)
* fix * fix bugs
parent
599ed868
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
include/dgl/runtime/ndarray.h
include/dgl/runtime/ndarray.h
+6
-2
python/dgl/data/graph_serialize.py
python/dgl/data/graph_serialize.py
+1
-1
src/graph/graph_serialize.cc
src/graph/graph_serialize.cc
+1
-0
No files found.
include/dgl/runtime/ndarray.h
View file @
54e1ef2e
...
@@ -440,8 +440,12 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
...
@@ -440,8 +440,12 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
<<
"Invalid DLTensor file format"
;
<<
"Invalid DLTensor file format"
;
CHECK
(
data_byte_size
==
num_elems
*
elem_bytes
)
CHECK
(
data_byte_size
==
num_elems
*
elem_bytes
)
<<
"Invalid DLTensor file format"
;
<<
"Invalid DLTensor file format"
;
if
(
data_byte_size
!=
0
)
{
// strm->Read will return the total number of elements successfully read.
// Therefore if data_byte_size is zero, the CHECK below would fail.
CHECK
(
strm
->
Read
(
ret
->
data
,
data_byte_size
))
CHECK
(
strm
->
Read
(
ret
->
data
,
data_byte_size
))
<<
"Invalid DLTensor file format"
;
<<
"Invalid DLTensor file format"
;
}
if
(
!
DMLC_IO_NO_ENDIAN_SWAP
)
{
if
(
!
DMLC_IO_NO_ENDIAN_SWAP
)
{
dmlc
::
ByteSwap
(
ret
->
data
,
elem_bytes
,
num_elems
);
dmlc
::
ByteSwap
(
ret
->
data
,
elem_bytes
,
num_elems
);
}
}
...
...
python/dgl/data/graph_serialize.py
View file @
54e1ef2e
...
@@ -135,9 +135,9 @@ def load_graphs(filename, idx_list=None):
...
@@ -135,9 +135,9 @@ def load_graphs(filename, idx_list=None):
>>> glist, label_dict = load_graphs("./data.bin", [0]) # glist will be [g1]
>>> glist, label_dict = load_graphs("./data.bin", [0]) # glist will be [g1]
"""
"""
assert
isinstance
(
idx_list
,
list
)
if
idx_list
is
None
:
if
idx_list
is
None
:
idx_list
=
[]
idx_list
=
[]
assert
isinstance
(
idx_list
,
list
)
metadata
=
_CAPI_DGLLoadGraphs
(
filename
,
idx_list
,
False
)
metadata
=
_CAPI_DGLLoadGraphs
(
filename
,
idx_list
,
False
)
label_dict
=
{}
label_dict
=
{}
for
k
,
v
in
metadata
.
labels
.
items
():
for
k
,
v
in
metadata
.
labels
.
items
():
...
...
src/graph/graph_serialize.cc
View file @
54e1ef2e
...
@@ -191,6 +191,7 @@ StorageMetaData LoadDGLGraphs(const std::string &filename,
...
@@ -191,6 +191,7 @@ StorageMetaData LoadDGLGraphs(const std::string &filename,
std
::
vector
<
dgl_id_t
>
idx_list
,
std
::
vector
<
dgl_id_t
>
idx_list
,
bool
onlyMeta
)
{
bool
onlyMeta
)
{
SeekStream
*
fs
=
SeekStream
::
CreateForRead
(
filename
.
c_str
(),
true
);
SeekStream
*
fs
=
SeekStream
::
CreateForRead
(
filename
.
c_str
(),
true
);
CHECK
(
fs
)
<<
"Filename is invalid"
;
StorageMetaData
metadata
=
StorageMetaData
::
Create
();
StorageMetaData
metadata
=
StorageMetaData
::
Create
();
// Read DGL MetaData
// Read DGL MetaData
uint64_t
magicNum
,
graphType
,
version
;
uint64_t
magicNum
,
graphType
,
version
;
...
...
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