forked from pkraison/toonygrad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_from_tinygrad.py
executable file
·25 lines (23 loc) · 1.03 KB
/
import_from_tinygrad.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
import os, pathlib
FILES = ["tensor.py", "function.py", "helpers.py", "dtype.py", "device.py", "multi.py",
"nn/__init__.py", "nn/datasets.py", "nn/optim.py", "nn/state.py", "ops.py",
"shape/shapetracker.py", "shape/view.py",
"runtime/ops_clang.py", "runtime/ops_python.py", "runtime/ops_metal.py",
"renderer/__init__.py", "renderer/cstyle.py",
"codegen/lowerer.py", "codegen/linearize.py",
"codegen/uopgraph.py", "codegen/transcendental.py",
"viz/serve.py", "viz/index.html"]
src = pathlib.Path("../tinygrad/tinygrad")
dest = pathlib.Path("toonygrad")
for f in FILES:
rd = open(src/f).read()
rd = rd.replace("from tinygrad.", "from toonygrad.")
rd = rd.replace("import tinygrad.", "import toonygrad.")
(dest/f).parent.mkdir(parents=True, exist_ok=True)
if not (dest/f).exists() or int(os.getenv("FORCE", "0")):
print("importing", f)
with open(dest/f, "w") as f: f.write(rd)
else:
cmp = open(dest/f).read()
if rd != cmp: print("skipping", f)