Pytorch variable explorer

Hi,

I want to see the all tensors that I made and the dependency between them.

If it doesn’t exist, I want to implement it.

Is there anyone who have ever seen this functionality?

I imagine that the final result will be something like this.

a = torch.zeros(1)
b = torch.zeros(1)
c = torch.zeros(1)
d = torch.zeros(1)
e = a + b
e = e + c

inspect_pytorch()
# Allocated tensor:
#  a (shape=[1], dtype=torch.float)
#  b (shape=[1], dtype=torch.float)
#  c (shape=[1], dtype=torch.float)
#  d (shape=[1], dtype=torch.float)
#  tensor#1 (shape=[1], dtype=torch.float) No name for this tensor
#  e (shape=[1], dtype=torch.float)
#
# Dependency:
#  tensor#1 <- (a, b, op:add)
#  e <- (tensor#1, c, op:add)

I think these kind of information could be helpful.

Thanks,

You can already do this with some third party libraries like

from rich import inspect
inspect(a)
inspect(b)
inspect(c)