Skip to main content

Leveraging Taichi Lang to customize brain dynamics operators

Project description

Leveraging Taichi Lang to Customize Brain Dynamics Operators

Header image of braintaichi.

Supported Python Version LICENSE Documentation Status PyPI version Continuous Integration

braintaichi leverages Taichi Lang to customize brain dynamics operators.

Quick Start

import taichi as ti

import braintaichi as bti


# define the custom kernel

@ti.kernel
def transpose_bool_homo_kernel(
    values: ti.types.ndarray(ndim=1),
    indices: ti.types.ndarray(ndim=1),
    indptr: ti.types.ndarray(ndim=1),
    events: ti.types.ndarray(ndim=1),
    out: ti.types.ndarray(ndim=1)
):
    value = values[0]
    ti.loop_config(serialize=True)
    for row_i in range(indptr.shape[0] - 1):
        if events[row_i]:
            for j in range(indptr[row_i], indptr[row_i + 1]):
                out[indices[j]] += value


kernel = bti.XLACustomOp(
    cpu_kernel=transpose_bool_homo_kernel,
    gpu_kernel=transpose_bool_homo_kernel,
)

# run with the sample data

import numpy as np
import jax
import jax.numpy as jnp
from scipy.sparse import csr_matrix

csr = csr_matrix((np.random.rand(10, 10) < 0.5).astype(float))
events = np.random.rand(10) < 0.5

out = kernel(
    jnp.array(csr.data),
    jnp.array(csr.indices),
    jnp.array(csr.indptr),
    events,
    outs=[jax.ShapeDtypeStruct([10], dtype=jnp.float32)]
)
print(out)

Installation

You can install braintaichi via pip:

pip install braintaichi --upgrade

Documentation

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

See also the BDP ecosystem

We are building the brain dynamics programming ecosystem: https://ecosystem-for-brain-dynamics.readthedocs.io/

Citation

If you think braintaichi is significant in your work, please consider to cite the following pubilication:

@inproceedings{wang2024brainpy,
    title={A differentiable brain simulator bridging brain simulation and brain-inspired computing},
    author={Wang, Chaoming and Zhang, Tianqiu and He, Sichao and Gu, Hongyaoxing and Li, Shangyang and Wu, Si},
    booktitle={The Twelfth International Conference on Learning Representations},
    year={2024}
}

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

braintaichi-0.0.5-cp312-cp312-win_amd64.whl (373.6 kB view details)

Uploaded CPython 3.12Windows x86-64

braintaichi-0.0.5-cp312-cp312-manylinux_2_28_x86_64.whl (41.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

braintaichi-0.0.5-cp312-cp312-macosx_11_0_arm64.whl (14.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

braintaichi-0.0.5-cp311-cp311-win_amd64.whl (373.2 kB view details)

Uploaded CPython 3.11Windows x86-64

braintaichi-0.0.5-cp311-cp311-manylinux_2_28_x86_64.whl (41.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

braintaichi-0.0.5-cp311-cp311-macosx_11_0_arm64.whl (14.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

braintaichi-0.0.5-cp310-cp310-win_amd64.whl (371.5 kB view details)

Uploaded CPython 3.10Windows x86-64

braintaichi-0.0.5-cp310-cp310-manylinux_2_28_x86_64.whl (41.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

braintaichi-0.0.5-cp310-cp310-macosx_11_0_arm64.whl (14.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file braintaichi-0.0.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c3fdc330edb27cd00bdc3b313ed2f3f368ffdcfa1b7ca9439f741b54111dbbba
MD5 0c8e89ce5ac2b446415cc670fad02101
BLAKE2b-256 73085b70dc4ab6fbd636a6ac3efa7b0987eb3e6159c17c7956d1d59e5d5f4b7c

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00b9a5392052939ed21f16f605331b07bf4a28a9efbc601212df80365ec1da07
MD5 ca688cf97e9bd3dcc86eec4ad1c51862
BLAKE2b-256 30b192555e20a92394b03b328f6e8e139a2c9f32cb9c0589f668708bbe87a6ec

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 692a99af729355f0d49a904761366451c555972cf0a7d6a13338cf5856f434bd
MD5 c9d902b2b78ccfd47f0858e0d07dc8f2
BLAKE2b-256 39a2254f634f564fdad14ac03de9a3852d7f13d5d3fa5217cb6b76eed852032d

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 45763bd1036738af976bafcdfc0c8dc171966382d50df0ea01d129a764f66d47
MD5 fbf13e4270bca8c44de4e752a23344fc
BLAKE2b-256 e4b2b14ce67748913536cee049a2d557ee611c2f52949b0646a47427460fe456

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f707eeb1abf4c395c71413b6d37f9b72d1902840d7bf5c196cf7eee3d0adfa7
MD5 8ba08453a2a42ab32cbece592a27be31
BLAKE2b-256 d80a325e9b9ec8d67d01aed74a8f31b83afab2809c5274bacb1ff9119ba0d888

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 824833a3cb850de9c54d967b87ca0fe8a48a02eb3cb9002a34275e39e0a47bb2
MD5 8da2f0126b7554e75fc7523c18920be7
BLAKE2b-256 ed9c21e333fba6faf28a7aa6d438f1af35be443b539d48fb639fe06e3a04274b

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1877ffc720afcbf62a9e5c3711edd49f43efe673349659f123a16767c253b0d5
MD5 db1c65df85b20e3571a5bff37942198a
BLAKE2b-256 7ac29e1401ba7dfc86327a8f830d0cdb43108a835c671c9107e74eb88708ec6f

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28dd349effa2f75192c743a6fde10eec32afebf94579ef5a05a3d3f79f768d68
MD5 a0417c7225e818a55967e8cd76c90639
BLAKE2b-256 0bd5307eacd8b3516b26f7015a1cf5d7c38d3e14d49427acf688534ec0cdf741

See more details on using hashes here.

File details

Details for the file braintaichi-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for braintaichi-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e72d803b11008832a8195dde6cfbf09ec96f0455e0f902e6e2d1f9664f83a06e
MD5 8195fe28e508b68936f16b2d1e66b30c
BLAKE2b-256 3d5644a71b15dbc9611988fe6e89af9e5797d5e0f2376200febef76d8fdd8b75

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