C code generation program for uTensor
Project description
# Installation (Python3)
## `setup.py`
1. `python3 setup.py bdist_wheel`
2. `cd dist`
3. `python3 -m pip install utensor_cgen-<whatever>.whl`
## `pip`
1. run `python3 -m pip install utensor_cgen`
This package is under beta development, using `virtualenv` is recommanded.
# Example
1. `example.py`:
1. run `python3 example.py` and it should generate a `main.cpp` file.
2. compile it and run, you should see familier hello world message
2. `simple_graph.pb`:
1. install `utensor_cgen` by running `python3 setup.py install`
2. run `python3 -m utensor_cgen simple_graph.pb`
3. it will save constant tensor data in `idx_data/` and generate two files, `model.hpp` and `model.cpp`.
4. compile your `uTensor` project with `model.hpp` and `model.cpp` and copy `idx_data/` to your SD card.
5. You should have a running simple graph.
<center>
<img alt=simple-graph src=images/simple_graph.png />
</center>
# User Guild
Following steps are a general guild for user how to porting a `TensorFlow` protobuf file into a `uTensor` implementation:
1. Freeze and quantize your graph
- [Freezing](https://www.tensorflow.org/extend/tool_developers/#freezing)
- [Quantization](https://www.tensorflow.org/performance/quantization)
- An alternative is to use the [`quantize_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/quantization/quantize_graph.py) script
- it should output one qunatized pb file, say `quantized_graph.pb`
2. install `utensor_cgent`
- run `python3 setupt.py install`
3. run `utensor-cli quantized_graph.pb`, where `quantized_graph.pb` is the output pb file you get from step **1**
- run `utensor-cli -h` for help
# TODOs
1. (done) Freezed graph protobuff parser
2. (done)Tensor snippets for [`uTensor`](https://github.com/neil-tan/uTensor)
3. (done) Add template engine for richer flexibility
- [jinja2](http://jinja.pocoo.org)
4. (done?) core code generator implementation
- We need some refatoring, PRs are welcomed!
5. type alias in C/C++
- ex: use `uint8_t` or `unsigned char`?
- a lot more about this....
6. `MANIFAST.in` for the `setup.py`
7. Relation among snippets/containers
- shared template variables? (headers, shared placeholders...etc)
8. Better configuration schema
- json
- yaml
- or ?
## `setup.py`
1. `python3 setup.py bdist_wheel`
2. `cd dist`
3. `python3 -m pip install utensor_cgen-<whatever>.whl`
## `pip`
1. run `python3 -m pip install utensor_cgen`
This package is under beta development, using `virtualenv` is recommanded.
# Example
1. `example.py`:
1. run `python3 example.py` and it should generate a `main.cpp` file.
2. compile it and run, you should see familier hello world message
2. `simple_graph.pb`:
1. install `utensor_cgen` by running `python3 setup.py install`
2. run `python3 -m utensor_cgen simple_graph.pb`
3. it will save constant tensor data in `idx_data/` and generate two files, `model.hpp` and `model.cpp`.
4. compile your `uTensor` project with `model.hpp` and `model.cpp` and copy `idx_data/` to your SD card.
5. You should have a running simple graph.
<center>
<img alt=simple-graph src=images/simple_graph.png />
</center>
# User Guild
Following steps are a general guild for user how to porting a `TensorFlow` protobuf file into a `uTensor` implementation:
1. Freeze and quantize your graph
- [Freezing](https://www.tensorflow.org/extend/tool_developers/#freezing)
- [Quantization](https://www.tensorflow.org/performance/quantization)
- An alternative is to use the [`quantize_graph.py`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/quantization/quantize_graph.py) script
- it should output one qunatized pb file, say `quantized_graph.pb`
2. install `utensor_cgent`
- run `python3 setupt.py install`
3. run `utensor-cli quantized_graph.pb`, where `quantized_graph.pb` is the output pb file you get from step **1**
- run `utensor-cli -h` for help
# TODOs
1. (done) Freezed graph protobuff parser
2. (done)Tensor snippets for [`uTensor`](https://github.com/neil-tan/uTensor)
3. (done) Add template engine for richer flexibility
- [jinja2](http://jinja.pocoo.org)
4. (done?) core code generator implementation
- We need some refatoring, PRs are welcomed!
5. type alias in C/C++
- ex: use `uint8_t` or `unsigned char`?
- a lot more about this....
6. `MANIFAST.in` for the `setup.py`
7. Relation among snippets/containers
- shared template variables? (headers, shared placeholders...etc)
8. Better configuration schema
- json
- yaml
- or ?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
utensor_cgen-0.0.4.tar.gz
(21.1 kB
view details)
Built Distribution
File details
Details for the file utensor_cgen-0.0.4.tar.gz
.
File metadata
- Download URL: utensor_cgen-0.0.4.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a0f1a7887ca97b23623f31dc380df34b6ad2ed27f6b19259ac6b444fca3d7e |
|
MD5 | a3b9cb639883101dc0f342390e6c966d |
|
BLAKE2b-256 | e4f94a9c4c563604be1a1638e6edfb76ef7db6056f576686478f4a7bdf27ad02 |
File details
Details for the file utensor_cgen-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: utensor_cgen-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fe8b60c0911a44263899046f3237b49a813e8423aaaeef2dd5734b740ab5032 |
|
MD5 | be1cc99458648fbdc1f7503f0adecb41 |
|
BLAKE2b-256 | 0c934f628482d34c2c97f87ea4b5242892b2b7499776cfd375371a5f1c9406b7 |