Error thrown by prepare_tensor

Hi, I am trying to understand an exception I’m seeing. The following is the end of the stack trace:

  File "<REDACTED>/python3.7/site-packages/dgl/", line 462, in add_edges
    u = utils.prepare_tensor(self, u, 'u')
  File "<REDACTED>/python3.7/site-packages/dgl/utils/", line 35, in prepare_tensor
    name, g.idtype, g.device, F.dtype(data), F.context(data)))
dgl._ffi.base.DGLError: Expect argument "u" to have data type torch.int64 and device context cpu. But got torch.int32 and cpu.

The curious thing about this issue is that it crops up in the context of a multi-trial hyperparameter optimization, after a full training run trial. In other words, a full training trial runs without error before this issue comes up during the next optimization step. Because the dataset does not change from trial to trial, I am not sure where this issue is coming from. Any help or insight would be appreciated, thank you!


How did you construct the graph? DGL’s graph has idtype, which is torch.int32 or int64. All arguments should be consistent to the graph type

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.