Ops#
API#
- warp_nn.utils.ops.copy( ) array[source]#
Copy an array into another array with the same shape (any of them can be non-contiguous).
Unlike
wp.copy(), the copy is always recorded on the active tape (if any) as a kernel launch, so that the gradients of the output array are accumulated (rather than assigned) into the input array.- Parameters:
input – The source array.
output – The destination array.
- Returns:
The destination array.
- Raises:
ValueError – If the arrays have different shapes.
- warp_nn.utils.ops.contiguous(array: array) array[source]#
Get a contiguous version of an array (e.g. to reshape it).
Unlike
wp.array.contiguous(), the copy of a non-contiguous array is recorded on the active tape (if any), so that gradients are propagated to the original array.- Parameters:
array – The array.
- Returns:
The array itself if it is contiguous, otherwise a contiguous copy of it.
- warp_nn.utils.ops.overlap(a: array, b: array) bool[source]#
Whether the memory spans of two arrays overlap.
The check is conservative: interleaved strided views that share no element are also reported as overlapping. Empty arrays, and arrays on different devices, never overlap.
- Parameters:
a – The first array.
b – The second array.
- Returns:
Whether the arrays may share memory.