Skip to main content

Efficient convolution for sparse data on FPGAs

Project description

SparsePixels: Efficient convolution for sparse data on FPGAs

arXiv PyPI - Version

Note: We are actively working on hls4ml integration to auto-convert sparse models to HLS, along with a major upgrade with partial parallelization and streaming for sparse layers in HLS. Stay tuned!

Installation

With Python >= 3.10:

pip install sparsepixels

Getting Started

Import sparse layers and quantization library (HGQ2):

import keras
from keras.layers import Flatten, Activation, ReLU
from hgq.layers import QConv2D, QDense
from hgq.config import QuantizerConfigScope, LayerConfigScope
from sparsepixels.layers import InputReduce, QConv2DSparse, AveragePooling2DSparse

Build an example sparse CNN within HGQ2 quantization scopes:

with (
    QuantizerConfigScope(place='all', default_q_type='kbi', overflow_mode='SAT_SYM'),
    QuantizerConfigScope(place='datalane', default_q_type='kif', overflow_mode='WRAP'),
    LayerConfigScope(enable_ebops=False, enable_iq=False),
):
    x_in = keras.Input(shape=(x_train.shape[1], x_train.shape[2], x_train.shape[3]), name='x_in')

    # Sparse input reduction: retain up to n_max_pixels active pixels
    x, keep_mask = InputReduce(n_max_pixels=20, threshold=0.1, name='input_reduce')(x_in)

    # Sparse convolution
    x = QConv2DSparse(filters=3, kernel_size=3, name='conv1', padding='same', strides=1)([x, keep_mask])
    x = ReLU(name='relu1')(x)

    # Sparse pooling
    x, keep_mask = AveragePooling2DSparse(2, name='pool1')([x, keep_mask])

    x = Flatten(name='flatten')(x)
    x = QDense(10, name='dense1', activation='relu')(x)
    x = Activation('softmax', name='softmax')(x)

model = keras.Model(x_in, x)

We are working on hls4ml integration that auto parses the sparse layers into HLS.

Documentation

Citation

If you find this useful in your research, please consider citing:

@article{Tsoi:2025nvg,
    author = "Tsoi, Ho Fung and Rankin, Dylan and Loncar, Vladimir and Harris, Philip",
    title = "{SparsePixels: Efficient Convolution for Sparse Data on FPGAs}",
    eprint = "2512.06208",
    archivePrefix = "arXiv",
    primaryClass = "cs.AR",
    month = "12",
    year = "2025"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparsepixels-0.2.1.tar.gz (82.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparsepixels-0.2.1-py3-none-any.whl (80.4 kB view details)

Uploaded Python 3

File details

Details for the file sparsepixels-0.2.1.tar.gz.

File metadata

  • Download URL: sparsepixels-0.2.1.tar.gz
  • Upload date:
  • Size: 82.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sparsepixels-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5b9ad9ab7425be2e1beef8075ceb96ab3ac57c7dbc3067c9511c51b7fb6ac4c9
MD5 af82a793bb8756aff0d5f0ec69e0949b
BLAKE2b-256 a9ec8a84bfcf67dccbbf720343e48237a0fafac3a3e5f02af41d49c8c9eaa069

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparsepixels-0.2.1.tar.gz:

Publisher: publish.yml on hftsoi/sparse-pixels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparsepixels-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sparsepixels-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 80.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sparsepixels-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a93db3b344e3098617002b375ce71037ef1bc4e88f14e15aa443efa0294d135
MD5 24be527a73712959c1068188eda715d4
BLAKE2b-256 02a792c65a2ab08be19aca7a8f5fc26cdeb723b9154ed80798be5791eb3159b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparsepixels-0.2.1-py3-none-any.whl:

Publisher: publish.yml on hftsoi/sparse-pixels

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page