question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

torch.long and torch.int64

See original GitHub issue

🐛 Bug

torch.long and torch.int64 should be equivalent according to the pytorch documentation, however, the following error message shows.

`` ValueError: MessagePassing.propagate only supports torch.LongTensor of shape [2, num_messages] or torch_sparse.SparseTensor for argument edge_index.

Expected behavior

I am not sure if I am creating the tensor wrongly or the dtype check did not include torch.int64.

I had tried changing the dtype by using .to(torch.long) but the dtypes stays at torch.int64

Environment

  • OS: wsl ubuntu
  • Python version: 3.9
  • PyTorch version: 1.9
  • CUDA/cuDNN version:
  • GCC version:
  • Any other relevant information:

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rusty1scommented, Dec 7, 2022

All GNN layers need a valid edge_index to propagate information. You can define an empty edge_index matrix via

edge_index = torch.empty(2, 0, dtype=torch.long)

Note that this matrix is still two-dimensional despite having zero elements, i.e it has shape [2, 0].

0reactions
codeastra2commented, Dec 6, 2022

Hi @rusty1s , thanks for the framework! I was trying to learn in a situation when there are no edges and and there are only nodes, so either I pass a empty tensor or pass None for edge index, when I do that I run into the above error, but according to the documentation here, it states that these attributes are not required, could you please help me out here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PyTorch tensor declared as torch.long becomes torch.int64
From the the documentation we can see that torch.long and torch.int64 are synonymous and both refer to the 64-bit signed integer type.
Read more >
torch.Tensor — PyTorch 1.13 documentation
Data types ; 64-bit integer (signed). torch.int64 or torch.long. torch.LongTensor ; Boolean. torch.bool. torch.BoolTensor ; quantized 8-bit integer (unsigned).
Read more >
torch.Tensor — PyTorch master documentation
A torch.Tensor is a multi-dimensional matrix containing elements of a single data type. Torch defines eight CPU tensor types and eight GPU tensor...
Read more >
How to typecast a float tensor to integer tensor and vice ...
This is achieved by using .type(torch.int64) which will return the integer type values, even if the values are in float or in some...
Read more >
torch.Tensor — PyTorch master documentation
torch.int32 or torch.int. torch.IntTensor. torch.cuda.IntTensor. 64-bit integer (signed). torch.int64 or torch.long. torch.LongTensor. torch.cuda.LongTensor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found