sequince.utils.copying#
Functions#
|
Recursively copy a value while preserving array backends. |
Module Contents#
- sequince.utils.copying.array_safe_copy(value)[source]#
Recursively copy a value while preserving array backends.
Array leaves are copied using
sequince.array_api.copy(). This avoids callingcopy.deepcopy()on backend arrays, which is unsupported for some arrays such as non-leaf PyTorch tensors. Mappings, lists, and tuples are copied recursively; other values usecopy.deepcopy().- Parameters:
value (Any) – The value to copy.
- Returns:
An independent copy of
valuewhere supported by its array backend.- Return type:
Any