torchoutil.nn.functional.checksum module¶
- checksum(
- x: int | bool | complex | float | None | str | bytes | bytearray | Pattern | Module | Tensor | ndarray | generic | NamedTupleInstance | DataclassInstance | Mapping | Iterable | method | function | partial | type | slice | Path,
- *,
- unk_mode: Literal['pickle', 'error'] = 'error',
- allow_protocol: bool = True,
- **kwargs,
Compute checksum of an arbitrary python object.
The property of a checksum is: for all any supported objects a and b, (a == b) => (checksum(a) == checksum(b)). This function is deterministic across executions by default.
- Args:
x: Object to checksum. unk_mode: Defines behaviour when x is not a supported type OR contains elements that are not supported.
“error”: raises a TypeError. “pickle”: convert object to bytes using pickle module. However, this conversion depends of the object implementation and might be not deterministic. defaults to “error”.
allow_protocol: Whether or not accept to use duck typing to detect NamedTuples, Dataclasses, Mappings or Iterables. defaults to True. **kwargs: Optional arguments to customize object checksum.
- checksum_any(
- x: int | bool | complex | float | None | str | bytes | bytearray | Pattern | Module | Tensor | ndarray | generic | NamedTupleInstance | DataclassInstance | Mapping | Iterable | method | function | partial | type | slice | Path,
- *,
- unk_mode: Literal['pickle', 'error'] = 'error',
- allow_protocol: bool = True,
- **kwargs,
Compute checksum of an arbitrary python object.
The property of a checksum is: for all any supported objects a and b, (a == b) => (checksum(a) == checksum(b)). This function is deterministic across executions by default.
- Args:
x: Object to checksum. unk_mode: Defines behaviour when x is not a supported type OR contains elements that are not supported.
“error”: raises a TypeError. “pickle”: convert object to bytes using pickle module. However, this conversion depends of the object implementation and might be not deterministic. defaults to “error”.
allow_protocol: Whether or not accept to use duck typing to detect NamedTuples, Dataclasses, Mappings or Iterables. defaults to True. **kwargs: Optional arguments to customize object checksum.
- checksum_dataclass(
- x: DataclassInstance,
- **kwargs,
- checksum_module(
- x: Module,
- *,
- only_trainable: bool = False,
- with_names: bool = False,
- buffers: bool = False,
- training: bool = False,
- **kwargs,
Compute a simple checksum over module parameters.
- checksum_namedtuple(
- x: NamedTupleInstance,
- **kwargs,