XMOS AI Tools
Project description
Documentation
Index
- How to use the graph transformer to run a sample model app on XCORE.AI
- Usage from Python to run a sample model on host
- Graph transformer command-line options
- Transforming Pytorch models
- FAQ
- Changelog
- Advanced topics
Quick intro to xmos-ai-tools
xmos-ai-tools
is available on PyPI.
It includes:
- the MLIR-based XCore optimizer(xformer) to optimize Tensorflow Lite models for XCore
- the XCore tflm interpreter to run the transformed models on host
Perform the following steps once:
-
pip3 install xmos-ai-tools --upgrade
; use a virtual-environment of your choice.Use
pip3 install xmos-ai-tools --pre --upgrade
instead if you want to install the latest development version.
from xmos_ai_tools import xformer as xf
xf.convert("source model path", "converted model path", params=None)
where params
is a dictionary of compiler flags and parameters and their values.
For example:
from xmos_ai_tools import xformer as xf
xf.convert("example_int8_model.tflite", "xcore_optimised_int8_model.tflite", {
"xcore-thread-count": "5",
})
To see all available parameters, call
from xmos_ai_tools import xformer as xf
xf.print_help()
This will print all options available to pass to xformer. To see hidden options, run print_help(show_hidden=True)
To create a parameters file and a tflite model suitable for loading to flash, use the "xcore-flash-image-file" option.
xf.convert("example_int8_model.tflite", "xcore_optimised_int8_flash_model.tflite", {
"xcore-flash-image-file ": "./xcore_params.params",
})
Run model on host interpreter
from xmos_ai_tools.xinterpreters import xcore_tflm_host_interpreter
ie = xcore_tflm_host_interpreter()
ie.set_model(model_path='path_to_xcore_model', params_path='path_to_xcore_params')
ie.set_tensor(ie.get_input_details()[0]['index'], value='input_data')
ie.invoke()
xformer_outputs = []
for i in range(num_of_outputs):
xformer_outputs.append(ie.get_tensor(ie.get_output_details()[i]['index']))
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 Distributions
Built Distributions
Hashes for xmos_ai_tools-1.0.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47cc3d8a56b45da0979b3b13b5f3403abfd6abf89cd84d2bd0060c30890a4e3f |
|
MD5 | d054d2b56c96853c1174ff761e3d3716 |
|
BLAKE2b-256 | 68d30ced80400696d85f0ae5fc06ae14a01c7708927ee12c14163f140282dc09 |
Hashes for xmos_ai_tools-1.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d932ac8e00042b5c8675c97da3a2ad637c7443305b017ef0a0cc5b53f2b06b1 |
|
MD5 | 33cf6a217621ccce404a5a4e3a8f800e |
|
BLAKE2b-256 | a692687530775067c65d0de61f85243955d0389098643fcd97bad544ddecd6cc |
Hashes for xmos_ai_tools-1.0.0-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6131d9714940e931858994254de67b5c88588aa0d85547cd5fbe099a46920db1 |
|
MD5 | a955cb79020dc90759585eb7bcae741e |
|
BLAKE2b-256 | 35d72aac6e87ae3ff89c8bde9a7b4c1a1947a6707931bbe37cda219e534b3d98 |
Hashes for xmos_ai_tools-1.0.0-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc2ff1eb8ab3036782b418079cdc336188607818e8aefdcf6f4adcca6a030964 |
|
MD5 | 470c3e5e21f1589decffaea49594751f |
|
BLAKE2b-256 | fe2e6138ff136dc3548b39d5597f6aed37734d5daa13de07de1bc703781cc6d4 |