quimb.tensor.interface

Tools for interfacing the tensor and tensor network objects with other libraries.

Module Contents

Classes

Functions

pack(obj)

Take a tensor or tensor network like object and return a skeleton needed

unpack(params, skeleton)

Take a skeleton of a tensor or tensor network like object and a pytree

jax_pack(obj)

jax_unpack(aux, children)

jax_register_pytree()

get_jax()

Attributes

class quimb.tensor.interface.Placeholder(x)[source]
__slots__ = ('shape',)
__repr__()[source]

Return repr(self).

quimb.tensor.interface.pack(obj)[source]

Take a tensor or tensor network like object and return a skeleton needed to reconstruct it, and a pytree of raw parameters.

Parameters:

obj (Tensor, TensorNetwork, or similar) – Something that has copy, set_params, and get_params methods.

Returns:

  • params (pytree) – A pytree of raw parameter arrays.

  • skeleton (Tensor, TensorNetwork, or similar) – A copy of obj with all references to the original data removed.

quimb.tensor.interface.unpack(params, skeleton)[source]

Take a skeleton of a tensor or tensor network like object and a pytree of raw parameters and return a new reconstructed object with those parameters inserted.

Parameters:
  • params (pytree) – A pytree of raw parameter arrays, with the same structure as the output of skeleton.get_params().

  • skeleton (Tensor, TensorNetwork, or similar) – Something that has copy, set_params, and get_params methods.

Returns:

obj – A copy of skeleton with parameters inserted.

Return type:

Tensor, TensorNetwork, or similar

quimb.tensor.interface._JAX_REGISTERED_TN_CLASSES
quimb.tensor.interface.jax_pack(obj)[source]
quimb.tensor.interface.jax_unpack(aux, children)[source]
quimb.tensor.interface.jax_register_pytree()[source]
quimb.tensor.interface.get_jax()[source]