Cannot save DGLGraph - AttributeError: ‘Series’ object has no attribute ‘contiguous’

Hi

For some reason I cannot save individual graphs or lists of graphs when using save_graphs(). I also get errors when trying to use pickle.

The graphs I am using were constructed with the graphein library (https://github.com/a-r-j/graphein).

File “model.py”, line 61, in get_graph
save_graphs(file_path, g)
File “/home/charlie/anaconda3/envs/pytorch/lib/python3.7/site-packages/dgl/data/graph_serialize.py”, line 107, in save_graphs
gdata_list = [GraphData.create(g) for g in g_list]
File “/home/charlie/anaconda3/envs/pytorch/lib/python3.7/site-packages/dgl/data/graph_serialize.py”, line 107, in
gdata_list = [GraphData.create(g) for g in g_list]
File “/home/charlie/anaconda3/envs/pytorch/lib/python3.7/site-packages/dgl/data/graph_serialize.py”, line 37, in create
node_tensors[key] = F.zerocopy_to_dgl_ndarray(value)
File “/home/charlie/anaconda3/envs/pytorch/lib/python3.7/site-packages/dgl/backend/pytorch/tensor.py”, line 283, in zerocopy_to_dgl_ndarray
return nd.from_dlpack(dlpack.to_dlpack(input.contiguous()))
File “/home/charlie/anaconda3/envs/pytorch/lib/python3.7/site-packages/pandas/core/generic.py”, line 5274, in getattr
return object.getattribute(self, name)
AttributeError: ‘Series’ object has no attribute ‘contiguous’

It seems that some node features of the graph are not tensors. contiguous is a function for making tensors contiguous. In general it’s not preferred to assign non-tensor values for features. To save the features, you will need to save them yourself with other approaches, e.g. pickle.

1 Like