qiboteam / qibo

A full-stack framework for quantum computing.
https://qibo.science
Apache License 2.0
294 stars 60 forks source link

The `tensordot` function is not consistent throughout different backends #1334

Open Canoming opened 5 months ago

Canoming commented 5 months ago

When I try to call the function tensordot from different backends, the arguments are not consistent:

  if self._backend.__class__.__name__ == "PyTorchBackend":
      tensor = self._backend.np.tensordot(tensor0, tensor1, dims=([1],[0]))
  else:
      tensor = self._backend.np.tensordot(tensor0, tensor1, axes=(1,0))

The argument axes is named dims in PyTorchBackend, which is different from all other backends. Also, the type of argument is different. While other backends support tuple of numbers for axes, the PyTorchBackend only support tuple of list.

Simone-Bordoni commented 5 months ago

We are planning on defining the function tensordot in the abstract backend. For now a good solution is using matmul that seems to work in the same way for all backends.

renatomello commented 4 months ago

@Canoming @Simone-Bordoni can this be closed?