Update to Keras2C#31
Update to Keras2C#31nathanchenseanwalter merged 142 commits intoPlasmaControl:masterfrom nathanchenseanwalter:master
Conversation
Tried to be more reluctant with requirements. Desired are only tensorflow, keras, and numpy. Hopefully without any constraints in the version numbers.
test_checks.py still fails.
The following tests fail: - test_Dense2_Activation() - test_dummy_layers() - test_repeat_vector() - test_Embedding1() - test_BatchNorm1() The following test is hanging: - test_SharedLayer1()
…ompatible 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).
Next steps: - Work on all tests that are getting stuck in loops - Work on a few tests that fail (C issues most likely).
Next steps: - Work on all tests that are getting stuck in loops - Work on a few tests that fail (C issues most likely).
Add citation request
Create python-app.yml
…s-using-uv-add Fix padding input mapping and update dependencies
…a-support-for-pytest Update conda env and tests
…nt-to-3.12 Update ruff workflow to Python 3.12
…r-silu-activation-in-keras2c Fix swish LSTM support
…-warnings-on-github Fix warnings from Keras 3
…flow-for-cross-platform-testing Add Windows/macOS CI support
…iguration-and-documentation Allow overriding compiler
…w-and-test-helpers-for-gcc Fix GCC build in workflow and tests
…encies-in-workflow
…brary-and-build-dependencies-in-workflow Fix library linking and CI build step
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes imports, refactors code formatting, updates license to LGPLv3, and standardizes testing patterns across the repository.
- Switched all
import tensorflow.keras as kerastofrom tensorflow.keras(orfrom tensorflow import keras) and unified use ofInput(shape=…). - Refactored C code generation to use f-strings, improved error/log messages, and integrated Pydantic
Keras2CConfigandLayerIOtypes. - Updated test suites with
@unittest.skip, modern imports, and consistent model building patterns.
Reviewed Changes
Copilot reviewed 65 out of 68 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_wrappers.py | Updated imports, added skips, and unified model syntax |
| tests/test_recurrent_layers.py | Refactored to use Input(shape=…), removed eager flags |
| tests/test_pooling_layers.py | Switched to direct layer imports and unified model syntax |
| tests/test_models.py | Consolidated imports, added skip decorators, refactored Sequential usage |
| tests/test_merge_layers.py | Updated Dot axes naming and Input(shape=…) usage |
| tests/test_malloc.py | Added skip decorator, aligned imports |
| tests/test_core_layers.py | Enhanced docstring, refactored test names and imports |
| tests/test_convolution_layers.py | Reformatted Conv layers with multi-line f-strings |
| tests/test_checks.py | Switched assertion style to context manager, updated imports |
| tests/test_advanced_activation_layers.py | Modernized LeakyReLU and ThresholdedReLU usage |
| src/keras2c/backend.py | Introduced single backend import module |
| src/keras2c/weights2c.py | Refactored array2c to use f-strings, updated license |
| src/keras2c/types.py | Added Pydantic models for config and IO |
| src/keras2c/make_test_suite.py | Overhauled test suite generation, improved subprocess handling |
| src/keras2c/layer2c.py | Refactored IO naming, added return types, modernized layer writers |
| src/keras2c/keras2c_main.py | Integrated Keras2CConfig, updated file-write modes |
| src/keras2c/io_parsing.py | Created new unified IO parsing with backend import |
| src/keras2c/check_model.py | Expanded supported activations, improved log formatting |
| include/makefile | Made CC overrideable via environment |
| setup.py | Added minimal setup.py scaffold |
| pyproject.toml & requirements files | Updated dependencies and version brackets |
Comments suppressed due to low confidence (3)
src/keras2c/make_test_suite.py:28
- Using
shell=Truewith a concatenatedCCenvironment variable may allow shell injection. Prefer passing the command and arguments as a list and avoidshell=True.
stateful=False,
src/keras2c/weights2c.py:1
- The module docstring still references MIT License but the file header now lists LGPLv3. Update the docstring to match the new LGPLv3 license.
"""weights2c.py
src/keras2c/layer2c.py:74
- [nitpick] Add a docstring for
_format_io_namesexplaining its parameters and the returnedLayerIOfields.
def _format_io_names(self, layer, inp, outp, model_io=False) -> LayerIO:
| """tests for layer wrappers""" | ||
| """Tests for layer wrappers""" | ||
|
|
||
| @unittest.skip # no reason needed |
There was a problem hiding this comment.
[nitpick] Skips should include a clear reason or refactoring ticket, e.g. @unittest.skip("wrapper not supported yet"), to improve traceability.
| @unittest.skip # no reason needed | |
| @unittest.skip("Bidirectional wrapper not supported yet") |
| reset_sig, reset_fun = gen_function_reset(function_name) | ||
|
|
||
| with open(function_name + '.c', 'x+') as source: | ||
| with open(function_name + '.c', 'w') as source: |
There was a problem hiding this comment.
Switching from 'x+' to 'w' allows overwriting existing files without warning. Consider using 'x' or checking for file existence before writing to prevent accidental data loss.
| with open(function_name + '.c', 'w') as source: | |
| with open(function_name + '.c', 'x') as source: |
|
Large new release update to Keras2C. Contains breaking changes, this will be a new version (will have the link to the previous version). |
No description provided.