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.7.0-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: femtocrux-0.7.0-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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 799617fe7d641b67cb0d9474d944399297d74aa2f805638a573fafdb56803b17
MD5 e1a0b1369c8f4cd4ba009f54783fa06f
BLAKE2b-256 2e622ea946328dfff907fde49f9bd10192903567ae4ba166b98f1c8198eff27e

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