Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speeding up snips by communicating less often #26

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ nengo_loihi/snips/nengo_io.c

# For .ipynb examples
*.pdf
examples/communication_channel.py
examples/integrator.py
examples/integrator_multi_d.py
examples/keyword_spotting.py
examples/learn_communication_channel.py
examples/oscillator.py
examples/oscillator_nonlinear.py
examples/*.pkl
*.pkl
docs/examples/communication_channel.py
docs/examples/integrator.py
docs/examples/integrator_multi_d.py
docs/examples/keyword_spotting.py
docs/examples/learn_communication_channel.py
docs/examples/oscillator.py
docs/examples/oscillator_nonlinear.py
20 changes: 20 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.MathJax .mi, .MathJax .mo {
color: inherit;
}

pre, kdb, samp, code, .rst-content tt, .rst-content code {
word-break: inherit;
}

code, .rst-content tt, .rst-content code {
white-space: pre-wrap;
}

#notebook .container {
padding-left: 0;
width: inherit;
}

.body img {
max-width: 100%;
}
13 changes: 13 additions & 0 deletions docs/_templates/globaltoc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="sidebar-block">
<div class="sidebar-wrapper">
<h2>{{ _('Table Of Contents') }}</h2>
</div>
<div class="sidebar-toc">
{% set toctree = toctree(maxdepth=3, collapse=True) %}
{% if toctree %}
{{ toctree }}
{% else %}
{{ toc }}
{% endif %}
</div>
</div>
8 changes: 8 additions & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# Import the theme's layout. #}
{% extends "!layout.html" %}

{%- block extrahead %}
<link rel="stylesheet" type="text/css" href="{{ pathto("_static/custom.css", 1) }}">
{# Call the parent block #}
{{ super() }}
{%- endblock %}
29 changes: 29 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*************
API reference
*************

.. default-role:: obj

.. autosummary::

nengo_loihi.add_params
nengo_loihi.set_defaults
nengo_loihi.Simulator
nengo_loihi.builder.Model
nengo_loihi.builder.Builder
nengo_loihi.loihi_cx.CxSimulator
nengo_loihi.loihi_interface.LoihiSimulator

.. autofunction:: nengo_loihi.add_params

.. autofunction:: nengo_loihi.set_defaults

.. autoclass:: nengo_loihi.Simulator

.. autoclass:: nengo_loihi.builder.Model

.. autoclass:: nengo_loihi.builder.Builder

.. autoclass:: nengo_loihi.loihi_cx.CxSimulator

.. autoclass:: nengo_loihi.loihi_interface.LoihiSimulator
117 changes: 117 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# -*- coding: utf-8 -*-
#
# This file is execfile()d with the current directory set
# to its containing dir.

import sys

try:
import nengo_loihi
import guzzle_sphinx_theme
except ImportError:
print("To build the documentation, nengo_loihi and guzzle_sphinx_theme "
"must be installed in the current environment. Please install these "
"and their requirements first. A virtualenv is recommended!")
sys.exit(1)

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.githubpages',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'guzzle_sphinx_theme',
'numpydoc',
'nbsphinx',
]

default_role = 'py:obj'

# -- sphinx.ext.autodoc
autoclass_content = 'both' # class and __init__ docstrings are concatenated
autodoc_default_flags = ['members']
autodoc_member_order = 'bysource' # default is alphabetical

# -- sphinx.ext.intersphinx
intersphinx_mapping = {
'nengo': ('https://www.nengo.ai/nengo/', None),
'numpy': ('https://docs.scipy.org/doc/numpy', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
}

# -- sphinx.ext.todo
todo_include_todos = True

# -- numpydoc
numpydoc_show_class_members = False

# -- nbsphinx
nbsphinx_timeout = -1

# -- sphinx
nitpicky = True
exclude_patterns = ['_build']
source_suffix = '.rst'
source_encoding = 'utf-8'
master_doc = 'index'

# Need to include https Mathjax path for sphinx < v1.3
mathjax_path = ("https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/"
"config/TeX-AMS-MML_HTMLorMML.js")

project = u'Nengo Loihi'
authors = u'Applied Brain Research'
copyright = nengo_loihi.__copyright__
version = '.'.join(nengo_loihi.__version__.split('.')[:2])
release = nengo_loihi.__version__ # Full version, with tags
pygments_style = 'default'

# -- Options for HTML output --------------------------------------------------

pygments_style = "sphinx"
templates_path = ["_templates"]
html_static_path = ["_static"]

html_theme_path = guzzle_sphinx_theme.html_theme_path()
html_theme = "guzzle_sphinx_theme"

html_theme_options = {
"project_nav_name": "Nengo Loihi %s" % (version,),
"base_url": "https://www.nengo.ai/nengo-loihi",
}

html_title = "Nengo Loihi {0} docs".format(release)
htmlhelp_basename = 'Nengo Loihi'
html_last_updated_fmt = '' # Suppress 'Last updated on:' timestamp
html_show_sphinx = False

# -- Options for LaTeX output -------------------------------------------------

latex_elements = {
'papersize': 'letterpaper',
'pointsize': '11pt',
# 'preamble': '',
}

latex_documents = [
# (source start file, target, title, author, documentclass [howto/manual])
('index', 'nengo_loihi.tex', html_title, authors, 'manual'),
]

# -- Options for manual page output -------------------------------------------

man_pages = [
# (source start file, name, description, authors, manual section).
('index', 'nengo_loihi', html_title, [authors], 1)
]

# -- Options for Texinfo output -----------------------------------------------

texinfo_documents = [
# (source start file, target, title, author, dir menu entry,
# description, category)
('index', 'nengo_loihi', html_title, authors, 'Nengo',
'Loihi backend for Nengo', 'Miscellaneous'),
]
19 changes: 19 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**************
Example models
**************

The following examples are similar
to the `Nengo core examples <https://www.nengo.ai/nengo/examples.html>`_,
but run using Nengo Loihi.
We compare performance with Nengo core where appropriate.

.. toctree::
:maxdepth: 1

examples/communication_channel
examples/integrator
examples/integrator_multi_d
examples/oscillator
examples/oscillator_nonlinear
examples/learn_communication_channel
examples/keyword_spotting
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Integrator\n",
"# Multidimensional integrator\n",
"\n",
"This demo implements an N-dimensional neural integrator.\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"This example uses optimized parameters\n",
"generated by Nengo DL:\n",
"\n",
"- [`reference_params.pkl`](\n",
"* [reference_params.pkl](\n",
"https://drive.google.com/open?id=149rLqXnJqZPBiqvWpOAysGyq4fvunlnM)\n",
"- [`test_stream.pkl`](\n",
"* [test_stream.pkl](\n",
"https://drive.google.com/open?id=1AQavHjQKNu1sso0jqYhWj6zUBLKuGNvV)\n",
"\n",
"If you have `requests` installed,\n",
Expand Down Expand Up @@ -272,7 +272,7 @@
" return stream[ti % len(stream)]\n",
"\n",
" model.inp.output = play_stream\n",
" n_steps = stream.shape[1]\n",
" n_steps = stream.shape[0]\n",
"\n",
" sim = nengo_loihi.Simulator(model, dt=dt, precompute=True)\n",
" with sim:\n",
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
***********
Nengo Loihi
***********

A backend for running Nengo models on Intel's Loihi architecture.

To use the backend, simply replace::

nengo.Simulator(model)

with::

nengo_loihi.Simulator(model)

.. toctree::
:maxdepth: 2

overview
installation
examples
api
tips
setup/index
Loading