quimb.tensor.belief_propagation.sparse_ops¶
Specialized kernels for belief propagation with sparse COO tensors and
dense vector messages. Both sparse.COO and n-dimensional
scipy.sparse.coo_array are supported.
Functions¶
|
Get the |
|
Convert a possibly sparse array to a dense numpy array. |
|
Numba kernel that computes all outgoing messages for COO tensor. |
|
Numba kernel that fully contracts a COO tensor with all incoming |
|
Make sure COO format tensor and messages are ready for numba kernels. |
|
Given messages |
|
Contract a sparse tensor with a dense vector message on every |
|
Sum the sparse tensor |
Module Contents¶
- quimb.tensor.belief_propagation.sparse_ops.parse_coo(x)¶
Get the
(coords, data)pair of a COO array, withcoordsas a tuple of one flat coordinate array per dimension. ReturnsNoneifxis not a COO array with zero fill value. Duplicate coordinates are allowed, since every kernel here accumulates additively.
- quimb.tensor.belief_propagation.sparse_ops.to_dense(x)¶
Convert a possibly sparse array to a dense numpy array.
- quimb.tensor.belief_propagation.sparse_ops._compute_all_tensor_messages_coo(coords, data, ms, out)¶
Numba kernel that computes all outgoing messages for COO tensor.
- quimb.tensor.belief_propagation.sparse_ops._contract_all_messages_coo(coords, data, ms, out)¶
Numba kernel that fully contracts a COO tensor with all incoming messages.
- quimb.tensor.belief_propagation.sparse_ops._prepare_coo_ms_for_numba(coo, ms)¶
Make sure COO format tensor and messages are ready for numba kernels.
- quimb.tensor.belief_propagation.sparse_ops.compute_all_tensor_messages_coo(coo, ms)¶
Given messages
msincident to a sparse tensor, compute all the outgoing messages, each the contraction of the tensor with every incident message but one.
- quimb.tensor.belief_propagation.sparse_ops.contract_tensor_messages_coo(coo, ms)¶
Contract a sparse tensor with a dense vector message on every dimension, to a scalar.
- quimb.tensor.belief_propagation.sparse_ops.sum_all_but_axis_coo(x, axis)¶
Sum the sparse tensor
xover every dimension butaxis, returning a dense vector. This is the BP ‘uniform message’ initialization step.