Skip to content

Commit 5135a21

Browse files
nathanchenseanwalterreniertsNathaniel Chenrenierts
authored
Large Update to Keras2C (#31)
* Added pyproject.toml to allow installation via pip. Tried to be more reluctant with requirements. Desired are only tensorflow, keras, and numpy. Hopefully without any constraints in the version numbers. * The first tests are passing. test_checks.py still fails. * Updated more tests. * 5 tests are not passing. The following tests fail: - test_Dense2_Activation() - test_dummy_layers() - test_repeat_vector() - test_Embedding1() - test_BatchNorm1() The following test is hanging: - test_SharedLayer1() * asdf * a * Further updates of the tests. * src * One test file is missing. Note that not all tests are passing yet. * fixed gcc input not being read * keras to tf keras * One test file is missing. Note that not all tests are passing yet. * dense1 fix and stuff * add foobar to gitignore * ignore egg-info * Only test_wrappers.py needs to be entirely updated. * Most of the tests are now passing. Particularly most of the code is compatible with the current keras/tensorflow versions. Next steps: - Work on all tests that are getting stuck in loops - Work on a few tests that fail (C issues most likely). * Bias issue is fixed. Next steps: - Work on all tests that are getting stuck in loops - Work on a few tests that fail (C issues most likely). * Added a test for an activation layer alone. Next steps: - Work on all tests that are getting stuck in loops - Work on a few tests that fail (C issues most likely). * Update README.rst Add citation request * Create python-app.yml * Create cmake-multi-platform.yml * Create python-publish.yml * Create python-package-conda.yml * Create c-cpp.yml * Create pylint.yml * Create summary.yml * Create greetings.yml * Create stale.yml * Add ThresholdedReLU test * Clarify array2c return values * Fix merge layer parsing * Fix typo in scratch notebook * Fix ThresholdedReLU weight stacking * Refactor imports for TensorFlow 2 * Refactor imports for TensorFlow 2 * Add conda installation option * Fix test generation and malloc initialization * docs: outline functional refactor for layer2c * Add conda environment file * Expand Travis CI matrix * Improve linting setup and docs * Remove unused import and define __all__ * Update license text to LGPLv3 * fix: ensure newline at EOF in pytest.ini * fix: remove unnecessary f-string * Use README.rst as project readme * Update pylint.yml * Use ruff for linting * Use ruff for linting * chore: replace flake8 with ruff * Update pre-commit config to use ruff * Configure Ruff * Switch linting to ruff * Fix dtype handling and update LeakyReLU * Add Pydantic models and integrate * Update ruff config * Configure Ruff * Clean tests of unused variables and imports * Fix long strings and docstrings * Remove unused imports * Clean up unused vars and except handling * Declare supported Python * Capture subprocess output for python36 * Replace __future__ annotations * Specify pytest by python version * Add pydantic runtime dependency * Update pyproject.toml * Update pyproject.toml * Update pyproject.toml * Fix padding input mapping * Align conda environment with pyproject * Update ruff workflow to Python 3.12 * Add silu activation support * Fix warnings in tests * Update python-app.yml * Update python-app.yml * Update python-app.yml * Update python-app.yml * Update python-app.yml * Update python-app.yml * removed cmake tests * CI: test on macOS and Windows * Allow compiler override via environment * Fix linking flag and build library in CI * CI: build C library with gcc --------- Co-authored-by: renierts <[email protected]> Co-authored-by: Nathaniel Chen <[email protected]> Co-authored-by: Peter Steiner <[email protected]>
1 parent 708b763 commit 5135a21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5917
-1410
lines changed

.github/workflows/greetings.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Greetings
2+
3+
on: [pull_request_target, issues]
4+
5+
jobs:
6+
greeting:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
steps:
12+
- uses: actions/first-interaction@v1
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}
15+
issue-message: "Message that will be displayed on users' first issue"
16+
pr-message: "Message that will be displayed on users' first pull request"

