Skip to main content

arraybridge

ArrayBridge provides explicit conversion and shared lifecycle utilities for NumPy, CuPy, PyTorch, TensorFlow, JAX, and pyclesperanto arrays.

Core dependencies are NumPy and metaclass-registry. Other frameworks are optional.

Quick start

import numpy as np

from arraybridge import convert_memory, detect_memory_type

value = np.arange(6).reshape(2, 3)
assert detect_memory_type(value) == "numpy"

copy = convert_memory(
    value,
    source_type="numpy",
    target_type="numpy",
    gpu_id=0,
)

convert_memory requires the declared source type, target type, and device id. The source and target MemoryType declarations perform conversion directly. The device id is required even for CPU conversions so call sites have one stable signature. A GPU target must declare that identifier as available; ArrayBridge does not silently place the value on the CPU.

Declarative decorators

from arraybridge import numpy

@numpy
def normalize(image):
    return image / max(float(image.max()), 1.0)

The framework decorators attach input_memory_type, output_memory_type, and execution_memory_type metadata, provide dtype/slice runtime parameters, and add framework-specific stream/OOM handling where supported. They do not convert inputs or outputs between frameworks and do not accept a gpu_id argument. A host runtime must call convert_memory at the boundary it plans and scope execution using the execution declaration.

Stack utilities

import numpy as np

from arraybridge import stack_slices, unstack_slices

slices = [np.zeros((8, 8)), np.ones((8, 8))]
stack = stack_slices(slices, memory_type="numpy", gpu_id=0)
restored = unstack_slices(stack, memory_type="numpy", gpu_id=0)

stack_slices requires non-empty 2D inputs. unstack_slices requires a 3D array. Both validate shape and use explicit target memory/device declarations.

Installation

pip install arraybridge
pip install "arraybridge[torch]"
pip install "arraybridge[cupy]"

Documentation: https://arraybridge.readthedocs.io

Native array geometry

MemoryType.reshape(array, shape) and MemoryType.broadcast_to(array, shape) operate in the array's framework and device. MemoryType.ones_like(reference, shape=..., dtype=...) allocates on the reference's device; omitting shape retains its shape. Reshape and broadcast preserve views where the backend can represent them. Broadcasting is not a promise of a writable, independent buffer.

These operations never silently project pixels to NumPy. Pyclesperanto cannot provide native changed-shape reshape or broadcasting, so those requests raise NotImplementedError. Its native ones allocation supports one to three dimensions and its supported integer/float32 dtypes; boolean allocation is explicitly unsupported. Existing conversion and disk boundaries remain separate.

Metadata

Release files for arraybridge 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arraybridge 0.3.7
File Size Uploaded
arraybridge-0.3.7.tar.gz 102.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arraybridge 0.3.7
File Interpreter ABI Platform
arraybridge-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 138.7 kB

Release files / arraybridge-0.3.7.tar.gz

Download URL arraybridge-0.3.7.tar.gz
Size 102.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9475c3d5dc824517965c416e13fa8f084c91cb1b502560814adca1bd01ac03db
BLAKE2b-256 checksum
How to use checksums
b29b930ecdd269e7d23a23fd7a69ca875caac67f5255ec44da0c5f8f13fb7e77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / arraybridge-0.3.7-py3-none-any.whl

Download URL arraybridge-0.3.7-py3-none-any.whl
Size 35.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89a54683f3531060b5c7badd83dfcabc58f17ef7ffb3c899f4ca163bd42bd905
BLAKE2b-256 checksum
How to use checksums
33da1d39284e16971671eeef24aa2d05db7aaae9dd46f432fd5af6fcd8acdc8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.3.8

2 release files

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page