Built-In Kernels

CPU Kernels

CPU kernel implementations.

class shmpipeline.kernels.cpu.AddConstantCpuKernel(context)[source]

Bases: CpuKernel

Add a scalar constant to the input payload.

Store the additive constant after validation.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Require a numeric constant and matching stream metadata.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Add the configured constant into the reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.AffineTransformCpuKernel(context)[source]

Bases: CpuKernel

Apply an affine transform y = A x + b to a vector input.

Cache auxiliary aliases used on every compute call.

classmethod validate_config(config, shared_memory)[source]

Validate vector, matrix, offset, and output compatibility.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute the affine transform into the reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.FlattenCpuKernel(context)[source]

Bases: CpuKernel

Flatten any CPU array into a contiguous 1D vector.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Require the output vector to match the flattened input size.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Flatten the input array into the reusable output vector.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.CopyCpuKernel(context)[source]

Bases: CpuKernel

Copy one CPU shared-memory payload into another.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Require matching input and output stream metadata.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Copy the input payload into the reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.CpuKernel(context)[source]

Bases: Kernel

Base class for CPU shared-memory kernels.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

class shmpipeline.kernels.cpu.CustomOperationCpuKernel(context)[source]

Bases: CpuKernel

Fuse a restricted arithmetic expression into one CPU kernel.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

auxiliary_arity: int | None = None
classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ElementwiseAddCpuKernel(context)[source]

Bases: CpuKernel

Compute output = input + auxiliary elementwise.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ElementwiseDivideCpuKernel(context)[source]

Bases: CpuKernel

Compute output = input / auxiliary elementwise.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ElementwiseMultiplyCpuKernel(context)[source]

Bases: CpuKernel

Compute output = input * auxiliary elementwise.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ElementwiseSubtractCpuKernel(context)[source]

Bases: CpuKernel

Compute output = input - auxiliary elementwise.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.LeakyIntegratorCpuKernel(context)[source]

Bases: CpuKernel

Apply the control law u_k = leak * u_{k-1} + gain * e_k.

Store the leak, gain, and persistent controller state.

classmethod validate_config(config, shared_memory)[source]

Require vector-compatible streams and numeric leak/gain.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Advance the controller one step into the reusable output vector.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.RaiseErrorCpuKernel(context)[source]

Bases: CpuKernel

Raise a configured error to exercise worker supervision paths.

Store validated kernel context and normalized parameters.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Require a non-empty error message.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Always raise the configured failure.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ScaleCpuKernel(context)[source]

Bases: CpuKernel

Multiply the input payload by a constant factor.

Store the scale factor after validation.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Require a numeric factor and matching stream metadata.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Scale the incoming array into the reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ScaleOffsetCpuKernel(context)[source]

Bases: CpuKernel

Apply output = gain * input - offset elementwise.

Store the configured scalar gain.

classmethod validate_config(config, shared_memory)[source]

Require matching input, offset, and output shapes/dtypes.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute the scale-and-offset result into the reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.cpu.ShackHartmannCentroidCpuKernel(context)[source]

Bases: CpuKernel

Compute local centroids for a tiled Shack-Hartmann sensor image.

The output shape is (rows, cols, 2) where the last axis stores [delta_row, delta_col] relative to each tile center.

Store the subaperture tile size.

classmethod validate_config(config, shared_memory)[source]

Require compatible image and centroid-output geometry.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute centroids tile-by-tile into the reusable output array.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

GPU Kernels

GPU kernel implementations.

class shmpipeline.kernels.gpu.AddConstantGpuKernel(context)[source]

Bases: GpuKernel

Add a scalar constant to the input payload.

Allocate the reusable output buffer directly on the target GPU.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.AffineTransformGpuKernel(context)[source]

Bases: GpuKernel

Apply an affine transform y = A x + b to a vector input.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.CopyGpuKernel(context)[source]

Bases: GpuKernel

Copy one GPU shared-memory payload into another.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.CustomOperationGpuKernel(context)[source]

Bases: GpuKernel

Fuse a restricted arithmetic expression into one GPU kernel.

Allocate the reusable output buffer directly on the target GPU.

Parameters:

context (KernelContext)

auxiliary_arity: int | None = None
classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ElementwiseAddGpuKernel(context)[source]

Bases: GpuKernel

Compute output = input + auxiliary elementwise.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ElementwiseDivideGpuKernel(context)[source]

Bases: GpuKernel

Compute output = input / auxiliary elementwise.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ElementwiseMultiplyGpuKernel(context)[source]

Bases: GpuKernel

Compute output = input * auxiliary elementwise.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ElementwiseSubtractGpuKernel(context)[source]

Bases: GpuKernel

Compute output = input - auxiliary elementwise.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.FlattenGpuKernel(context)[source]

Bases: GpuKernel

Flatten any GPU array into a contiguous 1D vector.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.GpuKernel(context)[source]

Bases: Kernel

Base class for GPU shared-memory kernels.

Allocate the reusable output buffer directly on the target GPU.

class shmpipeline.kernels.gpu.LeakyIntegratorGpuKernel(context)[source]

Bases: GpuKernel

Apply the control law u_k = leak * u_{k-1} + gain * e_k.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.RaiseErrorGpuKernel(context)[source]

Bases: GpuKernel

Raise a configured error to exercise worker supervision paths.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ScaleGpuKernel(context)[source]

Bases: GpuKernel

Multiply the input payload by a constant factor.

Allocate the reusable output buffer directly on the target GPU.

Parameters:

context (KernelContext)

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ScaleOffsetGpuKernel(context)[source]

Bases: GpuKernel

Apply output = gain * input - offset elementwise.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None

class shmpipeline.kernels.gpu.ShackHartmannCentroidGpuKernel(context)[source]

Bases: GpuKernel

Compute local centroids for a tiled Shack-Hartmann sensor image.

Allocate the reusable output buffer directly on the target GPU.

classmethod validate_config(config, shared_memory)[source]

Validate arity and storage constraints before build.

Parameters:
Return type:

None

compute_into(trigger_input, output, auxiliary_inputs)[source]

Compute into the provided reusable output buffer.

Parameters:
  • trigger_input (Any)

  • output (Any)

  • auxiliary_inputs (Mapping[str, Any])

Return type:

None