Skip to main content

Fast SIMD-optimized dot products (f32·f32, f16·f32)

Project description

fast_dot

Fast SIMD-optimized dot products exposed to Python via PyO3 + maturin.

Features

  • dot_f32(a: np.ndarray[float32], b: np.ndarray[float32]) -> float
  • dot_f16_f32(a: np.ndarray[float16], b: np.ndarray[float32]) -> float (uses F16C when available)

Both functions accept any Python object that implements the buffer protocol (NumPy arrays, PyTorch tensors via .numpy() if on CPU and contiguous) through the NumPy bridge. For non-NumPy objects, convert to NumPy first.

Build and install

  • Build wheel: maturin build --release
  • Develop install: maturin develop --release

Usage

import numpy as np import fast_dot as fd

x = np.random.rand(1024).astype(np.float32) y = np.random.rand(1024).astype(np.float32) print(fd.dot_f32(x, y))

x16 = x.astype(np.float16) print(fd.dot_f16_f32(x16, y))

Notes

  • Requires x86_64. F16C and AVX2 paths are used when available; otherwise falls back to scalar.
  • Arrays must be 1-D and contiguous with matching shapes.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

fastdotrs-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl (219.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

File details

Details for the file fastdotrs-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for fastdotrs-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a8821e235679f8115c4879eea8bf8412af6556c53fd66b4f2d6d9d676e069abe
MD5 5848d03e8d7e16785d5ffa953bc1f674
BLAKE2b-256 cadcd9e18ce7ebbc5abacc3940c5f876280f20d9beb84b6852cdb0aa4a9bf339

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