bdusell / semiring-einsum

Generic PyTorch implementation of einsum that supports different semirings
https://bdusell.github.io/semiring-einsum/
MIT License
45 stars 7 forks source link

Zero-dimensional tensors #7

Closed davidweichiang closed 2 years ago

davidweichiang commented 2 years ago

Desired behavior:

>>> torch.einsum('->', torch.tensor(1.))
tensor(1.)

Actual behavior:

>>> eq = compile_equation('->')
>>> einsum(eq, torch.tensor(1.), block_size=1)
...
  File ".../torch_semiring_einsum/equation.py", line 159, in lookup
    return arg[index].permute(self.permutation)
IndexError: too many indices for tensor of dimension 0