.github/workflows/python-app.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest, windows-latest]
21+
python-version: ["3.9", "3.10", "3.11", "3.12"]
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up build tools on Windows
27+
if: runner.os == 'Windows'
28+
uses: msys2/setup-msys2@v2
29+
with:
30+
msystem: MINGW64
31+
update: true
32+
install: >-
33+
mingw-w64-x86_64-gcc
34+
make
35+
- name: Set up Python 3.10
36+
uses: actions/setup-python@v3
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install ruff pytest
43+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
44+
shell: bash
45+
- name: Lint with ruff
46+
run: |
47+
ruff check .
48+
shell: bash
49+
- name: Build C library
50+
run: make CC=gcc -C include
51+
shell: bash
52+
- name: Test with pytest
53+
env:
54+
CC: gcc
55+
run: |
56+
pytest
57+
shell: bash
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Python Package using Conda
2+
3+
on: [push]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 5
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: '3.10'
17+
- name: Add conda to system path
18+
run: |
19+
# $CONDA is an environment variable pointing to the root of the miniconda directory
20+
echo $CONDA/bin >> $GITHUB_PATH
21+
- name: Install dependencies
22+
run: |
23+
conda env update --file environment.yml --name base
24+
- name: Lint with ruff
25+
run: |
26+
conda install -c conda-forge ruff
27+
ruff check .
28+
- name: Test with pytest
29+
run: |
30+
conda install pytest
31+
pytest
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
release-build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.x"
28+
29+
- name: Build release distributions
30+
run: |
31+
# NOTE: put your own distribution build steps here.
32+
python -m pip install build
33+
python -m build
34+
35+
- name: Upload distributions
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: release-dists
39+
path: dist/
40+
41+
pypi-publish:
42+
runs-on: ubuntu-latest
43+
needs:
44+
- release-build
45+
permissions:
46+
# IMPORTANT: this permission is mandatory for trusted publishing
47+
id-token: write
48+
49+
# Dedicated environments with protections for publishing are strongly recommended.
50+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51+
environment:
52+
name: pypi
53+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54+
# url: https://pypi.org/p/YOURPROJECT
55+
#
56+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57+
# ALTERNATIVE: exactly, uncomment the following line instead:
58+
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
59+
60+
steps:
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish release distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist/

.github/workflows/ruff.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Ruff Lint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.12"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ matrix.python-version }}
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install ruff
21+
- name: Analysing the code with ruff
22+
run: |
23+
ruff check .

.github/workflows/stale.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: '19 22 * * *'
11+
12+
jobs:
13+
stale:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
20+
steps:
21+
- uses: actions/stale@v5
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
stale-issue-message: 'Stale issue message'
25+
stale-pr-message: 'Stale pull request message'
26+
stale-issue-label: 'no-issue-activity'
27+
stale-pr-label: 'no-pr-activity'

.github/workflows/summary.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Summarize new issues
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
summary:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
models: read
13+
contents: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Run AI inference
20+
id: inference
21+
uses: actions/ai-inference@v1
22+
with:
23+
prompt: |
24+
Summarize the following GitHub issue in one paragraph:
25+
Title: ${{ github.event.issue.title }}
26+
Body: ${{ github.event.issue.body }}
27+
28+
- name: Comment with AI summary
29+
run: |
30+
gh issue comment $ISSUE_NUMBER --body '${{ steps.inference.outputs.response }}'
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
ISSUE_NUMBER: ${{ github.event.issue.number }}
34+
RESPONSE: ${{ steps.inference.outputs.response }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ __pycache__/
1414
*.gcno
1515
test___*
1616
docs/_build/*
17-
local/*
17+
local/*
18+
.venv/*
19+
foobar*
20+
*.egg-info/*

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.12
4+
hooks:
5+
- id: ruff

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ python:
33
- "3.6"
44
- "3.7"
55
- "3.8"
6+
- "3.9"
7+
- "3.10"
8+
- "3.11"
9+
- "3.12"
10+
- "3.13"
611

712
before_install:
813
- sudo apt-get install astyle

0 commit comments

Comments
 (0)