gpulinalg
cheatah-gpu-linalg v0.4.4-alpha — Biome Standard 0.6.3-alpha
Functions
A 1-element device array — the resident slot a loss accumulator lives in (purr cannot spell device_array<double>::uninitialized({1}), so the module provides it).
A fresh uninitialized 1-element device array.
O(1).
metadata only.
one pooled device data buffer (one 256 B size class).
example:purrWhether the device context can come up on this machine — a cached one-shot probe that NEVER throws.
This is the runtime "is there a GPU?" question (the nullopt-probe pattern at the linalg layer): gate work on it instead of hand-rolling a try/catch around a first dispatch. detail::ctx() itself still throws on first touch when the device is genuinely required.
true when the backend context is (or can be) live; false when bring-up failed.
O(1) after the first call (the probe result is cached).
none after the first call.
none.
gpu:guardsWhy available() is false — the probe's exception text, "" while available.
The consumer's skip note ("gpu lane skipped: …") should carry this instead of inventing its own reason.
The bring-up failure message, or the empty string while the device is available.
O(1) after the first call (the reason is cached).
one cached string on the first call.
none.
gpu:guardsUpload a host array into a fresh device array (same shape + element type; the operand must be contiguous — pack first via ndarray's reshape/copy if it is a strided view, else this throws).
a | The contiguous host array. |
A device array holding a copy of a's elements.
O(n) transfer.
metadata only — the Vulkan upload stages through a pooled host-visible buffer.
one pooled device data buffer of size()·sizeof(T).
example:vector_pipelineDownload a device array into a fresh host array (same shape + element type).
A SYNC POINT.
a | The device array. |
A host ndarray holding a copy of a's elements.
O(n) transfer.
the O(n) host result; the Vulkan readback stages through a pooled host-cached buffer.
none.
example:mlp_forwardRead ONE element by signed multi-index (ndarray's get) — a single-element SYNC POINT (exactly sizeof(T) crosses the bus; throws on a rank mismatch or an out-of-range index).
a | The device array. |
index | One signed index per dimension. |
The element's value.
O(ndim) index math + an O(1) offset download.
none fresh — the Vulkan readback stages through a pooled host-cached buffer.
none.
example:linear_regression_gdRender like ndarray renders (downloads, then reuses ndarray's own to_string — identical output by construction).
A SYNC POINT.
a | The device array. |
The rendered text.
O(n) download + O(n) formatting.
a full host copy of a plus the string.
none.
Element count as cheatah's signed integer (ndarray's size_of).
a | The device array. |
The element count.
O(1).
none.
none.
A double device array of zeros (ndarray's zeros) — the device-side fill kernel, no upload.
shape | The dimensions (negatives throw). |
A fresh zeroed device array.
O(n) device work.
none — pooled scalar/dims scratch only.
one pooled device data buffer for the result.
gpu:elementwiseA double device array of ones (ndarray's ones) — the device-side fill kernel, no upload.
shape | The dimensions (negatives throw). |
A fresh device array of ones.
O(n) device work.
none — pooled scalar/dims scratch only.
one pooled device data buffer for the result.
example:batched_inferenceA device array of the given shape, every element value (ndarray's full).
Real elements fill ON DEVICE (no host staging vector, no PCIe upload); complex elements take the staged-upload fallback.
shape | The dimensions (cheatah's signed integers; negatives throw). |
value | The fill value. |
A fresh device array of value s.
O(n) device work (real) or O(n) host fill + upload (complex).
none for real elements (pooled scalar/dims scratch); one O(n) host vector for complex.
one pooled device data buffer for the result.
gpu:elementwiseEvenly spaced values in [start, stop) with the given step (ndarray's arange; a zero step throws).
start | The first value. |
stop | The exclusive bound. |
step | The (non-zero) increment. |
A fresh 1-D device array of the sequence.
O(n) host generation + O(n) transfer.
one O(n) host vector (the sequence is generated host-side, then uploaded).
one pooled device data buffer for the result.
Reshape — ZERO-COPY: device arrays are always contiguous, so the new view shares the buffer (throws on a negative dimension, an element-count overflow, or a count mismatch).
a | The device array to re-view. |
shape | The new dimensions (same element count). |
A sibling array sharing a's device buffer under the new shape.
O(ndim).
the new shape/strides vectors.
none — zero-copy by design.
example:mlp_forwardvoid axpy(device_array< T > &out, T alpha, const device_array< T > &x, const device_array< T > &y)
#
out = α·x + y in ONE dispatch — the fused training-loop primitive (same shapes; operator chaining costs two dispatches and a temporary).
out | The destination (may alias |
alpha | The scalar coefficient. |
x | The scaled device operand. |
y | The added device operand (throws on a shape mismatch). |
O(n) device work in one blocking vec4 dispatch.
none — the 1-element α buffer and dims scratch recycle through the pool.
none.
gpu:elementwiseΣ aᵢ over the whole array — the DETERMINISTIC partial-sum contract (a size-picked one- or two-stage partial kernel + an on-device finalize, fused into one submission; fixed association order, so the same bits come back every run).
a | The device operand (any rank; 0 elements yield T{}). |
The scalar sum, downloaded as ONE element.
O(n) device work; one fused submission (partial + finalize).
none — pooled partial/result scratch; sizeof(T) readback.
none — pooled scratch only.
gpu:elementwiseThe arithmetic mean Σ aᵢ / n (n = 0 yields 0, matching an empty sum).
a | The device operand. |
The scalar mean.
O(n) device work (one fused sum) + one host division.
none — pooled partial/result scratch; sizeof(T) readback.
none — pooled scratch only.
gpu:elementwiseThe transfer/dispatch ledger of the process-wide context (uploads, downloads, dispatches).
The live counters (a reference into the context — reads reflect later ops).
O(1).
none.
none.
example:vector_pipelineZero the ledger (examples call this right before a hot loop, then assert on stats).
O(1).
none.
none.
example:vector_pipeline