GPU Computation

Comprehensive guide to GPU Computation in Linea

GPU Computation

Use @gpu functions and compute helpers for accelerated numeric operations.

import compute
func multiply(a: any, b: any) -> any {
    return compute::matmul(a, b)
}

var a = [[1.0, 2.0], [3.0, 4.0]]
var b = [[2.0, 0.0], [1.0, 2.0]]
display multiply(a, b)

When to Use

Prefer GPU paths for repeated large matrix/tensor workloads; keep small scalar logic on regular code paths.