MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / _python_hash_1mb

Function _python_hash_1mb

extra/tinyfs/fetch_file.py:4–7  ·  view source on GitHub ↗
(data:bytes|bytearray)

Source from the content-addressed store, hash-verified

2import argparse, math, hashlib
3
4def _python_hash_1mb(data:bytes|bytearray):
5 chunks = [data[i:i+4096] for i in range(0, len(data), 4096)]
6 chunk_hashes = [hashlib.shake_128(chunk).digest(16) for chunk in chunks]
7 return hashlib.shake_128(b''.join(chunk_hashes)).digest(16)
8
9def hash_file(data: bytes|bytearray):
10 if len(data) % Tensor.CHUNK_SIZE != 0: data += bytes(Tensor.CHUNK_SIZE - len(data) % Tensor.CHUNK_SIZE)

Callers 2

handleMethod · 0.90
hash_fileFunction · 0.85

Calls

no outgoing calls

Tested by 1

handleMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…