brainevent.fcnmv_dt2t#
- brainevent.fcnmv_dt2t = <NameScope(brainevent.fcnmv_dt2t)>#
Per-synapse element-wise product of a vector and fixed-connection weights.
For each stored connection slot
(i, k)of the fixed-connection-number (ELL) structure, computesout[i, k] = weights[i, k] * y[i]whentranspose=Falseorout[i, k] = weights[i, k] * y[indices[i, k]]whentranspose=True. The result has the same shape asindices(one value per structural non-zero).This is the fixed-connection-number analog of
brainevent.csrmv_dt2t()and follows the sametransposeconvention as that operator: the flag selects whetheryis indexed by the leading (row) axis or by the storedindices(column) axis. Note this is the opposite sense of thetransposeflag inbrainevent.fcnmv()/brainevent.fcnmm().Unlike
brainevent.csrmv_dt2t(), which returns a flat(nse,)vector because CSR stores its non-zeros in a 1-D array, this operator returns a 2-D array shaped likeindicesbecause the ELL layout stores non-zeros in a(rows, n_conn)grid.The operator is a plain element-wise / gather-multiply, so it is fully differentiable through JAX autodiff with respect to both
weightsandy; no custom differentiation rule is required. It is alsojit- andvmap-compatible.- Parameters:
weights (
Array|Quantity) – Per-synapse weights. Either a scalar / size-1 array (homogeneous) or a(rows, n_conn)array matchingindices(heterogeneous). Must be a floating-point dtype.indices (
Array) – Integer ELL index array of shape(rows, n_conn).y (
Array|Quantity) – Dense 1-D vector. Sizedshape[0]whentranspose=Falseorshape[1]whentranspose=True.shape (
Tuple[int,int]) – Two-element(rows_dim, cols_dim)logical shape of the ELL operand.transpose (
bool) – IfFalse, indexyby the leading axis (broadcast over the connection axis). IfTrue, indexybyindices(gather).
- Returns:
out – Per-synapse result of shape
indices.shape. The output unit isunit(weights) * unit(y).- Return type:
Array|Quantity- Raises:
ValueError – If
indicesis not 2-D.ValueError – If
shapeis not length-2.ValueError – If
weightsis not a floating-point dtype.ValueError – If
weightsis neither size-1 nor shaped likeindices.ValueError – If
yis not 1-D.ValueError – If
ydoes not have the length required bytransposeandshape.
See also
csrmv_dt2tCSR equivalent of this operator.
fcnmvFixed-connection sparse matrix–vector product.
fcnmmFixed-connection sparse matrix–matrix product.
Notes
Unlike
brainevent.csrmv_dt2t()(which dropsy’s physical unit), this operator keeps both units, consistent with thebrainevent.fcnmv()sibling and with the mathematics of a product.Mixed floating dtypes between
weightsandyare promoted following JAX’s standard promotion rules (e.g.float32 * float64 -> float64); no equal-dtype constraint is imposed.Empty structures are supported: an
indicesarray withrows == 0orn_conn == 0returns an array of the same (empty) shape.This operation is memory-bandwidth-bound and maps to a fused XLA broadcast-multiply (
transpose=False) or gather-multiply (transpose=True); it is therefore implemented in pure JAX rather than as a custom kernel.Examples
>>> import jax.numpy as jnp >>> from brainevent import fcnmv_dt2t >>> weights = jnp.array([[0.5, 1.0], [1.5, 2.0]]) >>> indices = jnp.array([[0, 1], [1, 2]]) >>> y = jnp.array([10.0, 20.0]) >>> fcnmv_dt2t(weights, indices, y, shape=(2, 3), transpose=False) Array([[ 5., 10.], [30., 40.]], dtype=float32) >>> # transpose=True gathers y by the stored column indices >>> y_post = jnp.array([1.0, 2.0, 3.0]) >>> fcnmv_dt2t(weights, indices, y_post, shape=(2, 3), transpose=True) Array([[0.5, 2. ], [3. , 6. ]], dtype=float32)