Skip to main content

XMOS AI Tools

Project description

XMOS AI Tools

Usage

xformer

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 paramters and their values.

For example:

from xmos_ai_tools import xformer as xf

xf.convert("example_int8_model.tflite", "xcore_optimised_int8_model.tflite", {
    "mlir-disable-threading": None,
    "xcore-reduce-memory": None,
})

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",
})

To use combine these files created by the code above into a .out file use the generate_flash() function

xf.generate_flash("xcore_optimised_int8_flash_model.tflite",  "xcore_params.params", "xcore_flash_binary.out")

xinterpreters

Host Interpreter

from xmos_ai_tools.xinterpreters import xcore_tflm_host_interpreter

ie = xcore_tflm_host_interpreter()
ie.set_model(model_path=xcore_model)
ie.set_tensor(ie.get_input_details()[0]['index'], value=input)
ie.invoke()

xformer_outputs = []
for i in range(num_of_outputs):
    xformer_outputs.append(ie.get_tensor(ie.get_output_details()[i]['index']))

Device Interpreter (USB)

from xmos_ai_tools.xinterpreters import xcore_tflm_usb_interpreter
from xmos_ai_tools.xinterpreters import xcore_tflm_spi_interpreter

ie = xcore_tflm_usb_interpreter()
ie.set_model(model_path=xcore_model, secondary_memory=False, flash=False)
ie.set_tensor(ie.get_input_details()[0]['index'], value=input)
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


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

xmos_ai_tools-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (44.6 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

xmos_ai_tools-0.2.1-py3-none-macosx_11_0_arm64.whl (15.3 MB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

xmos_ai_tools-0.2.1-py3-none-macosx_10_9_x86_64.whl (14.8 MB view hashes)

Uploaded Python 3 macOS 10.9+ x86-64

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