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,
*,
unk_mode: Literal['pickle', 'error'] = 'error',
allow_protocol: bool = True,
**kwargs,
) int[source]

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,
*,
unk_mode: Literal['pickle', 'error'] = 'error',
allow_protocol: bool = True,
**kwargs,
) int[source]

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_bool(
x: bool,
**kwargs,
) int[source]
checksum_builtin_number(
x: bool | int | float | complex,
**kwargs,
) int[source]

Compute a simple checksum of a builtin scalar number.

checksum_builtin_scalar(
x: bool | int | float | complex | None | str | bytes,
**kwargs,
) int[source]
checksum_bytearray(
x: bytearray,
**kwargs,
) int[source]
checksum_bytes(
x: bytes | bytearray,
**kwargs,
) int[source]
checksum_complex(
x: complex,
**kwargs,
) int[source]
checksum_dataclass(
x: DataclassInstance,
**kwargs,
) int[source]
checksum_dataframe(
x: DataFrame,
**kwargs,
) int[source]
checksum_dtype(
x: dtype | dtype,
**kwargs,
) int[source]
checksum_float(
x: float,
**kwargs,
) int[source]
checksum_function(
x: function,
**kwargs,
) int[source]
checksum_int(
x: int,
**kwargs,
) int[source]
checksum_iterable(
x: Iterable,
**kwargs,
) int[source]
checksum_mapping(
x: Mapping,
**kwargs,
) int[source]
checksum_method(
x: method,
**kwargs,
) int[source]
checksum_module(
x: Module,
*,
only_trainable: bool = False,
with_names: bool = False,
buffers: bool = False,
training: bool = False,
**kwargs,
) int[source]

Compute a simple checksum over module parameters.

checksum_namedtuple(
x: NamedTupleInstance,
**kwargs,
) int[source]
checksum_ndarray(
x: ndarray | generic,
**kwargs,
) int[source]
checksum_none(
x: None,
**kwargs,
) int[source]
checksum_partial(
x: partial,
**kwargs,
) int[source]
checksum_pattern(
x: Pattern,
**kwargs,
) int[source]
checksum_slice(
x: slice,
**kwargs,
) int[source]
checksum_str(
x: str,
**kwargs,
) int[source]
checksum_tensor(
x: Tensor,
**kwargs,
) int[source]

Compute a simple checksum of a tensor. Order of values matter for the checksum.

checksum_type(
x: type,
**kwargs,
) int[source]