Replicate llm.c in tinygrad (#4179)

* write llm.c and add a few new methods to tensor

* training works

* add jit

* tests for new functions

* test tolist

* simple fix for onnx test failures (#4186)

* write llm.c and add a few new methods to tensor

* training works

* add jit

* tests for new functions

* bump line count to 7500

* simplest fix

* safenumpy tolist for now

---------

Co-authored-by: George Hotz <geohot@gmail.com>
Co-authored-by: George Hotz <72895+geohot@users.noreply.github.com>

---------

Co-authored-by: geohotstan <135171913+geohotstan@users.noreply.github.com>
This commit is contained in:
George Hotz
2024-04-16 15:40:48 +04:00
committed by GitHub
parent b6e7243bfa
commit 55ae73e951
6 changed files with 230 additions and 5 deletions

View File

@@ -1695,6 +1695,10 @@ class TestOps(unittest.TestCase):
helper_test_op([], lambda: torch.nn.functional.one_hot(torch.tensor(data), 8).type(torch.int32),
lambda: Tensor(data).one_hot(8), forward_only=True)
def test_masked_fill(self):
helper_test_op([(32,10)], lambda x: x.masked_fill((x>0.1).detach(), -math.inf))
helper_test_op([(32,10)], lambda x: x.masked_fill((x<0.1).detach(), -math.inf))
if __name__ == '__main__':
np.random.seed(1337)
unittest.main(verbosity=2)