Skip to main content

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 ?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

utensor_cgen-0.0.3-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

utensor_cgen-0.0.3-py2.py3-none-any.whl (29.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file utensor_cgen-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for utensor_cgen-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32fde09dd48f2eceee80aa52b1c9caa84563dbb93da9880960c78e89e749032e
MD5 31f34a87883b4626a4a84ac266054fdc
BLAKE2b-256 b605210974d16c1d39f4778536790ef5a49967eae2ece1321fb6d72280598f28

See more details on using hashes here.

File details

Details for the file utensor_cgen-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for utensor_cgen-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1b6fc17e45ff2b4fb2ff88b1eaf1dc14170c270e35fd2605590349100a4a392a
MD5 2c5d13ecd37b8e872b6b0309e52847fb
BLAKE2b-256 099942e5e00989b794e6d19c777bb73d63877d42115f07474351a39d1ea673b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page