Add dictionary keys to reduce db size (#2131)

* work

* ignore beam cache

* dictionary keys are generic

* minor db cleanups

* fix baseline and extract dataset

* fix training

* log likelihood
This commit is contained in:
George Hotz
2023-10-24 10:49:22 -04:00
committed by GitHub
parent d5e2fdea22
commit cea2bc7964
6 changed files with 170 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
import unittest
import pickle
from tinygrad.helpers import diskcache_get, diskcache_put
def remote_get(q,k): q.put(diskcache_get("test", k))
@@ -43,5 +44,16 @@ class DiskCache(unittest.TestCase):
self.assertEqual(diskcache_get("test", 4), 5)
self.assertEqual(diskcache_get("test", "4"), 5)
def test_dict_key(self):
fancy_key = {"hello": "world", "goodbye": 7, "good": True, "pkl": pickle.dumps("cat")}
fancy_key2 = {"hello": "world", "goodbye": 8, "good": True, "pkl": pickle.dumps("cat")}
fancy_key3 = {"hello": "world", "goodbye": 8, "good": True, "pkl": pickle.dumps("dog")}
diskcache_put("test2", fancy_key, 5)
self.assertEqual(diskcache_get("test2", fancy_key), 5)
diskcache_put("test2", fancy_key2, 8)
self.assertEqual(diskcache_get("test2", fancy_key2), 8)
self.assertEqual(diskcache_get("test2", fancy_key), 5)
self.assertEqual(diskcache_get("test2", fancy_key3), None)
if __name__ == "__main__":
unittest.main()