warp.atomic_sub#
- warp.atomic_sub(arr: Array[Any], i: Int, value: Any) Any#
Atomically subtract a value from an array element in place.
For composite dtypes (vectors, matrices, quaternions, and transforms), the update is atomic only per component. Another thread can observe
arr[i]with only some of its components updated.On GPU, concurrent floating-point updates to the same element are applied in an unspecified order, so rounding can make the result differ between runs. Enable deterministic mode for reproducible results; see Deterministic Execution. In deterministic mode, compiling a kernel that uses the returned value raises
WarpDeterminismError.This function does not support
float16orbfloat16on GPUs with compute capability below 7.0, orfloat64below 6.0. Kernels compiled for those GPUs skip these updates without raising an error. Usefloat32on those GPUs instead.Currently, the backward pass does not recompute the returned value, so gradients that depend on it are incorrect. If the backward pass needs the returned value, for example as an index, save it to an array in the forward pass and return it from a custom replay function; see Example 2: Custom Replay Function. Even with a custom replay function, autodiff treats the returned value as a constant, so
arrreceives no gradient from expressions that use it.- Parameters:
arr – Array containing the element to update. Its scalar type must be
int32,uint32,int64,uint64,float16,bfloat16,float32, orfloat64.i – Index of the element to update.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i]before this update. For composite dtypes, the result may not equal any value thatarr[i]held at a single point in time.
- warp.atomic_sub(arr: Array[Any], i: Int, j: Int, value: Any) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j]before this update.
- warp.atomic_sub(arr: Array[Any], i: Int, j: Int, k: Int, value: Any) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k]before this update.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
l – Fourth index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k,l]before this update.
- warp.atomic_sub(arr: FabricArray[Any], i: Int, value: Any) Any
Atomically subtract a value from an array element in place.
For composite dtypes (vectors, matrices, quaternions, and transforms), the update is atomic only per component. Another thread can observe
arr[i]with only some of its components updated.On GPU, concurrent floating-point updates to the same element are applied in an unspecified order, so rounding can make the result differ between runs. Enable deterministic mode for reproducible results; see Deterministic Execution. In deterministic mode, compiling a kernel that uses the returned value raises
WarpDeterminismError.This function does not support
float16orbfloat16on GPUs with compute capability below 7.0, orfloat64below 6.0. Kernels compiled for those GPUs skip these updates without raising an error. Usefloat32on those GPUs instead.Currently, the backward pass does not recompute the returned value, so gradients that depend on it are incorrect. If the backward pass needs the returned value, for example as an index, save it to an array in the forward pass and return it from a custom replay function; see Example 2: Custom Replay Function. Even with a custom replay function, autodiff treats the returned value as a constant, so
arrreceives no gradient from expressions that use it.- Parameters:
arr – Array containing the element to update. Its scalar type must be
int32,uint32,int64,uint64,float16,bfloat16,float32, orfloat64.i – Index of the element to update.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i]before this update. For composite dtypes, the result may not equal any value thatarr[i]held at a single point in time.
- warp.atomic_sub(arr: FabricArray[Any], i: Int, j: Int, value: Any) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j]before this update.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k]before this update.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
l – Fourth index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k,l]before this update.
- warp.atomic_sub(arr: IndexedFabricArray[Any], i: Int, value: Any) Any
Atomically subtract a value from an array element in place.
For composite dtypes (vectors, matrices, quaternions, and transforms), the update is atomic only per component. Another thread can observe
arr[i]with only some of its components updated.On GPU, concurrent floating-point updates to the same element are applied in an unspecified order, so rounding can make the result differ between runs. Enable deterministic mode for reproducible results; see Deterministic Execution. In deterministic mode, compiling a kernel that uses the returned value raises
WarpDeterminismError.This function does not support
float16orbfloat16on GPUs with compute capability below 7.0, orfloat64below 6.0. Kernels compiled for those GPUs skip these updates without raising an error. Usefloat32on those GPUs instead.Currently, the backward pass does not recompute the returned value, so gradients that depend on it are incorrect. If the backward pass needs the returned value, for example as an index, save it to an array in the forward pass and return it from a custom replay function; see Example 2: Custom Replay Function. Even with a custom replay function, autodiff treats the returned value as a constant, so
arrreceives no gradient from expressions that use it.- Parameters:
arr – Array containing the element to update. Its scalar type must be
int32,uint32,int64,uint64,float16,bfloat16,float32, orfloat64.i – Index of the element to update.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i]before this update. For composite dtypes, the result may not equal any value thatarr[i]held at a single point in time.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j]before this update.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k]before this update.
- warp.atomic_sub( ) Any
Atomically subtract a value from an array element in place.
See the
wp.atomic_sub(arr, i, value)overload for dtype, atomicity, determinism, and autodiff details.- Parameters:
arr – Array containing the element to update.
i – First index of the element.
j – Second index of the element.
k – Third index of the element.
l – Fourth index of the element.
value – Amount to subtract.
valuemust have the same dtype asarr.
- Returns:
The value of
arr[i,j,k,l]before this update.