acetone-nnet


Nameacetone-nnet JSON
Version 0.3.2.post3 PyPI version JSON
download
home_pageNone
SummaryPredictable programming framework for ML applications in safety-critical systems.
upload_time2024-07-01 14:47:12
maintainerNone
docs_urlNone
authorNone
requires_python<3.12,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ACETONE
Predictable programming framework for ML applications in safety-critical systems.

This repo contains the code of the framework presented in the ECRTS'22 paper  ["ACETONE: Predictable programming framework for ML applications in safety-critical systems"](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECRTS.2022.3).

This framework generate a C code corresponding to a neural network given as input.

## Package

The corresponding package is named [acetone-nnet](https://pypi.org/project/acetone-nnet/). 

The folder [tests/examples](./tests/examples/) give examples on how to use the main functionnalities of the package (code generation and debug mode)

The folder [tests/check_installation](./tests/check_installation/) give a file with a few quick test checking some main, functionalities of the package, as an quick verification of the installation.


## Code architecture

You'll find in the home directory the files regarding the licencing and copyright of the framework:

* [AUTHORS.md](./AUTHORS.md)
* [LICENSE](./LICENSE)

This directory also contains the [requirements.txt](./requirements.txt) which list the package versionning used in the framework.

The [test](./test/) directory includes several tests for the framework and the data to run them.

The [src](./src/) folder contains the backend code of ACETONE.

## Installation

### User mode

Install le package using `pip`
```
pip install acetone-nnet
```


### Development Mode

Clone the GitHub repo on your computer

```
git clone https://github.com/onera/acetone.git
```

Then install the packages listed in [`requirements.txt`](./requirements.txt)

```
pip install -r acetone/requirements.txt
```


## Code Generation

The following commands generate a test neural network before generating the corresponding C code using ACETONE.

### Generating the neural network

In the *acetone* directory

* Run the *initial_setup.py* code
```
python3 tests/models/lenet5/lenet5_example/initial_setup.py
```

This script defines a neural network with a Lenet-5 architecture using the framework Keras. It then save the model in *.h5* and *.json* files. The later one is created using a specific function, developped by us, to write the keras model in ACETONE's format. The scripts also creates a random input to test the neural network. Finally, the scripts saves and prints, as a reference, the output of the inference done by the Keras framework.

### Generating the C code with ACETONE package

Then, generate the C code with ACETONE.

* Call ACETONE with the following arguments:
  * The file describing the model
  * The name of the function to generate (here 'lenet5')
  * The number of test to run (here 1)
  * The algorithm used for the convolution layer ('6loops','indirect_gemm_'+TYPE, 'std_gemm_'+TYPE, with TYPE being amongst 'nn','nt',    'tn','tt')
  * The directory in which the code will be generated
  * The input file with the test data

```
acetone_generate tests/models/lenet5/lenet5_example/lenet5.h5  lenet5 1 std_gemm_nn tests/models/lenet5/lenet5_example/lenet5_generated tests/models/lenet5/lenet5_example/test_input_lenet5.txt
```

* Compile the code
```
make -C tests/models/lenet5/lenet5_example/lenet5_generated all
```

* Execute the file with the path to the directory of the output file as argument
```
./tests/models/lenet5/lenet5_example/lenet5_generated/lenet5 ./tests/models/lenet5/lenet5_example/lenet5_generated/output_acetone.txt
```

* Compare the output given by Keras and ACETONE
```
acetone_compare ./tests/models/lenet5/lenet5_example/output_keras.txt ./tests/models/lenet5/lenet5_example/lenet5_generated/output_acetone.txt 1
```

## Tests

Tests are implemented in the folder *tests*.

To run them, use the `run_tests.py` script from the `tests/` folder.
```
python3 run_tests.py all
```

You can replace the `all` argument by the name of a subfolder to only run the tests in it.
```
python3 run_tests.py FOLDER_NAME
```
where FOLDER_NAME is the name of your subfolder.

You can run one test by using the command
```
python3 -m unittest PATH_TO_TEST
```
where PATH_TO_TEST is the path tot your test.

## Reproduce the paper's experiments

To reproduce the result of semantic experiment with ACETONE as described in the paper, use the following commands:

* For the acas_decr128 model
```
acetone_generate tests/models/acas/acas_decr128/acas_decr128.json acas_dcre128 1000 std_gemm_nn tests/models/acas/acas_decr128/output_acetone tests/models/acas/acas_decr128/test_input_acas_decr128.txt
make -C tests/models/acas/acas_decr128/output_acetone all
./tests/models/acas/acas_decr128/output_acetone/acas_decr128 tests/models/acas/acas_decr128/output_acetone/output_acetone.txt
acetone_compare tests/models/acas/acas_decr128/output_keras.txt tests/models/acas/acas_decr128/output_acetone/output_acetone.txt
```

* For the lent5 model

```
acetone_generate tests/models/lenet5/lenet5_trained/lenet5_trained.json lenet5_trained 1000 std_gemm_nn tests/models/lenet5/lenet5_trained/output_acetone tests/models/lenet5_trained/test_input_lenet5.txt
make -C tests/models/lenet5/lenet5_trained/output_acetone all
./tests/models/lenet5/lenet5_trained/output_acetone/lenet5_trained tests/models/lenet5/lenet5_trained/output_acetone/output_acetone.txt
acetone_compare tests/models/lenet5/lenet5_trained/output_keras.txt tests/models/lenet5/lenet5_trained/output_acetone/output_acetone.txt
```

## Capability

Please refer to the [`implemented.md`](./implemented.md) file to see the current capabilities of the framework.

## License

The project is under the GNU Lesser General Public License as published by the Free Software Foundation ; either version 3 of  the License or (at your option) any later version.

See LICENSE for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "acetone-nnet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Yanis AIT-AISSA <Yanis.AIT-AISSA@student.isae-supaero.fr>, Thomas CARLE <Thomas.Carle@irit.fr>, Iryna DE ALBUQUERQUE SILVA <Iryna.De_Albuquerque_Silva@onera.fr>, Adrien GAUFFRIAU <Adrien.Gauffriau@airbus.com>, Benjamin LESAGE <benjamin.lesage@onera.fr>, Claire PAGETTI <Claire.Pagetti@onera.fr>",
    "download_url": "https://files.pythonhosted.org/packages/13/fa/bf29ca029a43cf50add4337e65cde4fcf93d627e129070727ed7e5fb01ca/acetone_nnet-0.3.2.post3.tar.gz",
    "platform": null,
    "description": "# ACETONE\nPredictable programming framework for ML applications in safety-critical systems.\n\nThis repo contains the code of the framework presented in the ECRTS'22 paper  [\"ACETONE: Predictable programming framework for ML applications in safety-critical systems\"](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECRTS.2022.3).\n\nThis framework generate a C code corresponding to a neural network given as input.\n\n## Package\n\nThe corresponding package is named [acetone-nnet](https://pypi.org/project/acetone-nnet/). \n\nThe folder [tests/examples](./tests/examples/) give examples on how to use the main functionnalities of the package (code generation and debug mode)\n\nThe folder [tests/check_installation](./tests/check_installation/) give a file with a few quick test checking some main, functionalities of the package, as an quick verification of the installation.\n\n\n## Code architecture\n\nYou'll find in the home directory the files regarding the licencing and copyright of the framework:\n\n* [AUTHORS.md](./AUTHORS.md)\n* [LICENSE](./LICENSE)\n\nThis directory also contains the [requirements.txt](./requirements.txt) which list the package versionning used in the framework.\n\nThe [test](./test/) directory includes several tests for the framework and the data to run them.\n\nThe [src](./src/) folder contains the backend code of ACETONE.\n\n## Installation\n\n### User mode\n\nInstall le package using `pip`\n```\npip install acetone-nnet\n```\n\n\n### Development Mode\n\nClone the GitHub repo on your computer\n\n```\ngit clone https://github.com/onera/acetone.git\n```\n\nThen install the packages listed in [`requirements.txt`](./requirements.txt)\n\n```\npip install -r acetone/requirements.txt\n```\n\n\n## Code Generation\n\nThe following commands generate a test neural network before generating the corresponding C code using ACETONE.\n\n### Generating the neural network\n\nIn the *acetone* directory\n\n* Run the *initial_setup.py* code\n```\npython3 tests/models/lenet5/lenet5_example/initial_setup.py\n```\n\nThis script defines a neural network with a Lenet-5 architecture using the framework Keras. It then save the model in *.h5* and *.json* files. The later one is created using a specific function, developped by us, to write the keras model in ACETONE's format. The scripts also creates a random input to test the neural network. Finally, the scripts saves and prints, as a reference, the output of the inference done by the Keras framework.\n\n### Generating the C code with ACETONE package\n\nThen, generate the C code with ACETONE.\n\n* Call ACETONE with the following arguments:\n  * The file describing the model\n  * The name of the function to generate (here 'lenet5')\n  * The number of test to run (here 1)\n  * The algorithm used for the convolution layer ('6loops','indirect_gemm_'+TYPE, 'std_gemm_'+TYPE, with TYPE being amongst 'nn','nt',    'tn','tt')\n  * The directory in which the code will be generated\n  * The input file with the test data\n\n```\nacetone_generate tests/models/lenet5/lenet5_example/lenet5.h5  lenet5 1 std_gemm_nn tests/models/lenet5/lenet5_example/lenet5_generated tests/models/lenet5/lenet5_example/test_input_lenet5.txt\n```\n\n* Compile the code\n```\nmake -C tests/models/lenet5/lenet5_example/lenet5_generated all\n```\n\n* Execute the file with the path to the directory of the output file as argument\n```\n./tests/models/lenet5/lenet5_example/lenet5_generated/lenet5 ./tests/models/lenet5/lenet5_example/lenet5_generated/output_acetone.txt\n```\n\n* Compare the output given by Keras and ACETONE\n```\nacetone_compare ./tests/models/lenet5/lenet5_example/output_keras.txt ./tests/models/lenet5/lenet5_example/lenet5_generated/output_acetone.txt 1\n```\n\n## Tests\n\nTests are implemented in the folder *tests*.\n\nTo run them, use the `run_tests.py` script from the `tests/` folder.\n```\npython3 run_tests.py all\n```\n\nYou can replace the `all` argument by the name of a subfolder to only run the tests in it.\n```\npython3 run_tests.py FOLDER_NAME\n```\nwhere FOLDER_NAME is the name of your subfolder.\n\nYou can run one test by using the command\n```\npython3 -m unittest PATH_TO_TEST\n```\nwhere PATH_TO_TEST is the path tot your test.\n\n## Reproduce the paper's experiments\n\nTo reproduce the result of semantic experiment with ACETONE as described in the paper, use the following commands:\n\n* For the acas_decr128 model\n```\nacetone_generate tests/models/acas/acas_decr128/acas_decr128.json acas_dcre128 1000 std_gemm_nn tests/models/acas/acas_decr128/output_acetone tests/models/acas/acas_decr128/test_input_acas_decr128.txt\nmake -C tests/models/acas/acas_decr128/output_acetone all\n./tests/models/acas/acas_decr128/output_acetone/acas_decr128 tests/models/acas/acas_decr128/output_acetone/output_acetone.txt\nacetone_compare tests/models/acas/acas_decr128/output_keras.txt tests/models/acas/acas_decr128/output_acetone/output_acetone.txt\n```\n\n* For the lent5 model\n\n```\nacetone_generate tests/models/lenet5/lenet5_trained/lenet5_trained.json lenet5_trained 1000 std_gemm_nn tests/models/lenet5/lenet5_trained/output_acetone tests/models/lenet5_trained/test_input_lenet5.txt\nmake -C tests/models/lenet5/lenet5_trained/output_acetone all\n./tests/models/lenet5/lenet5_trained/output_acetone/lenet5_trained tests/models/lenet5/lenet5_trained/output_acetone/output_acetone.txt\nacetone_compare tests/models/lenet5/lenet5_trained/output_keras.txt tests/models/lenet5/lenet5_trained/output_acetone/output_acetone.txt\n```\n\n## Capability\n\nPlease refer to the [`implemented.md`](./implemented.md) file to see the current capabilities of the framework.\n\n## License\n\nThe project is under the GNU Lesser General Public License as published by the Free Software Foundation ; either version 3 of  the License or (at your option) any later version.\n\nSee LICENSE for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Predictable programming framework for ML applications in safety-critical systems.",
    "version": "0.3.2.post3",
    "project_urls": {
        "Bug Tracker": "https://github.com/onera/acetone/issues",
        "Repository": "https://github.com/onera/acetone/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df49aaeac376526ab89a737a2b197c8506e35b8c160dc033337a4e72bca72642",
                "md5": "21574cbf69086d33fec8f22ed1300f7f",
                "sha256": "e8b14694838853a5e5fdbe4b8618183a87094422310f606475398e6b5b007077"
            },
            "downloads": -1,
            "filename": "acetone_nnet-0.3.2.post3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "21574cbf69086d33fec8f22ed1300f7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.10",
            "size": 172097,
            "upload_time": "2024-07-01T14:47:10",
            "upload_time_iso_8601": "2024-07-01T14:47:10.412007Z",
            "url": "https://files.pythonhosted.org/packages/df/49/aaeac376526ab89a737a2b197c8506e35b8c160dc033337a4e72bca72642/acetone_nnet-0.3.2.post3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "13fabf29ca029a43cf50add4337e65cde4fcf93d627e129070727ed7e5fb01ca",
                "md5": "648424e5a3937cb93d6ace8533c03149",
                "sha256": "84277727d678d96be373dfa33cad2f5ed0401ca08b3e5203695a346b09583c11"
            },
            "downloads": -1,
            "filename": "acetone_nnet-0.3.2.post3.tar.gz",
            "has_sig": false,
            "md5_digest": "648424e5a3937cb93d6ace8533c03149",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.10",
            "size": 82316,
            "upload_time": "2024-07-01T14:47:12",
            "upload_time_iso_8601": "2024-07-01T14:47:12.712735Z",
            "url": "https://files.pythonhosted.org/packages/13/fa/bf29ca029a43cf50add4337e65cde4fcf93d627e129070727ed7e5fb01ca/acetone_nnet-0.3.2.post3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-01 14:47:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "onera",
    "github_project": "acetone",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "acetone-nnet"
}
        
Elapsed time: 0.62516s