DGL Version: 0.8.1
Pytorch Version: 1.9.0
Suppose that there is one graph:
g = dgl.graph(([3], [2]))
Then set node features using torch sparse tensors.
i = [[2, 3], [0, 0]]
v = [3, 4]
t = torch.sparse_coo_tensor(i, v, (4, 1))
g.ndata['h'] = t
but when trying to save the graph, it raise one NotImplementedError:
/opt/conda/lib/python3.8/site-packages/dgl/backend/pytorch/tensor.py in zerocopy_to_dgl_ndarray(data)
347 else:
348 def zerocopy_to_dgl_ndarray(data):
--> 349 return nd.from_dlpack(dlpack.to_dlpack(data.contiguous()))
350
351 def zerocopy_to_dgl_ndarray_for_write(input):
NotImplementedError: Tensors of type SparseTensorImpl do not have is_contiguous.
Seems that DGL does not support sparse tensors as node features when saving graphs. Will it be supported in the future?