Types Module

Memory type definitions for arraybridge.

This module defines the MemoryType enum and related constants for managing different array/tensor frameworks.

class MemoryType(value)[source]

Bases: Enum

Enum representing different array/tensor framework types.

NUMPY = 'numpy'
CUPY = 'cupy'
TORCH = 'torch'
TENSORFLOW = 'tensorflow'
JAX = 'jax'
PYCLESPERANTO = 'pyclesperanto'

Memory Types

MemoryType Enum

class MemoryType(value)[source]

Enum representing different array/tensor framework types.

NUMPY = 'numpy'
CUPY = 'cupy'
TORCH = 'torch'
TENSORFLOW = 'tensorflow'
JAX = 'jax'
PYCLESPERANTO = 'pyclesperanto'

Memory Type Sets

CPU_MEMORY_TYPES: set[MemoryType] = {MemoryType.NUMPY}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

GPU_MEMORY_TYPES: set[MemoryType] = {MemoryType.CUPY, MemoryType.JAX, MemoryType.PYCLESPERANTO, MemoryType.TENSORFLOW, MemoryType.TORCH}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

SUPPORTED_MEMORY_TYPES: set[MemoryType] = {MemoryType.CUPY, MemoryType.JAX, MemoryType.NUMPY, MemoryType.PYCLESPERANTO, MemoryType.TENSORFLOW, MemoryType.TORCH}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

VALID_MEMORY_TYPES = {'cupy', 'jax', 'numpy', 'pyclesperanto', 'tensorflow', 'torch'}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

Examples

Using Memory Types

from arraybridge.types import MemoryType, GPU_MEMORY_TYPES

# Access enum values
print(MemoryType.NUMPY.value)  # 'numpy'
print(MemoryType.TORCH.value)  # 'torch'

# Check if a type is GPU-based
is_gpu = MemoryType.CUPY in GPU_MEMORY_TYPES  # True

String Values

from arraybridge.types import VALID_MEMORY_TYPES

# Validate memory type strings
user_input = "torch"
if user_input in VALID_MEMORY_TYPES:
    print("Valid memory type")