Unverified Commit 54e1ef2e authored by VoVAllen's avatar VoVAllen Committed by GitHub
Browse files

[Fix] Fix serialize NDArray when shape is 0 (#884)

* fix

* fix bugs
parent 599ed868
......@@ -440,8 +440,12 @@ inline bool NDArray::Load(dmlc::Stream* strm) {
<< "Invalid DLTensor file format";
CHECK(data_byte_size == num_elems * elem_bytes)
<< "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))
<< "Invalid DLTensor file format";
}
if (!DMLC_IO_NO_ENDIAN_SWAP) {
dmlc::ByteSwap(ret->data, elem_bytes, num_elems);
}
......
......@@ -135,9 +135,9 @@ def load_graphs(filename, idx_list=None):
>>> glist, label_dict = load_graphs("./data.bin", [0]) # glist will be [g1]
"""
assert isinstance(idx_list, list)
if idx_list is None:
idx_list = []
assert isinstance(idx_list, list)
metadata = _CAPI_DGLLoadGraphs(filename, idx_list, False)
label_dict = {}
for k, v in metadata.labels.items():
......
......@@ -191,6 +191,7 @@ StorageMetaData LoadDGLGraphs(const std::string &filename,
std::vector<dgl_id_t> idx_list,
bool onlyMeta) {
SeekStream *fs = SeekStream::CreateForRead(filename.c_str(), true);
CHECK(fs) << "Filename is invalid";
StorageMetaData metadata = StorageMetaData::Create();
// Read DGL MetaData
uint64_t magicNum, graphType, version;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment