BitPackedBinary#
- class brainevent.BitPackedBinary(arr)#
Bit-packed binary event representation.
BitPackedBinarystores binary spike data as uint32 words where each word encodes 32 consecutive spikes. Packing is performed along every axis, so the number of packed arrays equals the number of dimensions.Instances are typically created via
BinaryArray.bitpack()rather than direct construction.- Parameters:
arr (jax.Array) – The original binary spike array (bool or 0/1).
Notes
The class stores both the original spike array (
value) and one packed uint32 representation per axis (packed). The original array is used for autodiff (gradient propagation), while the packed arrays are used for efficient CUDA kernel computation.The class is registered as a JAX PyTree node, so it is compatible with
jax.jit,jax.grad,jax.vmap, and other transformations.See also
BinaryArrayUnpacked binary event representation.
BinaryArray.bitpackCreates a
BitPackedBinaryfrom aBinaryArray.
- property T#
Transpose of the bit-packed binary array.
- Returns:
A new transposed instance.
- Return type:
- property ndim#
Number of dimensions of the original array.
- Returns:
Same as
len(self.original_shape).- Return type:
- property original_shape#
Shape of the original (unpacked) boolean array.
- property packed#
Tuple of packed uint32 arrays, one per axis.
- Returns:
packed[i]is the uint32 array obtained by packing along axisi. Its shape matches the original shape except that dimensioniisceil(original_shape[i] / 32).- Return type:
tuple[jax.Array, …]
- property shape#
Logical shape (original unpacked shape).
- transpose(*axes)[source]#
Return a transposed
BitPackedBinary.- Parameters:
*axes (int, optional) – Axis permutation. If omitted, reverses the axis order (standard transpose).
- Returns:
A new instance with permuted axes. Both
valueand allpackedarrays are transposed accordingly.- Return type:
- tree_flatten()[source]#
Flatten this instance for JAX PyTree serialisation.
- Returns:
children (tuple) –
(value, packed[0], packed[1], ...)— the original spike array followed by packed uint32 arrays for each axis.aux_data (dict) – Contains
original_shape.