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.2.tar.gz
(20.9 kB
view details)
Built Distribution
File details
Details for the file utensor_cgen-0.0.2.tar.gz
.
File metadata
- Download URL: utensor_cgen-0.0.2.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71a8e7a8d23fff93100e88177926d13d169dbf4ae9953a2663a9380195a68bcb |
|
MD5 | 6a66543592deef1b006b037d4ecfe6d2 |
|
BLAKE2b-256 | 87ccfffbaa7ef8d328869151825abbef8bea307e9c45b79fd269f26a9957ba15 |
File details
Details for the file utensor_cgen-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: utensor_cgen-0.0.2-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bdcd209648b838161ea7397014d95c248c03e9e0cfb82affd893b2b3ace765b |
|
MD5 | 6db3e70cff7eae825407494a322f40bd |
|
BLAKE2b-256 | b1c76aeec76f996984d39fb2ea1dc849891c8cea1b009389022691902e5df5f1 |