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
Hashes for femtocrux-0.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1f2f8dfc95c9c3ed2a35591b49162698b8a5924c98c9829aa8e446479f02bf9 |
|
MD5 | 9dec37dc51068e9a5c1e2a441c165d0a |
|
BLAKE2b-256 | a34f681e445ac8c1ee3e08b862bce9be575bac07051fd57044f7c3666bbee612 |