Hardware Abstraction Layer for edge AI with zero-copy tensors, image processing, and YOLO decoding
Project description
edgefirst-hal
Hardware-accelerated image processing, zero-copy tensors, and YOLO decoding for edge AI inference pipelines. Built in Rust with Python bindings via PyO3.
Installation
pip install edgefirst-hal
Pre-built wheels are available for Linux (x86_64, aarch64), macOS, and Windows. No Rust toolchain required.
Python 3.11+ wheels use the improved stable ABI for zero-copy buffer protocol support. Python 3.8–3.10 wheels use a compatible fallback. Pip selects the best wheel automatically.
Quick Start
import edgefirst_hal as ef
# Load a source image
src = ef.Tensor.load("photo.jpg", ef.PixelFormat.Rgb)
# Create an image processor (auto-selects best backend: GPU > G2D > CPU)
processor = ef.ImageProcessor()
# Allocate a GPU-optimal output buffer — always use create_image() for
# destinations passed to convert(), so the processor can select the best
# memory type (DMA-buf, PBO, or system memory) for zero-copy GPU paths.
dst = processor.create_image(640, 640, ef.PixelFormat.Rgb)
# Convert with letterbox resize (preserves aspect ratio)
processor.convert(src, dst)
# Access pixel data as a numpy array
import numpy as np
pixels = np.frombuffer(dst.map(), dtype=np.uint8).reshape(dst.shape())
Key Features
- Zero-copy tensors — DMA-BUF, POSIX shared memory, and PBO-backed buffers with automatic fallback to system memory
- Hardware-accelerated image processing — OpenGL, NXP G2D, and optimized CPU backends with automatic selection
- Letterbox resize — aspect-ratio-preserving resize with configurable padding color, rotation, and flip
- Int8 output —
create_image(..., dtype="int8")for direct signed int8 tensor output with GPU-accelerated XOR bias - YOLO decoding — YOLOv5, YOLOv8, YOLO11, and YOLO26 detection and instance segmentation (including end-to-end models)
- Object tracking — ByteTrack multi-object tracker with Kalman filtering
- Fully typed — ships with
.pyistubs for IDE autocompletion and type checking with mypy / pyright
Image Processing
import edgefirst_hal as ef
processor = ef.ImageProcessor()
src = ef.Tensor.load("frame.jpg", ef.PixelFormat.Rgb)
# Letterbox resize to model input size
dst = processor.create_image(640, 640, ef.PixelFormat.Rgb)
processor.convert(src, dst)
# With rotation and horizontal flip
processor.convert(src, dst, rotation=ef.Rotation.Rotate90, flip=ef.Flip.Horizontal)
# Crop source region
processor.convert(src, dst, src_crop=ef.Rect(100, 100, 400, 400))
# Int8 output for quantized models
dst_i8 = processor.create_image(640, 640, ef.PixelFormat.Rgb, dtype="int8")
processor.convert(src, dst_i8)
Zero-Copy External Buffer (Linux)
When integrating with an NPU delegate that owns DMA-BUF buffers, render
directly into the delegate's buffer to eliminate a memcpy:
import edgefirst_hal as ef
processor = ef.ImageProcessor()
src = ef.Tensor.load("frame.jpg", ef.PixelFormat.Rgb)
# Render directly into the delegate's DMA-BUF — zero copies
dst = processor.import_image(fd=vx_fd, width=640, height=640, format=ef.PixelFormat.Rgb)
processor.convert(src, dst)
# Reverse: HAL allocates, consumer imports the fd
hal_dst = processor.create_image(640, 640, ef.PixelFormat.Rgb)
fd = hal_dst.dmabuf_clone() # Raises if not DMA-backed
delegate.register(fd)
You can also attach format metadata to any raw tensor created via from_fd():
t = ef.Tensor.from_fd(some_fd, [480, 640, 3])
t.set_format(ef.PixelFormat.Rgb)
processor.convert(src, t)
Performance tip: When rotating through a pool of DMA-BUFs (e.g. 2-3
from an NPU delegate), create the Tensor wrappers once at init and
reuse them across frames. This avoids EGL image cache misses (~100-300us
each on Vivante GPUs).
YOLO Decoding
import edgefirst_hal as ef
# Configure decoder from model metadata
decoder = ef.Decoder(
{"detection": {"shape": [1, 84, 8400], "dtype": "float32"}},
score_threshold=0.5,
iou_threshold=0.45,
)
# Decode model outputs → (boxes, scores, class_ids)
boxes, scores, classes = decoder.decode([output_tensor])
Platform Support
| Platform | GPU Acceleration | Memory Types |
|---|---|---|
| Linux (NXP i.MX8/i.MX95) | OpenGL + G2D | DMA-buf, SHM, PBO, Mem |
| Linux (x86_64, other ARM) | OpenGL | SHM, PBO, Mem |
| macOS / Windows | CPU only | Mem |
Hardware acceleration is used automatically when available. All platforms fall back to CPU.
Part of the EdgeFirst Ecosystem
edgefirst-hal is the runtime inference library in the
EdgeFirst platform for deploying AI at the edge.
- EdgeFirst Studio — label, train, and deploy models for edge devices
- Rust crates — use the same library directly from Rust or C
- GitHub — source code, architecture docs, benchmarks, and contribution guide
License
Apache-2.0 — see LICENSE.
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 Distributions
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 edgefirst_hal-0.13.2.tar.gz.
File metadata
- Download URL: edgefirst_hal-0.13.2.tar.gz
- Upload date:
- Size: 323.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef3f12958dd5c29ca21d6cc9157d86902e06ff060a52b267b2ce44a3e597e71e
|
|
| MD5 |
fef4323355f76b29c4e696dce5748193
|
|
| BLAKE2b-256 |
7573baf0fc4bd5046cc9f46ba0167f748946481e4a6a8cc623fa82eb3a3de6e9
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2.tar.gz:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2.tar.gz -
Subject digest:
ef3f12958dd5c29ca21d6cc9157d86902e06ff060a52b267b2ce44a3e597e71e - Sigstore transparency entry: 1189503653
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e76f7cb3ba867aad2f136a42503a88def08353059477b85a8cc0b4feba70560
|
|
| MD5 |
4a2291f9ad036267d4bd9917ceb891b5
|
|
| BLAKE2b-256 |
c8fd43e97a353d9791a00fbc5ac9c82217ecd4bd749551b1e72fe911db32512d
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp311-abi3-win_amd64.whl -
Subject digest:
7e76f7cb3ba867aad2f136a42503a88def08353059477b85a8cc0b4feba70560 - Sigstore transparency entry: 1189503703
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.4 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e169a932c0b6fc2466dba9acd0ebc1302ed597ea22061b72837e1d3431fa371
|
|
| MD5 |
5d29240e89d68aed8a4c63072e38e947
|
|
| BLAKE2b-256 |
9c90a1bd19757d9f6374ca84068fea1a696dd51864ad551c3f8b7a0af11dc074
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
2e169a932c0b6fc2466dba9acd0ebc1302ed597ea22061b72837e1d3431fa371 - Sigstore transparency entry: 1189503668
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e914160f4279a059ab5d454b76d82c09050ef7c9040c2b64efcfe40fdde1580a
|
|
| MD5 |
0bb5d4a1c8e051d22f084f6ba2c91daf
|
|
| BLAKE2b-256 |
818541e95f34bb637a744187ecccf30ee81391790030784ca11aa1e6be41823d
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
e914160f4279a059ab5d454b76d82c09050ef7c9040c2b64efcfe40fdde1580a - Sigstore transparency entry: 1189503688
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf150f33894907f4a2e2bb1baaef2f404ad89e63ee23f28083b2574fae47215
|
|
| MD5 |
59a15925dbace4699d2499241a4f627e
|
|
| BLAKE2b-256 |
91bb71ee5982589fb508043a5181bcde0affa315c63e390445aff4553180f948
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
daf150f33894907f4a2e2bb1baaef2f404ad89e63ee23f28083b2574fae47215 - Sigstore transparency entry: 1189503675
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e6611fff8cc2d8eccf175c158467caf02405980dc8727f606f2de8f308b1bc8
|
|
| MD5 |
0131c1f442f8ffc6bf34897f565be671
|
|
| BLAKE2b-256 |
48387e132f3dbbb25c47dc405407254c205424f5f6101c3ca52daf21a6dd3a82
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp38-abi3-win_amd64.whl -
Subject digest:
8e6611fff8cc2d8eccf175c158467caf02405980dc8727f606f2de8f308b1bc8 - Sigstore transparency entry: 1189503669
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa508e2bff14c2a184d56e07d761c77f68f0aa18218047c416ef284f506fec07
|
|
| MD5 |
2ba319f0f8d7364169a80588c0a78062
|
|
| BLAKE2b-256 |
37b32356a067cb39586258ae55f91ed74e441be6779f930b2f6b500917473e03
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
aa508e2bff14c2a184d56e07d761c77f68f0aa18218047c416ef284f506fec07 - Sigstore transparency entry: 1189503664
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e77784949fb8f58ad6002b277cb726d877f698581c413db5036c48a668dfcb
|
|
| MD5 |
d345d5b96c95b695afb0c719ffab72c8
|
|
| BLAKE2b-256 |
78409fe5ee57e06f30e5dcc881cfc829caf8d3b4afad61368acabac3906a5d9c
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
92e77784949fb8f58ad6002b277cb726d877f698581c413db5036c48a668dfcb - Sigstore transparency entry: 1189503698
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type:
File details
Details for the file edgefirst_hal-0.13.2-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: edgefirst_hal-0.13.2-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df6fd5eb9a426a7a912808ddb7e218634dcb15428782f0727ac52d6070398ae8
|
|
| MD5 |
6429b4736c5d12b393a48cf0d9ef5102
|
|
| BLAKE2b-256 |
4c64bf58f581860338dbf459fc62d5a6e400b8496a7e71ffa294fb6a3b72c698
|
Provenance
The following attestation bundles were made for edgefirst_hal-0.13.2-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on EdgeFirstAI/hal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
edgefirst_hal-0.13.2-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
df6fd5eb9a426a7a912808ddb7e218634dcb15428782f0727ac52d6070398ae8 - Sigstore transparency entry: 1189503682
- Sigstore integration time:
-
Permalink:
EdgeFirstAI/hal@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Branch / Tag:
refs/tags/v0.13.2 - Owner: https://github.com/EdgeFirstAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bc76161cead93c0e74d1c49dc64c1f8502091d85 -
Trigger Event:
push
-
Statement type: