(self, obj: Any)
| 159 | |
| 160 | class _ContentHashPickler(pickle.Pickler): |
| 161 | def reducer_override(self, obj: Any) -> Any: |
| 162 | if stub := maybe_get_custom_stub(obj): |
| 163 | return (bytes, (stub.to_bytes(),)) |
| 164 | try: |
| 165 | if not is_primitive(obj) and is_data_primitive(obj): |
| 166 | h = hashlib.new(hash_type, usedforsecurity=False) |
| 167 | h.update(_contiguous_tensor_bytes(obj)) |
| 168 | return (bytes, (h.digest(),)) |
| 169 | except Exception: |
| 170 | pass |
| 171 | # Falls back to parent pickle |
| 172 | return NotImplemented |
| 173 | |
| 174 | buf = io.BytesIO() |
| 175 | _ContentHashPickler(buf).dump(obj) |
nothing calls this directly
no test coverage detected