Determines the correct framework to dispatch to given a tensor-like object or a sequence of tensor-like objects.


*values (tensor_like) – variable length argument list with single tensor-like objects


the name of the interface

Return type


To determine the framework to dispatch to, the following rules are applied:

  • Tensors that are incompatible (such as Torch, TensorFlow and Jax tensors) cannot both be present.

  • Autograd tensors may be present alongside Torch, TensorFlow and Jax tensors, but Torch, TensorFlow and Jax take precendence; the autograd arrays will be treated as non-differentiable NumPy arrays. A warning will be raised suggesting that vanilla NumPy be used instead.

  • Vanilla NumPy arrays and SciPy sparse matrices can be used alongside other tensor objects; they will always be treated as non-differentiable constants.


get_interface defaults to "numpy" whenever Python built-in objects are passed. I.e. a list or tuple of torch tensors will be identified as "numpy":

>>> get_interface([torch.tensor([1]), torch.tensor([1])])

The correct usage in that case is to unpack the arguments get_interface(*[torch.tensor([1]), torch.tensor([1])]).