MCPcopy
hub / github.com/tinygrad/tinygrad / load

Function load

examples/llama3.py:57–68  ·  view source on GitHub ↗
(fn:str)

Source from the content-addressed store, hash-verified

55 return {name: convert(name) for name in {name: None for model in models for name in model}}
56
57def load(fn:str):
58 if fn.endswith('.index.json'):
59 with open(fn) as fp: weight_map = json.load(fp)['weight_map']
60 parts = {n: load(str(Path(fn).parent / Path(n).name)) for n in set(weight_map.values())}
61 return {k: parts[n][k] for k, n in weight_map.items()}
62 elif fn.endswith(".gguf"):
63 gguf_tensor = Tensor.empty(os.stat(fn).st_size, dtype=dtypes.uint8, device=f"disk:{fn}").to(Device.DEFAULT)
64 return gguf_load(gguf_tensor)[1]
65 elif fn.endswith(".safetensors"):
66 return safe_load(fn)
67 else:
68 return torch_load(fn)
69
70# **** quantized linears ****
71class Int8Linear:

Callers 3

load_modelFunction · 0.90
eval_llama3Function · 0.90
build_transformerFunction · 0.70

Calls 6

gguf_loadFunction · 0.90
safe_loadFunction · 0.90
torch_loadFunction · 0.90
loadMethod · 0.45
toMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…