Femtosense Compiler
Project description
femtocrux
Compiler API for the Femotsense Sparse Processing Unit (SPU).
This package drives compilation of machine learning models to SPU binaries, as well as simulation of those binaries on SPU hardware.
The package itself is a thin Python wrapper communicating to the actual compiler / simulator via gRPC.
Supported ML model representations:
- Femtosense Quantized IR (FQIR)
Installation
You will need to have python 3.10
and Docker installed.
Install Docker by following these instructions.
femtocrux is available on PyPI via
pip install femtocrux
Basic Usage
ManagedCompilerClient
ManagedCompilerClient
is the recommended way to use femtocrux within a context manager.
from femtocrux import ManagedCompilerClient, FQIRModel
# fqir_graph = ... # Assuming we have an FQIR graph using fmot
# inputs = ... # Assuming we have numpy array inputs to the model
fqir_model = FQIRModel(fqir_graph, batch_dim=0, sequence_dim=1)
with ManagedCompilerClient() as client:
# simulate execution, view power, energy, and latency metrics
simulator = client.simulate(fqir_model)
outputs, metrics = simulator.simulate(inputs)
# compile the model to a bitfile
bitstream = client.compile(fqir_model)
with open('my_bitfile.zip', 'wb') as f:
f.write(bitstream)
The bitfile can be used to generate program files to run on the SPU, using femtodriverpub
CompilerClient
CompilerClient
is another interface to the compiler. This will be deprecated in future releases, so we recommend using ManagedCompilerClient
.
from femtocrux import CompilerClient, FQIRModel
# fqir_graph = ... # Assuming we have an FQIR graph using fmot
# inputs = ... # Assuming we have numpy array inputs to the model
fqir_model = FQIRModel(fqir_graph, batch_dim=0, sequence_dim=1)
client = CompilerClient()
# simulate execution, view power, energy, and latency metrics
simulator = client.simulate(fqir_model)
outputs, metrics = simulator.simulate(inputs)
# compile the model to a bitfile
bitstream = client.compile(fqir_model)
with open('my_bitfile.zip', 'wb') as f:
f.write(bitstream)
# close the client (important to avoid background docker containers that continue running)
client.close()
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 Distribution
File details
Details for the file femtocrux-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: femtocrux-0.6.3-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbda5f93ecc1eefa756b4f2d51c65b4e0bfef6294a83cbe32f9faeec508d4ffa |
|
MD5 | bd9c12e23d2e60309d0b5b09e71e26d7 |
|
BLAKE2b-256 | 85d2d4c44968a058c13a7b2c5ba937c8e1872e90854643c157cb19da60d2d899 |