This release is a pre-release and may not be stable for production use.
Aidge Compression Module
A module for compressing Convolutional Neural Networks (CNNs).
This module decomposes convolutional layers into multiple smaller convolution operations, reducing the total number of computations and improving inference speed.
It provides a C++/Python interface for compression.
Installation
Work in progress — PyPI packages are not yet available.
From GitLab Package Registry (recommended)
The wheels are published to the Aidge GitLab Package Registry on every push to main (pre-release .dev0) and on tag commits (stable release).
Requires a GitLab personal access token with read_api scope (set as GITLAB_TOKEN):
export GITLAB_TOKEN=<your_personal_access_token>
# Install latest stable release
pip install aidge_compression \
--index-url https://gitlab.eclipse.org/api/v4/projects/eclipse%2Faidge%2Faidge_compression/packages/pypi/simple
# Install latest pre-release (dev version)
pip install --pre aidge_compression \
--index-url https://gitlab.eclipse.org/api/v4/projects/eclipse%2Faidge%2Faidge_compression/packages/pypi/simple
# Install a specific version
pip install aidge_compression==0.0.5 \
--index-url https://gitlab.eclipse.org/api/v4/projects/eclipse%2Faidge%2Faidge_compression/packages/pypi/simple
The dependencies
aidge_coreandaidge_backend_cpuare also published to the monorepo GitLab Package Registry. Add the monorepo index as well so pip can resolve them:
pip install aidge_compression \
--index-url https://gitlab.eclipse.org/api/v4/projects/eclipse%2Faidge%2Faidge_compression/packages/pypi/simple \
--extra-index-url https://gitlab.eclipse.org/api/v4/projects/eclipse%2Faidge%2Faidge/packages/pypi/simple
From PyPI (planned)
pip install aidge_compression
From source
Requires aidge_core and aidge_backend_cpu to be installed first (from GitLab Package Registry, PyPI, or built from source):
pip install aidge_core aidge_backend_cpu
pip install .
Requirements
System
- Python >= 3.10
- C++17 compiler (GCC, Clang, MSVC)
- CMake >= 3.22
- OpenMP support
Python dependencies (installed automatically)
| Package | Version |
|---|---|
| numpy | >= 1.21.6 |
| aidge_core | any |
C++ dependencies (fetched automatically at build time)
| Library | Version | Purpose |
|---|---|---|
| Eigen | 3.4.0 | Linear algebra |
| nlohmann/json | 3.11.3 | JSON parsing |
| pybind11 | >= 3.0 | Python bindings |
Aidge ecosystem
| Package | Role |
|---|---|
| aidge_core | Core graph, operators, tensor infrastructure |
| aidge_backend_cpu | CPU backend (required for compression evaluation) |
Building from source
# With Python bindings (default)
pip install .
# C++ only, without Python
cmake -B build -DPYBIND=OFF
cmake --build build
# With tests
cmake -B build -DTEST=ON
cmake --build build
ctest --test-dir build
CMake options:
| Option | Default | Description |
|---|---|---|
PYBIND |
ON | Build Python bindings |
WERROR |
ON | Treat warnings as errors |
TEST |
OFF | Build C++ unit tests |
COVERAGE |
OFF | Enable code coverage (GCC only) |
Usage
Example usage with resnet18, where the first convolution is ignored, and manual ranks are assigned to specific layers (-1 ignores the layer, [0.,1.] represents a weakening factor):
import aidge_core
import aidge_onnx
import aidge_compression
model = aidge_onnx.load_onnx("resnet18.onnx")
ignores = {"conv1_Conv"}
ranks = {
"layer1_layer1_1_conv1_Conv": -1.,
"layer2_layer2_0_conv1_Conv": -1.,
}
aidge_compression.Compressor(ignores, ranks, 0.8).compress(model)
aidge_onnx.export_onnx(
model,
"resnet18_0.8.onnx",
inputs_dims={
list(model.get_input_nodes(aidge_core.InputCategory.Data))[0].name(): [
[1, 3, 224, 224]
]
},
outputs_dims={list(model.get_output_nodes())[0].name(): [[1, 100]]},
opset=18,
)
A more complete set of examples to use this module is provided in the examples/ folder, including a tutorial notebook.
Compression methods
This module compresses CNNs through tensor decomposition, replacing a single convolutional tensor with multiple smaller tensors, reducing computational complexity.
{width=50%}
The process starts with rank selection for each layer's decomposition:
-
Without a training dataset: The module uses VBMF to estimate the rank for each layer.
-
With a training dataset: It leverages inference on the dataset to assess the impact of decomposition on each layer.
-
With a partial dataset: The method can still use the available data, but it's preferable to ensure the dataset represents various cases the network will encounter.
Following rank selection, each layer undergoes Tucker-2 decomposition or WeightSVD:
{width=50%}
-
WeightSVD: Applied to 2D tensors, replacing a single tensor with two smaller ones.
-
Tucker-2: Applied to 4D tensors, replacing a 4D tensor with two 2D tensors and a smaller 4D tensor.
TODO list
- Tucker-2 implementation.
- VBMF rank automatic selection.
- Weight SVD for linear tensors.
- Validation dataset aided rank selection.
- CP decomposition
- Automatic hybrid selection between CP / Tucker
- Robust network decomposition
Metadata
Release files for aidge-compression 0.0.5.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| aidge_compression-0.0.5.dev0-cp313-cp313-manylinux_2_35_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.35+ x86-64 | Details for aidge_compression-0.0.5.dev0-cp313-cp313-manylinux_2_35_x86_64.whl |
| aidge_compression-0.0.5.dev0-cp312-cp312-manylinux_2_35_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.35+ x86-64 | Details for aidge_compression-0.0.5.dev0-cp312-cp312-manylinux_2_35_x86_64.whl |
| aidge_compression-0.0.5.dev0-cp311-cp311-manylinux_2_35_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.35+ x86-64 | Details for aidge_compression-0.0.5.dev0-cp311-cp311-manylinux_2_35_x86_64.whl |
| aidge_compression-0.0.5.dev0-cp310-cp310-manylinux_2_35_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.35+ x86-64 | Details for aidge_compression-0.0.5.dev0-cp310-cp310-manylinux_2_35_x86_64.whl |
Total release size: 3.3 MB
Release files / aidge_compression-0.0.5.dev0-cp313-cp313-manylinux_2_35_x86_64.whl
| Download URL | aidge_compression-0.0.5.dev0-cp313-cp313-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 831.9 kB |
| Tags | CPython 3.13 Linux glibc 2.35+ x86-64 |
|
SHA-256 checksum How to use checksums |
e1d3195ca82f2bbee36a0f80899770631253f9c055e9ffbe5ab3fdac8cf700d8
|
|
BLAKE2b-256 checksum How to use checksums |
8498bef465851e46226661ac4521370a6cce1a84a20b0bcfb8be5df299fb3900
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / aidge_compression-0.0.5.dev0-cp312-cp312-manylinux_2_35_x86_64.whl
| Download URL | aidge_compression-0.0.5.dev0-cp312-cp312-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 831.0 kB |
| Tags | CPython 3.12 Linux glibc 2.35+ x86-64 |
|
SHA-256 checksum How to use checksums |
6a6223f0f4c9fb8edccbbbd4668fe9e59271e5b31bc52bf3d59ac11276526864
|
|
BLAKE2b-256 checksum How to use checksums |
1874bcdc9324e5eae2b20059c2ca6c05008d57dcf34c6fdb1f337c5a7517890a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / aidge_compression-0.0.5.dev0-cp311-cp311-manylinux_2_35_x86_64.whl
| Download URL | aidge_compression-0.0.5.dev0-cp311-cp311-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 825.9 kB |
| Tags | CPython 3.11 Linux glibc 2.35+ x86-64 |
|
SHA-256 checksum How to use checksums |
5156505d32f5e2ee1d55b63c29e51ebf9c520dd2357277b5d9e33588f61fdaa3
|
|
BLAKE2b-256 checksum How to use checksums |
067a479463b0ff14fbda5045fc3a671cafb5d25528c6750547a6c06bb99da9b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / aidge_compression-0.0.5.dev0-cp310-cp310-manylinux_2_35_x86_64.whl
| Download URL | aidge_compression-0.0.5.dev0-cp310-cp310-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 820.6 kB |
| Tags | CPython 3.10 Linux glibc 2.35+ x86-64 |
|
SHA-256 checksum How to use checksums |
43baa9e33bc6c37c981a212620b2ed8185ae49c709108ee7e20b59c7cc61780b
|
|
BLAKE2b-256 checksum How to use checksums |
6d32c9f06d0a2bde1b9accb00c98b39606571e6af3f1674607f0ab635cc77944
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for aidge-compression 0.0.5.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.