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 examplespython/— Python bindings (pybind11)CMakeLists.txt— Build configurationbenchmark_numpy.py— Performance comparison with NumPyPERFORMANCE_ANALYSIS.md— Detailed performance analysis
License
See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e93e9df6b84b6bf42786ff2559206145db118b3d6d683702d1e71433d6631f73
|
|
| MD5 |
9ef7d9ca8803332b1eab98eb6576f31f
|
|
| BLAKE2b-256 |
84e7cf3a3e1df55e6c7b05f275e73dc47f265ef58500a720e93241cb41279074
|
File details
Details for the file labneura2-0.1.1-cp39-cp39-macosx_10_9_universal2.whl.
File metadata
- Download URL: labneura2-0.1.1-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 803.8 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34605dd82f73710f31e1831a4b45873fb048923237b9c8eceafd16c33f12a7c5
|
|
| MD5 |
d9a3a892fd2cf72d7235027d866ad23f
|
|
| BLAKE2b-256 |
e57f1f89146b138b7de7058f0b9191e7d7e55adeac91a8446c000655dedebc7d
|