Skip to main content

Neuromorphic Intermediate Representation

Project description

NIRTorch

PyTorch helpers for the Neuromorphic Intermediate Representation (NIR). This is a no frills python package to enable torch based libraries to translate to NIR.

Installation

pip install nirtorch

Usage

NIRTorch is typically only interfaced by library/hardwarae developers. NIRTorch provides the extract_nir_graph function that takes as input a torch.nn.Module and a means to map Torch modules into NIR nodes. An NIR node is an element in the NIR compute graph, corresponding to neuromorphic ODEs.

Here is an example from the Norse library:

def _extract_norse_module(module: torch.nn.Module) -> Optional[nir.NIRNode]:
    if isinstance(module, LIFBoxCell):
        return nir.LIF(
            tau=module.p.tau_mem_inv,
            v_th=module.p.v_th,
            v_leak=module.p.v_leak,
            r=torch.ones_like(module.p.v_leak),
        )
    elif isinstance(module, torch.nn.Linear):
        return nir.Linear(module.weight, module.bias)
    elif ...

    return None

def to_nir(
    module: torch.nn.Module, sample_data: torch.Tensor, model_name: str = "norse"
) -> nir.NIRNode:
    return extract_nir_graph(
        module, _extract_norse_module, sample_data, model_name=model_name
    )

Acknowledgements

If you use NIR torch in your work, please cite the following Zenodo reference

@software{nir2023,
  author       = {Abreu, Steven and
                  Bauer, Felix and
                  Eshraghian, Jason and
                  Jobst, Matthias and
                  Lenz, Gregor and
                  Pedersen, Jens Egholm and
                  Sheik, Sadique},
  title        = {Neuromorphic Intermediate Representation},
  month        = jul,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {0.0.1},
  doi          = {10.5281/zenodo.8105042},
  url          = {https://doi.org/10.5281/zenodo.8105042}
}

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

nirtorch-0.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

nirtorch-0.0.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file nirtorch-0.0.2.tar.gz.

File metadata

  • Download URL: nirtorch-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for nirtorch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0d571a59ee5474b1626c757e9748a569fff3f6aa74c63b60b20ee5757955b3f3
MD5 0042eab641a5ae07efc122feee0d634f
BLAKE2b-256 e27c830e56ef804a51283ee6b13878d980672541ece44b7671349bd3bcce1d16

See more details on using hashes here.

File details

Details for the file nirtorch-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: nirtorch-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for nirtorch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38a1b581029fe33fef1ae1f5559fb65d1fef2cf10a380d40816952daabbc75d1
MD5 c8e3cd97842e6d1b0f86b25c60c78856
BLAKE2b-256 dc8c2693926eae1bc3f82ed404466d820297f68cec8fe4e4a82c6beec04eaff7

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