Attempting to follow Andrej Karpathy's wonderful tutorial and implement micrograd in mojo.
- The
Valueuses reference semantics. - The
Value's internaldata,gradand_prevuse a custom and very basicRC(reference counting pointer) - this will be migrated to references (and lifetimes) once they are ready in the core language. - Using
traitsto makeValueagenericstruct (we introduce atraitcalledGradablewhich is basically a type constraint on what is needed on an 'autogradable' type which can be wrapped by ourValue). Gradableimplementations:-
GradFloat32 -
GradTensorFloat32
-
- The topological sort in
_backwardis using an iterative implementation (nested functions don't currently support recursion) - Primitive test suite (
make test) (including tests that mimic those of micrograd)
- Follow guide https://docs.modular.com/mojo/manual/get-started
- Opionally use the
devcontaier make installmake testmake runmake ...(seeMakeFile)