Skip to content

Commit

Permalink
Update ci-build.yml (#42)
Browse files Browse the repository at this point in the history
* Update ci-build.yml

* Delete setup.py

* Delete requirements.txt

* Delete build.py

* Delete build-requirements.txt

* Update README.md

* Update pyproject.toml

Drop coverage requirement to 45% as project only has this amount of coverage for now.

* Fix non-printable character U+00A0

Fix python invalid non-printable character U+00A0

* Fix nonprintable characters, add poetry.lock
  • Loading branch information
mgkwill authored Mar 8, 2022
1 parent 70ab5ab commit 2c20061
Show file tree
Hide file tree
Showing 11 changed files with 2,358 additions and 269 deletions.
101 changes: 81 additions & 20 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
lint:
name: Lint with flake8
name: Lint Code
runs-on: ubuntu-latest

steps:
Expand All @@ -14,17 +14,38 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pybuilder
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run pybuilder w/o unit tests
run: |
pyb analyze
- name: Install Lava
run: poetry install --no-interaction

- name: Run flakeheaven (flake8)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
source $VENV
flakeheaven lint src/lava tests/
- name: Run flakeheaven (flake8)
if: runner.os == 'Windows'
run: |
.venv\Scripts\activate.ps1
flakeheaven lint src/lava tests/
security-lint:
name: Security Lint with bandit
name: Security Lint Code
runs-on: ubuntu-latest

steps:
Expand All @@ -35,17 +56,35 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pybuilder
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run pybuilder to lint security w/ bandit
run: |
pyb bandit
- name: Install Lava
run: poetry install --no-interaction

- name: Run bandit
uses: tj-actions/[email protected]
with:
targets: |
src/lava/.
options: "-r --format custom --msg-template '{abspath}:{line}: {test_id}[bandit]: {severity}: {msg}'"

unit-tests:
name: Run unit tests
name: Unit Test Code + Coverage
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
Expand All @@ -59,12 +98,34 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-01-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pybuilder
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install Lava
run: poetry install --no-interaction

- name: Run unit tests
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
source $VENV
pytest
- name: Run unit tests
if: runner.os == 'Windows'
run: |
pyb -E unit
.venv\Scripts\activate.ps1
pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ share/python-wheels/
*.egg
MANIFEST

.vscode

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The library presently consists of

More tools will be added in the future.

## Lava-DL Workflow
## Lava-DL Workflow

<p align="center">
<img src="https://user-images.githubusercontent.com/29907126/140595634-a97886c6-280a-4771-830b-ae47a9324612.png" alt="Drawing" style="max-height: 400px;"/>
Expand Down Expand Up @@ -142,16 +142,16 @@ __Network Description__
class Network(torch.nn.Module):
def __init__(self):
...
self.blocks = torch.nn.ModuleList([# sequential network blocks 
slayer.block.sigma_delta.Input(sdnn_params), 
slayer.block.sigma_delta.Conv(sdnn_params,  324, 3),
slayer.block.sigma_delta.Conv(sdnn_params, 24, 36, 3),
slayer.block.rf_iz.Conv(rf_params, 36, 64, 3, delay=True),
slayer.block.rf_iz.Conv(sdnn_cnn_params, 64, 64, 3, delay=True),
self.blocks = torch.nn.ModuleList([# sequential network blocks
slayer.block.sigma_delta.Input(sdnn_params),
slayer.block.sigma_delta.Conv(sdnn_params, 3, 24, 3),
slayer.block.sigma_delta.Conv(sdnn_params, 24, 36, 3),
slayer.block.rf_iz.Conv(rf_params, 36, 64, 3, delay=True),
slayer.block.rf_iz.Conv(sdnn_cnn_params, 64, 64, 3, delay=True),
slayer.block.rf_iz.Flatten(),
slayer.block.alif.Dense(alif_params, 64*40, 100, delay=True),
slayer.block.cuba.Recurrent(cuba_params, 100, 50),
slayer.block.cuba.KWTA(cuba_params, 50, 50, num_winners=5)
slayer.block.alif.Dense(alif_params, 64*40, 100, delay=True),
slayer.block.cuba.Recurrent(cuba_params, 100, 50),
slayer.block.cuba.KWTA(cuba_params, 50, 50, num_winners=5)
])

def forward(self, x):
Expand Down Expand Up @@ -205,15 +205,15 @@ __Network Description__
class Network(torch.nn.Module):
def __init__(self):
...
self.blocks = torch.nn.ModuleList([# sequential network blocks 
bootstrap.block.cuba.Input(sdnn_params), 
bootstrap.block.cuba.Conv(sdnn_params,  324, 3),
bootstrap.block.cuba.Conv(sdnn_params, 24, 36, 3),
bootstrap.block.cuba.Conv(rf_params, 36, 64, 3),
bootstrap.block.cuba.Conv(sdnn_cnn_params, 64, 64, 3),
self.blocks = torch.nn.ModuleList([# sequential network blocks
bootstrap.block.cuba.Input(sdnn_params),
bootstrap.block.cuba.Conv(sdnn_params, 3, 24, 3),
bootstrap.block.cuba.Conv(sdnn_params, 24, 36, 3),
bootstrap.block.cuba.Conv(rf_params, 36, 64, 3),
bootstrap.block.cuba.Conv(sdnn_cnn_params, 64, 64, 3),
bootstrap.block.cuba.Flatten(),
bootstrap.block.cuba.Dense(alif_params, 64*40, 100),
bootstrap.block.cuba.Dense(cuba_params, 100, 10),
bootstrap.block.cuba.Dense(alif_params, 64*40, 100),
bootstrap.block.cuba.Dense(cuba_params, 100, 10),
])

def forward(self, x, mode):
Expand Down Expand Up @@ -251,20 +251,20 @@ __Export the network__
net.export_hdf5('network.net')
```

## __`lava.lib.dl.netx`__ 
## __`lava.lib.dl.netx`__

For inference using Lava, `lava.lib.dl.netx` provides an automated API for loading SLAYER-trained models as Lava Processes, which can be directly run on a desired backend. `lava.lib.dl.netx` imports models saved via SLAYER using the hdf5 network exchange format. The details of hdf5 network description specification can be found [here](https://github.com/lava-nc/lava-dl/blob/main/src/lava/lib/dl/netx/README.md).
For inference using Lava, `lava.lib.dl.netx` provides an automated API for loading SLAYER-trained models as Lava Processes, which can be directly run on a desired backend. `lava.lib.dl.netx` imports models saved via SLAYER using the hdf5 network exchange format. The details of hdf5 network description specification can be found [here](https://github.com/lava-nc/lava-dl/blob/main/src/lava/lib/dl/netx/README.md).

### Example Code

__Import modules__
__Import modules__
```python
from lava.lib.dl.netx import hdf5
from lava.lib.dl.netx import hdf5
```
__Load the trained network__
__Load the trained network__
```python
# Import the model as a Lava Process
net = hdf5.Network(net_config='network.net')
net = hdf5.Network(net_config='network.net')
```
__Attach Processes for Input-Output interaction__
```python
Expand All @@ -282,7 +282,7 @@ dataloader.s_out.connect(net.in_layer.neuron.a_in)
# Connect network-output to the output process
net.out_layer.out.connect(output_logger.a_in)
```
__Run the network__
__Run the network__
```python
from lava.magma import run_configs as rcfg
from lava.magma import run_conditions as rcnd
Expand Down
6 changes: 0 additions & 6 deletions build-requirements.txt

This file was deleted.

101 changes: 0 additions & 101 deletions build.py

This file was deleted.

Loading

0 comments on commit 2c20061

Please sign in to comment.