helion.language.atomic_cas#
- helion.language.atomic_cas(target, index, expected, value, sem='relaxed')[source]#
Atomically compare-and-swap a value at
target[index].If the current value equals
expected, writesvalue. Otherwise leaves memory unchanged.- Parameters:
target (
Tensor) – Tensor to update.index (
list[object]) – Indices selecting elements to update. Can include tiles.expected (
Tensor|float|bool) – Expected current value(s) used for comparison.value (
Tensor|float|bool) – New value(s) to write if comparison succeeds.sem (
str) – Memory ordering semantics. One of"relaxed","acquire","release","acq_rel". Defaults to"relaxed".
- Returns:
The previous value(s) stored at
target[index]before the compare-and-swap.- Return type:
Note
Triton CAS doesn’t support a masked form; our generated code uses an unmasked CAS and relies on index masking to avoid OOB.