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 has no masked form. A lane of a tile past the target’s extent instead swaps an in-bounds element (its indices clamped to each dim’s last element) for that lane’s expected value, which leaves memory unchanged; its returned value is meaningless.