Skip to main content

SIMD-accelerated tensor operations for neural networks

Project description

LabNeura

High-performance C++ tensor library with Python bindings, optimized for Apple Silicon (M1/M2/M3) and modern CPUs. Provides SIMD-accelerated operations with optional INT8 quantization support.

Features

  • Architecture-aware optimization: Automatic NEON vectorization on Apple Silicon, generic fallback for other platforms
  • Pure SIMD acceleration: High-performance vector operations without multi-threading overhead
  • Mixed-precision support: FP32 (32-bit float) and INT8 (8-bit quantized) modes
  • Python integration: Easy-to-use Python bindings via pybind11
  • Header-only C++ library: Simple integration into C++ projects

Quick Start

As a C++ Header-Only Library

Include headers from include/ in your project:

#include "labneura/tensor.h"

labneura::Tensor t1(std::vector<float>{1.0, 2.0, 3.0});
labneura::Tensor t2(std::vector<float>{1.0, 1.0, 1.0});
t1.add_inplace(t2);

Build & Install

mkdir build && cd build
cmake ..
cmake --build . --config Release
cmake --install .

Python Extension

cd python
pip install .
import labneura

# FP32 operations
t1 = labneura.Tensor([1.0, 2.0, 3.0], labneura.QuantizationMode.FP32)
t2 = labneura.Tensor([1.0, 1.0, 1.0], labneura.QuantizationMode.FP32)
t1.add_inplace(t2)
data = t1.data_fp32()

# INT8 quantization
t3 = labneura.Tensor([10, 20, 30], labneura.QuantizationMode.INT8)

Performance

LabNeura delivers SIMD-accelerated performance exceeding NumPy on M1 Macs through pure vectorization:

  • NEON vectorization: 8x float (2 instructions) or 16x int8 operations per iteration
  • Memory efficiency: INT8 mode uses 4x less memory, improving cache utilization
  • No threading overhead: Single-threaded SIMD approach maximizes per-core performance

Run benchmarks:

python benchmark_numpy.py

Expected results on M1/M2:

  • FP32 addition: 2000-3000 M ops/sec
  • INT8 addition: 4000-6000 M ops/sec (4x throughput due to wider vectors)
  • Competitive or faster than NumPy across array sizes

Implementation Details

NEON Optimization (Apple Silicon)

  • Detects M1/M2/M3 at compile-time via __aarch64__ and __APPLE__
  • Uses ARM NEON intrinsics for 128-bit vector operations
  • Processes 8 floats (2 instructions) or 16 int8 values per iteration
  • Single-threaded design maximizes instruction-level parallelism

Quantization Support

  • FP32 mode: Full precision for scientific computing
  • INT8 mode: 4x memory reduction, suitable for inference workloads

Repository Layout

  • include/labneura/ — C++ headers (tensor.h, types.hpp)
  • src/labneura/ — Implementation (tensor.cpp)
  • examples/ — C++ usage examples
  • python/ — Python bindings (pybind11)
  • CMakeLists.txt — Build configuration
  • benchmark_numpy.py — Performance comparison with NumPy
  • PERFORMANCE_ANALYSIS.md — Detailed performance analysis

License

See LICENSE file for details.

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

labneura2-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

labneura2-0.1.1-cp39-cp39-macosx_10_9_universal2.whl (803.8 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file labneura2-0.1.1.tar.gz.

File metadata

  • Download URL: labneura2-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for labneura2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e93e9df6b84b6bf42786ff2559206145db118b3d6d683702d1e71433d6631f73
MD5 9ef7d9ca8803332b1eab98eb6576f31f
BLAKE2b-256 84e7cf3a3e1df55e6c7b05f275e73dc47f265ef58500a720e93241cb41279074

See more details on using hashes here.

File details

Details for the file labneura2-0.1.1-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for labneura2-0.1.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 34605dd82f73710f31e1831a4b45873fb048923237b9c8eceafd16c33f12a7c5
MD5 d9a3a892fd2cf72d7235027d866ad23f
BLAKE2b-256 e57f1f89146b138b7de7058f0b9191e7d7e55adeac91a8446c000655dedebc7d

See more details on using hashes here.

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