Catalog PyPI
PACKAGE EXPLORERView in registry

AffineFlow-NN

PyPI

A high-performance C++ neural network backend for AffineFlow

autogradc++eigenmachine-learningneural-networks
Versions collected1
Direct dependencies1From release 0.1.1
Last observed20 Oct, 21:04 UTC

README

Version 0.1.1 documentation

AffineFlow-NN

PyPI version Python Build system Bindings

A high-performance, fully native C++ Neural Network engine exposed to Python via pybind11.

Designed for rapid experimentation without the Python Global Interpreter Lock (GIL) overhead, AffineFlow-NN executes the entire deep learning training loop strictly in native C++ using Eigen. It utilizes a zero-allocation flat-memory Autograd graph, AVX SIMD vectorization, and dynamically compiled OpenBLAS to achieve massive speedups over mainstream Python frameworks.

Highlights

  • Dual Execution Modes: Train dynamic graphs using the @nn.eager decorator for zero-allocation step-by-step execution, or compile static graphs with JITCompiler for maximum throughput.
  • Dynamic Hardware Dispatch: Automatically detects your CPU at runtime to dispatch highly optimized AVX2 or AVX-512 instructions.
  • CNN & Modern Layer Support: Built-in support for Conv2dLayer, MaxPool2dLayer, AvgPool2dLayer, FlattenLayer, BatchNorm1dLayer, DropoutLayer, and Leaky ReLUs.
  • Zero-Allocation Autograd: Uses arena allocation (Tape) and flat contiguous memory structs to dynamically build computational graphs without heap allocations.

Installation

Install the released wheel from PyPI:

pip install AffineFlow-NN

Quick Start: Building a CNN

import numpy as np
import affineflow_nn as nn

X_train = np.random.rand(100, 1, 64, 64).astype(np.float32)
y_train = np.eye(40, dtype=np.float32)[np.random.choice(40, 100)]

class AffineFlowNNDeepCNN(nn.Module):
    def __init__(self, in_h, in_w, num_classes):
        super().__init__()
        self.conv1 = nn.Conv2dLayer(1, 16, in_h, in_w, kernel_size=5, stride=1, pad=2)
        self.act1 = nn.LeakyReLULayer(0.01)
        self.pool1 = nn.MaxPool2dLayer(16, in_h, in_w, kernel_size=2, stride=2, pad=0)
        
        out_h1, out_w1 = in_h // 2, in_w // 2
        self.conv2 = nn.Conv2dLayer(16, 32, out_h1, out_w1, kernel_size=3, stride=1, pad=1)
        self.act2 = nn.LeakyReLULayer(0.01)
        self.pool2 = nn.MaxPool2dLayer(32, out_h1, out_w1, kernel_size=2, stride=2, pad=0)
        
        out_h2, out_w2 = out_h1 // 2, out_w1 // 2
        self.flatten = nn.FlattenLayer()
        self.fc = nn.DenseLayer(32 * out_h2 * out_w2, num_classes)

    def forward(self, x):
        x = self.pool1(self.act1(self.conv1(x)))
        x = self.pool2(self.act2(self.conv2(x)))
        x = self.flatten(x)
        return self.fc(x)

model = AffineFlowNNDeepCNN(64, 64, 40)
optimizer = nn.Adam(learning_rate=0.001)
optimizer.set_parameters(model.parameters())
loss_fn = nn.SoftmaxCrossEntropyLoss()

trainer = nn.JITCompiler(model, optimizer, loss_fn)
dataloader = nn.DataLoader(X_train, y_train, batch_size=32, shuffle=True, drop_last=True)
trainer.fit(dataloader, epochs=40, verbose=False)
trainer.save_checkpoint("faces_model")

Latest Benchmark Results

Benchmark TaskScikit-LearnPyTorch (ATen)AffineFlow-NN (Eager)AffineFlow-NN (C++ JIT)Max Speedup (vs PyTorch)
Deep Regression (Housing)MSE: 0.2811
Time: 4.94s
MSE: 0.2720
Time: 13.32s
MSE: 0.2662
Time: 2.47s
MSE: 0.2669
Time: 4.02s
5.39x
Deep CNN (Faces)N/AAcc: 98.75%
Time: 15.19s
Acc: 98.75%
Time: 12.17s
Acc: 98.75%
Time: 11.22s
1.35x

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.15 Aug 20261

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
affineflow/affineflow-nn

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:04 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:1f9de270f9f4a047e2c9694ef9dd4a8838e77aa241d152a51de8e56e747498b7