Skip to main content

Femtosense Compiler

Project description

Build Status

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


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 Distribution

femtocrux-0.6.1-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file femtocrux-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: femtocrux-0.6.1-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

Hashes for femtocrux-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 136d4c1211c2768de051e784b4ac3958cdaabdfc517d01f960180f59b157073c
MD5 7e0b75e6913303fb44f41f9cee85982d
BLAKE2b-256 fe568e0fd9895069b606671c8e9d75a9a323a77b28104f89d58bcbf6d75cc98e

See more details on using hashes here.

Provenance

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