Skip to main content

Enabling Event-driven Computation in CPU/GPU/TPU.

Project description

Enabling Event-driven Computation in CPU/GPU/TPU

Header image of brainevent.

Supported Python Version LICENSE Documentation Status PyPI version Continuous Integration Daily CI Tests PyPI Downloads DOI

Brain is characterized by the discrete spiking events, which are the fundamental units of computation in the brain.

BrainEvent provides a set of data structures and algorithms for such event-driven computation on CPUs, GPUs, TPUs, and maybe more, which can be used to model the brain dynamics in an efficient and biologically plausible way.

Particularly, it provides the following class to represent binary events in the brain:

  • BinaryArray: representing array with a vector/matrix of events.

Furthermore, it implements the following commonly used data structures for event-driven computation of the above class:

  • COO: a sparse matrix in COO format for sparse and event-driven computation.
  • CSR: a sparse matrix in CSR format for sparse and event-driven computation.
  • CSC: a sparse matrix in CSC format for sparse and event-driven computation.
  • JITCHomoR: a just-in-time connectivity matrix with homogenous weight for sparse and event-driven computation.
  • JITCNormalR: a just-in-time connectivity matrix with normal distribution weight for sparse and event-driven computation.
  • JITCUniformR: a just-in-time connectivity matrix with uniform distribution weight for sparse and event-driven computation.
  • FixedPreNumConn: a fixed number of pre-synaptic connections for sparse and event-driven computation.
  • FixedPostNumConn: a fixed number of post-synaptic connections for sparse and event-driven computation.
  • ...

BrainEvent is fully compatible with physical units and unit-aware computations provided in BrainUnit.

Usage

If you want to take advantage of event-driven computations, you must warp your data with brainevent.BinaryArray:

import brainevent

# wrap your array with BinaryArray
event_array = brainevent.BinaryArray(your_array)

Then, the matrix multiplication with the following data structures, $\mathrm{event\ array} @ \mathrm{data}$, will take advantage of event-driven computations:

  • Sparse data structures provided by brainevent, like:
    • brainevent.CSR
    • brainevent.JITCHomoR
    • brainevent.FixedPostNumConn
    • ...
  • Dense data structures provided by JAX/NumPy, like:
    • jax.numpy.ndarray
    • numpy.ndarray
data = jax.random.rand(...)  # normal dense array
data = brainevent.CSR(...)  # CSR structure
data = brainevent.JITCScalarR(...)  # JIT connectivity
data = brainevent.FixedPostNumConn(...)  # fixed number of post-synaptic connections

# event-driven matrix multiplication
r = event_array @ data
r = data @ event_array

Installation

You can install brainevent via pip:

pip install brainevent -U

Alternatively, you can install BrainX, which bundles brainevent with other compatible packages for a comprehensive brain modeling ecosystem:

pip install BrainX -U

Documentation

The official documentation is hosted on Read the Docs: https://brainevent.readthedocs.io/

See also the ecosystem

brainevent is one part of our brain modeling ecosystem: https://brainmodeling.readthedocs.io/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brainevent-0.0.6.tar.gz (401.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brainevent-0.0.6-py3-none-any.whl (480.5 kB view details)

Uploaded Python 3

File details

Details for the file brainevent-0.0.6.tar.gz.

File metadata

  • Download URL: brainevent-0.0.6.tar.gz
  • Upload date:
  • Size: 401.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for brainevent-0.0.6.tar.gz
Algorithm Hash digest
SHA256 e0e4fc727864e08b4c0437f872cb8ea3462de7ac96abfdccd41621672f4de49b
MD5 ddc1afa16349c239b884f296e5a0ebb1
BLAKE2b-256 aa86313c10e5a0cedc0e42a187aec99d4d58f0d3d8facb1a6c5f8618b0409d1c

See more details on using hashes here.

File details

Details for the file brainevent-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: brainevent-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 480.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for brainevent-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 39a3d05e9637c3860aa8f71106c643f05b366d24e49bc64d9bc3285aa527e3d0
MD5 e90af32ddd9b8017c7a6385b8b82e378
BLAKE2b-256 8e255ed6b2ddd9c97ab36c8490ca427b23c9c70ee5b020e5bcb0f8766d069882

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page