Decorators — Mapanare

Annotations for GPU dispatch, restart policies, and metadata.

Overview

Decorators attach metadata and behavior to functions, agents, structs, and enums using @name syntax.

GPU / CPU Dispatch

@gpu
fn matrix_multiply(a: Tensor<Float>[M, K], b: Tensor<Float>[K, N]) -> Tensor<Float>[M, N] {
    return a @ b
}

Agent Restart Policies

let worker = spawn DataProcessor() @restart(policy: "always", max: 3, window: 60)

Parameters: policy ("always", "never", "transient"), max (maximum restart attempts), window (time window in seconds).

Decorated Definitions

@serializable
struct Config { host: String, port: Int }

@deprecated("use ProcessorV2 instead")
agent OldProcessor { ... }