Module array_protocol

Source
Expand description

Implementation of Array Protocol (similar to NumPy’s __array_function__ protocol)

This module provides a mechanism for third-party array implementations to override SciRS2 functions. It is inspired by NumPy’s __array_function__ protocol defined in NEP-18.

The protocol enables third-party arrays to implement SciRS2 functions in a way that is recognized by the SciRS2 library. This allows for seamless integration with distributed arrays, GPU arrays, and other custom array implementations.

§Core Components

The Array Protocol system includes:

  • Specialized array implementations (GPU, distributed, JIT)
  • Automatic device placement with AutoDevice
  • Mixed-precision operations
  • Neural network layers and models
  • Gradient computation and training capabilities
  • Distributed training and model serialization

Re-exports§

pub use self::ml_ops::activation;
pub use self::ml_ops::batch_norm;
pub use self::ml_ops::conv2d;
pub use self::ml_ops::cross_entropy;
pub use self::ml_ops::dropout;
pub use self::ml_ops::max_pool2d;
pub use self::ml_ops::self_attention;
pub use self::ml_ops::ActivationFunc;

Modules§

auto_device
Automatic device placement for array operations.
distributed_training
Distributed training support for the array protocol.
gpu_kernels
A collection of GPU kernels for common operations
grad
Gradient computation support for the array protocol.
mixed_precision
Mixed-precision operations for the array protocol.
ml_ops
Machine learning operations using the array protocol.
neural
Neural network layers and models using the array protocol.
serialization
Serialization and deserialization of neural network models.
training
Training utilities for neural networks using the array protocol.
traits
Extra traits for third-party array implementations.

Macros§

array_function_dispatch

Structs§

ArrayChunk
A chunk of a distributed array
ArrayFunction
A wrapper for functions that can be overridden by the array protocol.
ArrayFunctionDecorator
Decorator for adding array function dispatch capabilities to a function.
ArrayFunctionRegistry
Registry of all array functions with dispatch caching.
ArrayProtocolFunction
A factory for creating and registering array protocol enabled functions.
CraneliftFunctionFactory
A factory for creating JIT functions using the Cranelift backend
DispatchCacheEntry
Cache entry for function dispatch optimization
DistributedConfig
A configuration for distributed array operations
DistributedNdarray
A distributed array implementation
GPUArrayBuilder
A builder for GPU arrays
GPUConfig
Configuration for GPU operations
GPUNdarray
A mock implementation of a GPU array
JITConfig
Configuration for JIT compilation
JITEnabledArray
An array that supports JIT compilation
JITFactoryRegistry
Registry of JIT function factories.
JITFunctionImpl
A compiled JIT function
JITManager
A JIT manager that selects the appropriate factory for a given array type
LLVMFunctionFactory
A factory for creating JIT functions using the LLVM backend
MockDistributedArray
A mock distributed array implementation.
MockGPUArray
A mock GPU array implementation.
NdarrayWrapper
A wrapper for ndarray to implement the ArrayProtocol trait.
NotImplemented
Marker for functions not implemented by a specific type.

Enums§

DistributedBackend
Communication backends for distributed arrays
DistributionStrategy
Strategies for distributing an array
GPUBackend
GPU backends that can be used
JITBackend
JIT compilation backends
OperationError
Error type for array operations.

Traits§

ArrayProtocol
Trait for objects that can handle the array protocol.
DistributedArray
Trait for distributed arrays that can span multiple machines.
GPUArray
Trait for arrays that can support GPU operations.
JITArray
JIT (Just-In-Time) compilation support for arrays.
JITFunction
A JIT-compiled function that can be evaluated on arrays.
JITFunctionFactory
A factory for creating JIT functions for specific array implementations.

Functions§

add
apply_elementwise
array_function_dispatch
Calls the array protocol with the given function and arguments.
concatenate
get_implementing_args
Helper function to extract all arguments implementing the ArrayProtocol trait.
init
Initializes the array protocol system.
inverse
matmul
multiply
reshape
subtract
sum
svd
transpose

Type Aliases§

ArrayFunctionImpl
Type alias for the complex function implementation type